summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp5
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp19
-rw-r--r--xfa/fxfa/cxfa_textparser.h6
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp22
-rw-r--r--xfa/fxfa/cxfa_textprovider.h10
5 files changed, 30 insertions, 32 deletions
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 346a316781..976988ee32 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -773,7 +773,10 @@ bool CXFA_TextLayout::LoadRichText(
while (iTabCount-- > 0)
wsText += L'\t';
} else {
- m_textParser.GetEmbbedObj(m_pTextProvider, pXMLNode, wsText);
+ Optional<WideString> obj =
+ m_textParser.GetEmbeddedObj(m_pTextProvider, pXMLNode);
+ if (obj)
+ wsText = *obj;
}
}
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index c60b774051..0d1c52fab7 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -495,20 +495,19 @@ float CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider,
return fLineHeight;
}
-bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
- CFX_XMLNode* pXMLNode,
- WideString& wsValue) {
- wsValue.clear();
+Optional<WideString> CXFA_TextParser::GetEmbeddedObj(
+ CXFA_TextProvider* pTextProvider,
+ CFX_XMLNode* pXMLNode) {
if (!pXMLNode)
- return false;
+ return {};
CFX_XMLElement* pElement = ToXMLElement(pXMLNode);
if (!pElement)
- return false;
+ return {};
WideString wsAttr = pElement->GetAttribute(L"xfa:embed");
if (wsAttr.IsEmpty())
- return false;
+ return {};
if (wsAttr[0] == L'#')
wsAttr.Delete(0);
@@ -521,7 +520,7 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
bool bURI = (ws == L"uri");
if (!bURI && ws != L"som")
- return false;
+ return {};
ws = pElement->GetAttribute(L"xfa:embedMode");
if (ws.IsEmpty())
@@ -531,9 +530,9 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
bool bRaw = (ws == L"raw");
if (!bRaw && ws != L"formatted")
- return false;
+ return {};
- return pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue);
+ return pTextProvider->GetEmbeddedObj(bURI, bRaw, wsAttr);
}
CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap(
diff --git a/xfa/fxfa/cxfa_textparser.h b/xfa/fxfa/cxfa_textparser.h
index cd2856e6df..591606074e 100644
--- a/xfa/fxfa/cxfa_textparser.h
+++ b/xfa/fxfa/cxfa_textparser.h
@@ -14,6 +14,7 @@
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/fx_dib.h"
+#include "third_party/base/optional.h"
#include "xfa/fxfa/fxfa_basic.h"
class CFGAS_GEFont;
@@ -79,9 +80,8 @@ class CXFA_TextParser {
bool bFirst,
float fVerScale) const;
- bool GetEmbbedObj(CXFA_TextProvider* pTextProvider,
- CFX_XMLNode* pXMLNode,
- WideString& wsValue);
+ Optional<WideString> GetEmbeddedObj(CXFA_TextProvider* pTextProvider,
+ CFX_XMLNode* pXMLNode);
CXFA_TextParseContext* GetParseContextFromMap(CFX_XMLNode* pXMLNode);
protected:
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index ba48cd8490..b46bf345f9 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -130,21 +130,18 @@ CXFA_Font* CXFA_TextProvider::GetFontIfExists() {
return font ? font : m_pNode->GetFontIfExists();
}
-bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
+bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() const {
if (m_pNode->GetFFWidgetType() != XFA_FFWidgetType::kCheckButton)
return false;
return !m_pNode->TryWidth();
}
-bool CXFA_TextProvider::GetEmbbedObj(bool bURI,
- bool bRaw,
- const WideString& wsAttr,
- WideString& wsValue) {
- if (m_eType != XFA_TEXTPROVIDERTYPE_Text)
- return false;
-
- if (!bURI)
- return false;
+Optional<WideString> CXFA_TextProvider::GetEmbeddedObj(
+ bool bURI,
+ bool bRaw,
+ const WideString& wsAttr) {
+ if (m_eType != XFA_TEXTPROVIDERTYPE_Text || !bURI)
+ return {};
CXFA_Node* pParent = m_pNode->GetParent();
CXFA_Document* pDocument = m_pNode->GetDocument();
@@ -158,8 +155,7 @@ bool CXFA_TextProvider::GetEmbbedObj(bool bURI,
wsAttr.AsStringView());
}
if (!pIDNode || !pIDNode->IsWidgetReady())
- return false;
+ return {};
- wsValue = pIDNode->GetValue(XFA_VALUEPICTURE_Display);
- return true;
+ return pIDNode->GetValue(XFA_VALUEPICTURE_Display);
}
diff --git a/xfa/fxfa/cxfa_textprovider.h b/xfa/fxfa/cxfa_textprovider.h
index 4f349e47e2..d6f00056f0 100644
--- a/xfa/fxfa/cxfa_textprovider.h
+++ b/xfa/fxfa/cxfa_textprovider.h
@@ -8,6 +8,7 @@
#define XFA_FXFA_CXFA_TEXTPROVIDER_H_
#include "core/fxcrt/fx_string.h"
+#include "third_party/base/optional.h"
#include "xfa/fxfa/cxfa_textlayout.h"
class CXFA_Font;
@@ -33,11 +34,10 @@ class CXFA_TextProvider {
CXFA_Node* GetTextNode(bool& bRichText);
CXFA_Para* GetParaIfExists();
CXFA_Font* GetFontIfExists();
- bool IsCheckButtonAndAutoWidth();
- bool GetEmbbedObj(bool bURI,
- bool bRaw,
- const WideString& wsAttr,
- WideString& wsValue);
+ bool IsCheckButtonAndAutoWidth() const;
+ Optional<WideString> GetEmbeddedObj(bool bURI,
+ bool bRaw,
+ const WideString& wsAttr);
private:
CXFA_Node* m_pNode; // Raw, this class owned by tree node.