summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r--xfa/fxfa/app/xfa_ffbarcode.cpp12
-rw-r--r--xfa/fxfa/app/xfa_ffdoc.cpp9
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp6
-rw-r--r--xfa/fxfa/app/xfa_fontmgr.cpp25
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp37
-rw-r--r--xfa/fxfa/app/xfa_textlayout.h2
6 files changed, 35 insertions, 56 deletions
diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp
index 567882d546..b4608a349e 100644
--- a/xfa/fxfa/app/xfa_ffbarcode.cpp
+++ b/xfa/fxfa/app/xfa_ffbarcode.cpp
@@ -94,12 +94,12 @@ const int32_t g_iXFABarcodeTypeCount =
XFA_LPCBARCODETYPEENUMINFO XFA_GetBarcodeTypeByName(
const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength, TRUE);
- int32_t iStart = 0, iEnd = g_iXFABarcodeTypeCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, true);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFABarcodeTypeCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
XFA_LPCBARCODETYPEENUMINFO pInfo = g_XFABarCodeTypeEnumData + iMid;
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp
index 1fecee7547..4b0f67bb6a 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -326,8 +326,7 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
if (!m_pPDFDoc)
return nullptr;
- uint32_t dwHash =
- FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength(), FALSE);
+ uint32_t dwHash = FX_HashCode_GetW(wsName, false);
FX_IMAGEDIB_AND_DPI* imageDIBDpi = nullptr;
if (m_mapNamedImages.Lookup((void*)(uintptr_t)dwHash, (void*&)imageDIBDpi)) {
iImageXDpi = imageDIBDpi->iImageXDpi;
@@ -384,8 +383,7 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
}
CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) {
- uint32_t packetHash =
- FX_HashCode_String_GetW(wsPackage.c_str(), wsPackage.GetLength());
+ uint32_t packetHash = FX_HashCode_GetW(wsPackage, false);
CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash));
if (!pNode) {
return NULL;
@@ -399,8 +397,7 @@ FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage,
IFX_FileWrite* pFile,
CXFA_ChecksumContext* pCSContext) {
CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument);
- uint32_t packetHash =
- FX_HashCode_String_GetW(wsPackage.c_str(), wsPackage.GetLength());
+ uint32_t packetHash = FX_HashCode_GetW(wsPackage, false);
CXFA_Node* pNode = NULL;
if (packetHash == XFA_HASHCODE_Xfa) {
pNode = m_pDocument->GetRoot();
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index 986e265a45..7a858748b7 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -779,9 +779,9 @@ void CXFA_FFDocView::RunBindItems() {
wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$");
const bool bValueUseContent =
wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$");
- CFX_WideString wsValue, wsLabel;
- uint32_t uValueHash =
- FX_HashCode_String_GetW(wsValueRef.c_str(), wsValueRef.GetLength());
+ CFX_WideString wsValue;
+ CFX_WideString wsLabel;
+ uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false);
for (int32_t i = 0; i < iCount; i++) {
CXFA_Object* refObj = rs.nodes[i];
if (!refObj->IsNode()) {
diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp
index 72952a7bd9..02b44be789 100644
--- a/xfa/fxfa/app/xfa_fontmgr.cpp
+++ b/xfa/fxfa/app/xfa_fontmgr.cpp
@@ -1694,12 +1694,7 @@ static const XFA_FONTINFO g_XFAFontsMap[] = {
void XFA_LocalFontNameToEnglishName(const CFX_WideStringC& wsLocalName,
CFX_WideString& wsEnglishName) {
wsEnglishName = wsLocalName;
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
- uint32_t dwLocalNameHash = FX_HashCode_String_GetW(
- wsLocalName.c_str(), wsLocalName.GetLength(), TRUE);
+ uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true);
int32_t iStart = 0;
int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
int32_t iMid = 0;
@@ -1715,18 +1710,13 @@ void XFA_LocalFontNameToEnglishName(const CFX_WideStringC& wsLocalName,
iEnd = iMid - 1;
}
} while (iEnd >= iStart);
-#endif
}
const XFA_FONTINFO* XFA_GetFontINFOByFontName(
const CFX_WideStringC& wsFontName) {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
CFX_WideString wsFontNameTemp = wsFontName;
wsFontNameTemp.Remove(L' ');
- uint32_t dwCurFontNameHash = FX_HashCode_String_GetW(
- wsFontNameTemp.c_str(), wsFontNameTemp.GetLength(), TRUE);
+ uint32_t dwCurFontNameHash =
+ FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true);
int32_t iStart = 0;
int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
int32_t iMid = 0;
@@ -1744,9 +1734,6 @@ const XFA_FONTINFO* XFA_GetFontINFOByFontName(
}
} while (iEnd >= iStart);
return pFontInfo;
-#else
- return NULL;
-#endif
}
CXFA_DefFontMgr::~CXFA_DefFontMgr() {
@@ -1891,8 +1878,7 @@ IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
CPDF_Font** pPDFFont,
FX_BOOL bStrictMatch) {
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsFontFamily.c_str(), wsFontFamily.GetLength());
+ uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
CFX_ByteString strKey;
strKey.Format("%u%u", dwHashCode, dwFontStyles);
auto it = m_FontMap.find(strKey);
@@ -2018,8 +2004,7 @@ IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- uint32_t dwHash = FX_HashCode_String_GetW(wsFontFamily.c_str(),
- wsFontFamily.GetLength(), FALSE);
+ uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false);
CFX_ByteString bsKey;
bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage);
auto it = m_FontMap.find(bsKey);
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index b2030814bc..b259a7f357 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -112,22 +112,22 @@ IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle(
FDE_CSSLENGTH indent;
indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent());
pParaStyle->SetTextIndent(indent);
- FDE_CSSTEXTALIGN hAlgin = FDE_CSSTEXTALIGN_Left;
+ FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left;
switch (para.GetHorizontalAlign()) {
case XFA_ATTRIBUTEENUM_Center:
- hAlgin = FDE_CSSTEXTALIGN_Center;
+ hAlign = FDE_CSSTEXTALIGN_Center;
break;
case XFA_ATTRIBUTEENUM_Right:
- hAlgin = FDE_CSSTEXTALIGN_Right;
+ hAlign = FDE_CSSTEXTALIGN_Right;
break;
case XFA_ATTRIBUTEENUM_Justify:
- hAlgin = FDE_CSSTEXTALIGN_Justify;
+ hAlign = FDE_CSSTEXTALIGN_Justify;
break;
case XFA_ATTRIBUTEENUM_JustifyAll:
- hAlgin = FDE_CSSTEXTALIGN_JustifyAll;
+ hAlign = FDE_CSSTEXTALIGN_JustifyAll;
break;
}
- pParaStyle->SetTextAlign(hAlgin);
+ pParaStyle->SetTextAlign(hAlign);
FDE_CSSRECT rtMarginWidth;
rtMarginWidth.left.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginLeft());
rtMarginWidth.top.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceAbove());
@@ -275,8 +275,7 @@ void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
pXMLElement->GetLocalTagName(wsName);
tagProvider.SetTagNameObj(wsName);
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength(), TRUE);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsName.AsStringC(), true);
static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t);
CFX_DSPATemplate<uint32_t> lookup;
tagProvider.m_bTagAviliable =
@@ -292,7 +291,7 @@ void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
}
}
-int32_t CXFA_TextParser::GetVAlgin(CXFA_TextProvider* pTextProvider) const {
+int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const {
CXFA_Para para = pTextProvider->GetParaNode();
return para ? para.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top;
}
@@ -613,8 +612,7 @@ FX_BOOL CXFA_TextParser::GetTabstops(
break;
case XFA_TABSTOPSSTATUS_Location:
if (ch == ' ') {
- uint32_t dwHashCode = FX_HashCode_String_GetW(
- wsAlign.c_str(), wsAlign.GetLength(), TRUE);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true);
CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
pTabstopContext->Append(dwHashCode, fPos);
@@ -628,8 +626,7 @@ FX_BOOL CXFA_TextParser::GetTabstops(
}
}
if (!wsAlign.IsEmpty()) {
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsAlign.c_str(), wsAlign.GetLength(), TRUE);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true);
CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
pTabstopContext->Append(dwHashCode, fPos);
@@ -934,7 +931,7 @@ FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex,
if (iBlockCount == 0 && fHeight > 0) {
fHeight = fTextHeight - GetLayoutHeight();
if (fHeight > 0) {
- int32_t iAlign = m_textParser.GetVAlgin(m_pTextProvider);
+ int32_t iAlign = m_textParser.GetVAlign(m_pTextProvider);
if (iAlign == XFA_ATTRIBUTEENUM_Middle) {
fHeight /= 2.0f;
} else if (iAlign != XFA_ATTRIBUTEENUM_Bottom) {
@@ -1253,7 +1250,7 @@ void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) {
if (fHeight < 0.1f) {
return;
}
- switch (m_textParser.GetVAlgin(m_pTextProvider)) {
+ switch (m_textParser.GetVAlign(m_pTextProvider)) {
case XFA_ATTRIBUTEENUM_Middle:
fHeight /= 2.0f;
break;
@@ -1643,13 +1640,13 @@ void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle,
if (m_pTabstopContext->m_bTabstops) {
XFA_TABSTOPS* pTabstops =
m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex);
- uint32_t dwAlgin = pTabstops->dwAlign;
- if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) {
+ uint32_t dwAlign = pTabstops->dwAlign;
+ if (dwAlign == FX_HashCode_GetW(L"center", false)) {
fLeft = pPiece->rtPiece.width / 2.0f;
- } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) ||
- dwAlgin == FX_HashCode_String_GetW(L"before", 6)) {
+ } else if (dwAlign == FX_HashCode_GetW(L"right", false) ||
+ dwAlign == FX_HashCode_GetW(L"before", false)) {
fLeft = pPiece->rtPiece.width;
- } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) {
+ } else if (dwAlign == FX_HashCode_GetW(L"decimal", false)) {
int32_t iChars = pPiece->iChars;
for (int32_t i = 0; i < iChars; i++) {
if (pPiece->pszText[i] == L'.') {
diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h
index 9cced6a65a..ccebff8ad9 100644
--- a/xfa/fxfa/app/xfa_textlayout.h
+++ b/xfa/fxfa/app/xfa_textlayout.h
@@ -87,7 +87,7 @@ class CXFA_TextParser {
IFDE_CSSComputedStyle* pParentStyle);
FX_BOOL IsParsed() const { return m_pAllocator != NULL; }
- int32_t GetVAlgin(CXFA_TextProvider* pTextProvider) const;
+ int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const;
FX_FLOAT GetTabInterval(IFDE_CSSComputedStyle* pStyle) const;
int32_t CountTabs(IFDE_CSSComputedStyle* pStyle) const;
FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const;