summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/doc_basic.cpp4
-rw-r--r--core/fpdftext/fpdf_text_int.cpp13
-rw-r--r--core/fxcrt/fx_basic_bstring.cpp2
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp5
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp6
-rw-r--r--core/fxcrt/fx_xml_parser.cpp6
-rw-r--r--core/fxcrt/include/fx_basic.h10
-rw-r--r--core/fxcrt/include/fx_string.h3
8 files changed, 26 insertions, 23 deletions
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index a0c6b2babc..76639efac6 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -315,7 +315,7 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) {
result += ChangeSlashToPlatform(filepath.c_str());
return result;
#else
- return filepath;
+ return CFX_WideString(filepath);
#endif
}
@@ -390,7 +390,7 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) {
}
return ChangeSlashToPDF(filepath.c_str());
#else
- return filepath;
+ return CFX_WideString(filepath);
#endif
}
diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp
index f843da3061..136c44b5ed 100644
--- a/core/fpdftext/fpdf_text_int.cpp
+++ b/core/fpdftext/fpdf_text_int.cpp
@@ -537,7 +537,8 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (nCount == -1) {
nCount = pdfium::CollectionSize<int>(m_CharList) - start;
- return m_TextBuf.AsStringC().Mid(start, m_TextBuf.AsStringC().GetLength());
+ return CFX_WideString(
+ m_TextBuf.AsStringC().Mid(start, m_TextBuf.AsStringC().GetLength()));
}
if (nCount <= 0 || m_CharList.empty()) {
return L"";
@@ -574,7 +575,7 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (nCount <= 0) {
return L"";
}
- return m_TextBuf.AsStringC().Mid(startindex, nCount);
+ return CFX_WideString(m_TextBuf.AsStringC().Mid(startindex, nCount));
}
int CPDF_TextPage::CountRects(int start, int nCount) {
@@ -890,7 +891,7 @@ void CPDF_TextPage::CloseTempLine() {
if (m_TempCharList.empty())
return;
- CFX_WideString str = m_TempTextBuf.AsStringC();
+ CFX_WideString str = m_TempTextBuf.MakeString();
FX_BOOL bPrevSpace = FALSE;
for (int i = 0; i < str.GetLength(); i++) {
if (str.GetAt(i) != ' ') {
@@ -1299,7 +1300,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
charinfo.m_OriginY = 0;
pTextObj->GetItemInfo(i, &item);
if (item.m_CharCode == (uint32_t)-1) {
- CFX_WideString str = m_TempTextBuf.AsStringC();
+ CFX_WideString str = m_TempTextBuf.MakeString();
if (str.IsEmpty()) {
str = m_TextBuf.AsStringC();
}
@@ -1435,7 +1436,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
m_TempCharList.push_back(charinfo);
}
} else if (i == 0) {
- CFX_WideString str = m_TempTextBuf.AsStringC();
+ CFX_WideString str = m_TempTextBuf.MakeString();
if (!str.IsEmpty() &&
str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) {
m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
@@ -1478,7 +1479,7 @@ int32_t CPDF_TextPage::GetTextObjectWritingMode(
return m_TextlineDir;
}
FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) {
- CFX_WideString strCurText = m_TempTextBuf.AsStringC();
+ CFX_WideString strCurText = m_TempTextBuf.MakeString();
if (strCurText.GetLength() == 0) {
strCurText = m_TextBuf.AsStringC();
}
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index 3a81e41920..c774e80cb7 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -820,7 +820,7 @@ CFX_WideString CFX_ByteString::UTF8Decode() const {
for (FX_STRSIZE i = 0; i < GetLength(); i++) {
decoder.Input((uint8_t)m_pData->m_String[i]);
}
- return decoder.GetResult();
+ return CFX_WideString(decoder.GetResult());
}
// static
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index 5a75f8b487..6008a00b40 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -186,11 +186,6 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideTextBuf& buf) {
return *this;
}
-CFX_WideStringC CFX_WideTextBuf::AsStringC() const {
- return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
- m_DataSize / sizeof(FX_WCHAR));
-}
-
#ifdef PDF_ENABLE_XFA
CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(uint8_t i) {
if (m_pStream) {
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index 8c1d494e7a..241c3a6985 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -786,10 +786,10 @@ CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) {
return CFX_WideString();
CFX_UTF8Decoder decoder;
- for (FX_STRSIZE i = 0; i < str.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < str.GetLength(); i++)
decoder.Input(str[i]);
- }
- return decoder.GetResult();
+
+ return CFX_WideString(decoder.GetResult());
}
// static
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index 4b52189142..a5e351fe56 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -457,7 +457,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
iState = 10;
} else {
content << decoder.GetResult();
- CFX_WideString dataStr = content.AsStringC();
+ CFX_WideString dataStr = content.MakeString();
if (!bCDATA && !m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
@@ -501,7 +501,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
} while (ReadNextBlock());
content << decoder.GetResult();
- CFX_WideString dataStr = content.AsStringC();
+ CFX_WideString dataStr = content.MakeString();
if (!m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
@@ -784,7 +784,7 @@ void CXML_AttrMap::SetAt(const CFX_ByteStringC& space,
}
}
- m_pMap->push_back({space, name, value});
+ m_pMap->push_back({space, name, CFX_WideString(value)});
}
int CXML_AttrMap::GetSize() const {
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 7437d9567c..48999c4f19 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -80,7 +80,15 @@ class CFX_WideTextBuf : public CFX_BinaryBuf {
FX_WCHAR* GetBuffer() const {
return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get());
}
- CFX_WideStringC AsStringC() const;
+
+ CFX_WideStringC AsStringC() const {
+ return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
+ m_DataSize / sizeof(FX_WCHAR));
+ }
+ CFX_WideString MakeString() const {
+ return CFX_WideString(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
+ m_DataSize / sizeof(FX_WCHAR));
+ }
void Delete(int start_index, int count) {
CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR),
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 9019522eca..df8afb386f 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -250,8 +250,7 @@ class CFX_WideString {
CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
- // TODO(tsepez): mark constructor as explicit.
- CFX_WideString(const CFX_WideStringC& str);
+ explicit CFX_WideString(const CFX_WideStringC& str);
CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
~CFX_WideString();