summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-29 18:56:40 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-29 18:56:40 +0000
commitb3eb4ac763bbeb4744f4c8411d280abda6f17644 (patch)
treee3cf9517fe2833c6d730046017ddb12e43925dfd
parent97b4b48685b7624cc69f73f9c57bb9e23159c8ec (diff)
downloadpdfium-b3eb4ac763bbeb4744f4c8411d280abda6f17644.tar.xz
Remove static measurement data
This CL removes the static initialized CXFA_Measurement items and replaces them with strings which are converted to measurements at runtime. Bug: pdfium:804 Change-Id: I60422b6ddff750d504a5a8b62de6ad896fc80caf Reviewed-on: https://pdfium-review.googlesource.com/19770 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--xfa/fxfa/parser/cxfa_measurement.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp5
-rw-r--r--xfa/fxfa/parser/xfa_basic_data_attributes.cpp86
3 files changed, 36 insertions, 58 deletions
diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp
index 288ed0cd31..a929f701be 100644
--- a/xfa/fxfa/parser/cxfa_measurement.cpp
+++ b/xfa/fxfa/parser/cxfa_measurement.cpp
@@ -36,6 +36,7 @@ void CXFA_Measurement::SetString(const WideStringView& wsMeasure) {
m_eUnit = XFA_Unit::Unknown;
return;
}
+
int32_t iUsedLen = 0;
int32_t iOffset = (wsMeasure[0] == L'=') ? 1 : 0;
float fValue = FXSYS_wcstof(wsMeasure.unterminated_c_str() + iOffset,
@@ -142,6 +143,8 @@ XFA_Unit CXFA_Measurement::GetUnitFromString(const WideStringView& wsUnit) {
return XFA_Unit::Mp;
if (wsUnit == L"em")
return XFA_Unit::Em;
+ if (wsUnit == L"an")
+ return XFA_Unit::Angle;
if (wsUnit == L"%")
return XFA_Unit::Percent;
return XFA_Unit::Unknown;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index f11876f255..05228734f3 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1352,9 +1352,8 @@ pdfium::Optional<CXFA_Measurement> CXFA_Node::GetDefaultMeasurement(
if (!value)
return {};
- CXFA_Measurement measure;
- memcpy(&measure, *value, sizeof(measure));
- return {measure};
+ WideString str = WideString(static_cast<const wchar_t*>(*value));
+ return {CXFA_Measurement(str.AsStringView())};
}
pdfium::Optional<WideString> CXFA_Node::GetDefaultCData(
diff --git a/xfa/fxfa/parser/xfa_basic_data_attributes.cpp b/xfa/fxfa/parser/xfa_basic_data_attributes.cpp
index 7b371a0239..038f89405a 100644
--- a/xfa/fxfa/parser/xfa_basic_data_attributes.cpp
+++ b/xfa/fxfa/parser/xfa_basic_data_attributes.cpp
@@ -9,31 +9,17 @@
#include "xfa/fxfa/fxfa_basic.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
-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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{0x77, L"w", XFA_Attribute::W, XFA_AttributeType::Measure,
- XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{0x78, L"x", XFA_Attribute::X, XFA_AttributeType::Measure,
XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x79, L"y", XFA_Attribute::Y, XFA_AttributeType::Measure,
XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x21aed, L"id", XFA_Attribute::Id, XFA_AttributeType::CData,
XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template |
XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form,
@@ -74,7 +60,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)L"100%"},
{0x8d4f1c7, L"textIndent", XFA_Attribute::TextIndent,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x97c1c65, L"context", XFA_Attribute::Context, XFA_AttributeType::Integer,
XFA_XDPPACKET_UNKNOWN, (void*)0},
{0x9876578, L"trayOut", XFA_Attribute::TrayOut, XFA_AttributeType::Enum,
@@ -102,14 +88,14 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
nullptr},
{0xcfea02e, L"leftInset", XFA_Attribute::LeftInset,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{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)},
+ (void*)L"0in"},
{0x13a08bdb, L"overflowTarget", XFA_Attribute::OverflowTarget,
XFA_AttributeType::CData, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
nullptr},
@@ -148,7 +134,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
XFA_XDPPACKET_SourceSet, nullptr},
{0x25764436, L"topInset", XFA_Attribute::TopInset,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x25839852, L"access", XFA_Attribute::Access, XFA_AttributeType::Enum,
XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)XFA_ATTRIBUTEENUM_Open},
@@ -167,7 +153,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
XFA_XDPPACKET_LocaleSet, (void*)0},
{0x2a82d99c, L"marginRight", XFA_Attribute::MarginRight,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x2b5df51e, L"dataDescription", XFA_Attribute::DataDescription,
XFA_AttributeType::CData, XFA_XDPPACKET_ConnectionSet, nullptr},
{0x2bb3f470, L"encipherOnly", XFA_Attribute::EncipherOnly,
@@ -177,16 +163,14 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0an"},
{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, nullptr},
{0x34ae103c, L"reserve", XFA_Attribute::Reserve, XFA_AttributeType::Measure,
- XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 4)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"-1"},
{0x3650557e, L"textLocation", XFA_Attribute::TextLocation,
XFA_AttributeType::Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)XFA_ATTRIBUTEENUM_Below},
@@ -198,7 +182,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)0},
{0x3b582286, L"moduleWidth", XFA_Attribute::ModuleWidth,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 3)},
+ (void*)L"0.25mm"},
{0x3d123c26, L"hyphenate", XFA_Attribute::Hyphenate,
XFA_AttributeType::Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)0},
@@ -227,7 +211,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
nullptr},
{0x4873c601, L"baselineShift", XFA_Attribute::BaselineShift,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x4b319767, L"overlinePeriod", XFA_Attribute::OverlinePeriod,
XFA_AttributeType::Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)XFA_ATTRIBUTEENUM_All},
@@ -244,13 +228,13 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)0},
{0x534729c9, L"marginLeft", XFA_Attribute::MarginLeft,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{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)},
+ (void*)L"5mm"},
{0x54fa722c, L"transferEncoding", XFA_Attribute::TransferEncoding,
XFA_AttributeType::NotSure,
XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
@@ -263,7 +247,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)XFA_ATTRIBUTEENUM_Visible},
{0x5739d1ff, L"radixOffset", XFA_Attribute::RadixOffset,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x577682ac, L"preserve", XFA_Attribute::Preserve, XFA_AttributeType::CData,
XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, nullptr},
{0x58be2870, L"aliasNode", XFA_Attribute::AliasNode,
@@ -281,7 +265,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)XFA_ATTRIBUTEENUM_Error},
{0x5c054755, L"startAngle", XFA_Attribute::StartAngle,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 5)},
+ (void*)L"0an"},
{0x5ec958c0, L"cursorType", XFA_Attribute::CursorType,
XFA_AttributeType::Enum, XFA_XDPPACKET_SourceSet,
(void*)XFA_ATTRIBUTEENUM_ForwardOnly},
@@ -319,10 +303,10 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)XFA_ATTRIBUTEENUM_Client},
{0x731e0665, L"spaceBelow", XFA_Attribute::SpaceBelow,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0x74788f8b, L"sweepAngle", XFA_Attribute::SweepAngle,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 7)},
+ (void*)L"360an"},
{0x78bff531, L"numberOfCells", XFA_Attribute::NumberOfCells,
XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)0},
@@ -346,20 +330,16 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{0x7c2ff6bd, L"maxW", XFA_Attribute::MaxW, XFA_AttributeType::Measure,
- XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{0x7d02357b, L"minW", XFA_Attribute::MinW, XFA_AttributeType::Measure,
- XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{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,
@@ -382,7 +362,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
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)},
+ (void*)L"0in"},
{0x8af2e657, L"maxChars", XFA_Attribute::MaxChars,
XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)0},
@@ -412,14 +392,13 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{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)},
+ (void*)L"0.5pt"},
{0x957fa006, L"commitOn", XFA_Attribute::CommitOn, XFA_AttributeType::Enum,
XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)XFA_ATTRIBUTEENUM_Select},
@@ -474,8 +453,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"10pt"},
{0xa85e74f3, L"initialNumber", XFA_Attribute::InitialNumber,
XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)1},
@@ -586,7 +564,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
nullptr},
{0xd4b01921, L"lineHeight", XFA_Attribute::LineHeight,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 1)},
+ (void*)L"0pt"},
{0xd4cc53f8, L"highlight", XFA_Attribute::Highlight,
XFA_AttributeType::Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)XFA_ATTRIBUTEENUM_Inverted},
@@ -632,7 +610,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
(void*)2},
{0xe18b5659, L"spaceAbove", XFA_Attribute::SpaceAbove,
XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ (void*)L"0in"},
{0xe1a26b56, L"codeBase", XFA_Attribute::CodeBase, XFA_AttributeType::CData,
XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, nullptr},
{0xe349d044, L"stock", XFA_Attribute::Stock, XFA_AttributeType::CData,
@@ -658,8 +636,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
XFA_AttributeType::CData, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
nullptr},
{0xe948b9a8, L"radius", XFA_Attribute::Radius, XFA_AttributeType::Measure,
- XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
- (void*)(g_XFAMeasurementData + 0)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{0xe996b2fe, L"sourceAbove", XFA_Attribute::SourceAbove,
XFA_AttributeType::Enum, XFA_XDPPACKET_Config,
(void*)XFA_ATTRIBUTEENUM_Warn},
@@ -690,8 +667,7 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = {
{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)},
+ XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"},
{0xf6b59543, L"intact", XFA_Attribute::Intact, XFA_AttributeType::Enum,
XFA_XDPPACKET_Template | XFA_XDPPACKET_Form,
(void*)XFA_ATTRIBUTEENUM_None},