summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_texteditengine.cpp80
-rw-r--r--xfa/fde/cfde_texteditengine.h21
-rw-r--r--xfa/fde/cfde_texteditengine_unittest.cpp4
-rw-r--r--xfa/fde/cfde_textout.cpp10
-rw-r--r--xfa/fde/cfde_textout.h10
5 files changed, 62 insertions, 63 deletions
diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp
index 9fc7990ca3..999380b401 100644
--- a/xfa/fde/cfde_texteditengine.cpp
+++ b/xfa/fde/cfde_texteditengine.cpp
@@ -38,7 +38,7 @@ class InsertOperation : public CFDE_TextEditEngine::Operation {
public:
InsertOperation(CFDE_TextEditEngine* engine,
size_t start_idx,
- const CFX_WideString& added_text)
+ const WideString& added_text)
: engine_(engine), start_idx_(start_idx), added_text_(added_text) {}
~InsertOperation() override {}
@@ -56,14 +56,14 @@ class InsertOperation : public CFDE_TextEditEngine::Operation {
private:
CFX_UnownedPtr<CFDE_TextEditEngine> engine_;
size_t start_idx_;
- CFX_WideString added_text_;
+ WideString added_text_;
};
class DeleteOperation : public CFDE_TextEditEngine::Operation {
public:
DeleteOperation(CFDE_TextEditEngine* engine,
size_t start_idx,
- const CFX_WideString& removed_text)
+ const WideString& removed_text)
: engine_(engine), start_idx_(start_idx), removed_text_(removed_text) {}
~DeleteOperation() override {}
@@ -81,15 +81,15 @@ class DeleteOperation : public CFDE_TextEditEngine::Operation {
private:
CFX_UnownedPtr<CFDE_TextEditEngine> engine_;
size_t start_idx_;
- CFX_WideString removed_text_;
+ WideString removed_text_;
};
class ReplaceOperation : public CFDE_TextEditEngine::Operation {
public:
ReplaceOperation(CFDE_TextEditEngine* engine,
size_t start_idx,
- const CFX_WideString& removed_text,
- const CFX_WideString& added_text)
+ const WideString& removed_text,
+ const WideString& added_text)
: insert_op_(engine, start_idx, added_text),
delete_op_(engine, start_idx, removed_text) {}
@@ -195,7 +195,7 @@ void CFDE_TextEditEngine::SetMaxEditOperationsForTesting(size_t max) {
}
void CFDE_TextEditEngine::AdjustGap(size_t idx, size_t length) {
- static const size_t char_size = sizeof(CFX_WideString::CharType);
+ static const size_t char_size = sizeof(WideString::CharType);
// Move the gap, if necessary.
if (idx < gap_position_) {
@@ -222,7 +222,7 @@ void CFDE_TextEditEngine::AdjustGap(size_t idx, size_t length) {
}
}
-size_t CFDE_TextEditEngine::CountCharsExceedingSize(const CFX_WideString& text,
+size_t CFDE_TextEditEngine::CountCharsExceedingSize(const WideString& text,
size_t num_to_check) {
if (!limit_horizontal_area_ && !limit_vertical_area_)
return 0;
@@ -245,7 +245,7 @@ size_t CFDE_TextEditEngine::CountCharsExceedingSize(const CFX_WideString& text,
text_out->SetStyles(style);
size_t length = text.GetLength();
- CFX_WideStringC temp(text.c_str(), length);
+ WideStringView temp(text.c_str(), length);
float vertical_height = line_spacing_ * visible_line_count_;
size_t chars_exceeding_size = 0;
@@ -253,7 +253,7 @@ size_t CFDE_TextEditEngine::CountCharsExceedingSize(const CFX_WideString& text,
for (size_t i = 0; i < num_to_check; i++) {
// This does a lot of string copying ....
// TODO(dsinclair): make CalcLogicSize take a WideStringC instead.
- text_out->CalcLogicSize(CFX_WideString(temp), text_rect);
+ text_out->CalcLogicSize(WideString(temp), text_rect);
if (limit_horizontal_area_ && text_rect.width <= available_width_)
break;
@@ -269,7 +269,7 @@ size_t CFDE_TextEditEngine::CountCharsExceedingSize(const CFX_WideString& text,
}
void CFDE_TextEditEngine::Insert(size_t idx,
- const CFX_WideString& text,
+ const WideString& text,
RecordOperation add_operation) {
if (idx > text_length_)
idx = text_length_;
@@ -289,15 +289,15 @@ void CFDE_TextEditEngine::Insert(size_t idx,
AdjustGap(idx, length);
if (validation_enabled_ || limit_horizontal_area_ || limit_vertical_area_) {
- CFX_WideString str;
+ WideString str;
if (gap_position_ > 0)
- str += CFX_WideStringC(content_.data(), gap_position_);
+ str += WideStringView(content_.data(), gap_position_);
str += text;
if (text_length_ - gap_position_ > 0) {
- str += CFX_WideStringC(content_.data() + gap_position_ + gap_size_,
- text_length_ - gap_position_);
+ str += WideStringView(content_.data() + gap_position_ + gap_size_,
+ text_length_ - gap_position_);
}
if (validation_enabled_ && delegate_ && !delegate_->OnValidate(str)) {
@@ -328,12 +328,12 @@ void CFDE_TextEditEngine::Insert(size_t idx,
pdfium::MakeUnique<InsertOperation>(this, gap_position_, text));
}
- CFX_WideString previous_text;
+ WideString previous_text;
if (delegate_)
previous_text = GetText();
// Copy the new text into the gap.
- static const size_t char_size = sizeof(CFX_WideString::CharType);
+ static const size_t char_size = sizeof(WideString::CharType);
memcpy(content_.data() + gap_position_, text.c_str(), length * char_size);
gap_position_ += length;
gap_size_ -= length;
@@ -623,32 +623,32 @@ void CFDE_TextEditEngine::SetSelection(size_t start_idx, size_t end_idx) {
selection_.end_idx = end_idx;
}
-CFX_WideString CFDE_TextEditEngine::GetSelectedText() const {
+WideString CFDE_TextEditEngine::GetSelectedText() const {
if (!has_selection_)
return L"";
- CFX_WideString text;
+ WideString text;
if (selection_.start_idx < gap_position_) {
if (selection_.end_idx < gap_position_) {
- text += CFX_WideStringC(content_.data() + selection_.start_idx,
- selection_.end_idx - selection_.start_idx + 1);
+ text += WideStringView(content_.data() + selection_.start_idx,
+ selection_.end_idx - selection_.start_idx + 1);
return text;
}
- text += CFX_WideStringC(content_.data() + selection_.start_idx,
- gap_position_ - selection_.start_idx);
- text += CFX_WideStringC(
+ text += WideStringView(content_.data() + selection_.start_idx,
+ gap_position_ - selection_.start_idx);
+ text += WideStringView(
content_.data() + gap_position_ + gap_size_,
selection_.end_idx - (gap_position_ - selection_.start_idx) + 1);
return text;
}
- text += CFX_WideStringC(content_.data() + gap_size_ + selection_.start_idx,
- selection_.end_idx - selection_.start_idx + 1);
+ text += WideStringView(content_.data() + gap_size_ + selection_.start_idx,
+ selection_.end_idx - selection_.start_idx + 1);
return text;
}
-CFX_WideString CFDE_TextEditEngine::DeleteSelectedText(
+WideString CFDE_TextEditEngine::DeleteSelectedText(
RecordOperation add_operation) {
if (!has_selection_)
return L"";
@@ -657,24 +657,24 @@ CFX_WideString CFDE_TextEditEngine::DeleteSelectedText(
selection_.end_idx - selection_.start_idx + 1, add_operation);
}
-CFX_WideString CFDE_TextEditEngine::Delete(size_t start_idx,
- size_t length,
- RecordOperation add_operation) {
+WideString CFDE_TextEditEngine::Delete(size_t start_idx,
+ size_t length,
+ RecordOperation add_operation) {
if (start_idx >= text_length_)
return L"";
length = std::min(length, text_length_ - start_idx);
AdjustGap(start_idx + length, 0);
- CFX_WideString ret;
- ret += CFX_WideStringC(content_.data() + start_idx, length);
+ WideString ret;
+ ret += WideStringView(content_.data() + start_idx, length);
if (add_operation == RecordOperation::kInsertRecord) {
AddOperationRecord(
pdfium::MakeUnique<DeleteOperation>(this, start_idx, ret));
}
- CFX_WideString previous_text = GetText();
+ WideString previous_text = GetText();
gap_position_ = start_idx;
gap_size_ += length;
@@ -688,23 +688,23 @@ CFX_WideString CFDE_TextEditEngine::Delete(size_t start_idx,
return ret;
}
-void CFDE_TextEditEngine::ReplaceSelectedText(const CFX_WideString& rep) {
+void CFDE_TextEditEngine::ReplaceSelectedText(const WideString& rep) {
size_t start_idx = selection_.start_idx;
- CFX_WideString txt = DeleteSelectedText(RecordOperation::kSkipRecord);
+ WideString txt = DeleteSelectedText(RecordOperation::kSkipRecord);
Insert(gap_position_, rep, RecordOperation::kSkipRecord);
AddOperationRecord(
pdfium::MakeUnique<ReplaceOperation>(this, start_idx, txt, rep));
}
-CFX_WideString CFDE_TextEditEngine::GetText() const {
- CFX_WideString str;
+WideString CFDE_TextEditEngine::GetText() const {
+ WideString str;
if (gap_position_ > 0)
- str += CFX_WideStringC(content_.data(), gap_position_);
+ str += WideStringView(content_.data(), gap_position_);
if (text_length_ - gap_position_ > 0) {
- str += CFX_WideStringC(content_.data() + gap_position_ + gap_size_,
- text_length_ - gap_position_);
+ str += WideStringView(content_.data() + gap_position_ + gap_size_,
+ text_length_ - gap_position_);
}
return str;
}
diff --git a/xfa/fde/cfde_texteditengine.h b/xfa/fde/cfde_texteditengine.h
index aa8a24381d..750b62a2e1 100644
--- a/xfa/fde/cfde_texteditengine.h
+++ b/xfa/fde/cfde_texteditengine.h
@@ -66,9 +66,9 @@ class CFDE_TextEditEngine {
virtual ~Delegate() = default;
virtual void NotifyTextFull() = 0;
virtual void OnCaretChanged() = 0;
- virtual void OnTextChanged(const CFX_WideString& prevText) = 0;
+ virtual void OnTextChanged(const WideString& prevText) = 0;
virtual void OnSelChanged() = 0;
- virtual bool OnValidate(const CFX_WideString& wsText) = 0;
+ virtual bool OnValidate(const WideString& wsText) = 0;
virtual void SetScrollOffset(float fScrollOffset) = 0;
};
@@ -84,13 +84,13 @@ class CFDE_TextEditEngine {
void Clear();
void Insert(size_t idx,
- const CFX_WideString& text,
+ const WideString& text,
RecordOperation add_operation = RecordOperation::kInsertRecord);
- CFX_WideString Delete(
+ WideString Delete(
size_t start_idx,
size_t length,
RecordOperation add_operation = RecordOperation::kInsertRecord);
- CFX_WideString GetText() const;
+ WideString GetText() const;
size_t GetLength() const;
// Non-const so we can force a layout.
@@ -147,10 +147,10 @@ class CFDE_TextEditEngine {
std::pair<size_t, size_t> GetSelection() const {
return {selection_.start_idx, selection_.end_idx};
}
- CFX_WideString GetSelectedText() const;
- CFX_WideString DeleteSelectedText(
+ WideString GetSelectedText() const;
+ WideString DeleteSelectedText(
RecordOperation add_operation = RecordOperation::kInsertRecord);
- void ReplaceSelectedText(const CFX_WideString& str);
+ void ReplaceSelectedText(const WideString& str);
void Layout();
@@ -183,8 +183,7 @@ class CFDE_TextEditEngine {
void SetCombTextWidth();
void AdjustGap(size_t idx, size_t length);
void RebuildPieces();
- size_t CountCharsExceedingSize(const CFX_WideString& str,
- size_t num_to_check);
+ size_t CountCharsExceedingSize(const WideString& str, size_t num_to_check);
void AddOperationRecord(std::unique_ptr<Operation> op);
bool IsAlignedRight() const {
@@ -210,7 +209,7 @@ class CFDE_TextEditEngine {
FX_ARGB font_color_;
float font_size_;
float line_spacing_;
- std::vector<CFX_WideString::CharType> content_;
+ std::vector<WideString::CharType> content_;
size_t text_length_;
size_t gap_position_;
size_t gap_size_;
diff --git a/xfa/fde/cfde_texteditengine_unittest.cpp b/xfa/fde/cfde_texteditengine_unittest.cpp
index 2084914bbf..48ed647945 100644
--- a/xfa/fde/cfde_texteditengine_unittest.cpp
+++ b/xfa/fde/cfde_texteditengine_unittest.cpp
@@ -20,9 +20,9 @@ class CFDE_TextEditEngineTest : public testing::Test {
void NotifyTextFull() override { text_is_full = true; }
void OnCaretChanged() override {}
- void OnTextChanged(const CFX_WideString& prevText) override {}
+ void OnTextChanged(const WideString& prevText) override {}
void OnSelChanged() override {}
- bool OnValidate(const CFX_WideString& wsText) override {
+ bool OnValidate(const WideString& wsText) override {
return !fail_validation;
}
void SetScrollOffset(float fScrollOffset) override {}
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 7ccc9688da..3cf4ed36e0 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -191,13 +191,13 @@ void CFDE_TextOut::SetLineBreakTolerance(float fTolerance) {
m_pTxtBreak->SetLineBreakTolerance(m_fTolerance);
}
-void CFDE_TextOut::CalcLogicSize(const CFX_WideString& str, CFX_SizeF& size) {
+void CFDE_TextOut::CalcLogicSize(const WideString& str, CFX_SizeF& size) {
CFX_RectF rtText(0.0f, 0.0f, size.width, size.height);
CalcLogicSize(str, rtText);
size = rtText.Size();
}
-void CFDE_TextOut::CalcLogicSize(const CFX_WideString& str, CFX_RectF& rect) {
+void CFDE_TextOut::CalcLogicSize(const WideString& str, CFX_RectF& rect) {
if (str.IsEmpty()) {
rect.width = 0.0f;
rect.height = 0.0f;
@@ -278,7 +278,7 @@ bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus,
}
void CFDE_TextOut::DrawLogicText(CFX_RenderDevice* device,
- const CFX_WideStringC& str,
+ const WideStringView& str,
const CFX_RectF& rect) {
ASSERT(m_pFont && m_fFontSize >= 1.0f);
@@ -292,7 +292,7 @@ void CFDE_TextOut::DrawLogicText(CFX_RenderDevice* device,
m_ttoLines.clear();
m_wsText.clear();
- LoadText(CFX_WideString(str), rect);
+ LoadText(WideString(str), rect);
Reload(rect);
DoAlignment(rect);
@@ -321,7 +321,7 @@ void CFDE_TextOut::DrawLogicText(CFX_RenderDevice* device,
device->RestoreState(false);
}
-void CFDE_TextOut::LoadText(const CFX_WideString& str, const CFX_RectF& rect) {
+void CFDE_TextOut::LoadText(const WideString& str, const CFX_RectF& rect) {
ASSERT(!str.IsEmpty());
m_wsText = str;
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index 89c8eac28d..b936eb4415 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -95,10 +95,10 @@ class CFDE_TextOut {
void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
void SetLineBreakTolerance(float fTolerance);
- void CalcLogicSize(const CFX_WideString& str, CFX_SizeF& size);
- void CalcLogicSize(const CFX_WideString& str, CFX_RectF& rect);
+ void CalcLogicSize(const WideString& str, CFX_SizeF& size);
+ void CalcLogicSize(const WideString& str, CFX_RectF& rect);
void DrawLogicText(CFX_RenderDevice* device,
- const CFX_WideStringC& str,
+ const WideStringView& str,
const CFX_RectF& rect);
int32_t GetTotalLines() const { return m_iTotalLines; }
@@ -107,7 +107,7 @@ class CFDE_TextOut {
float& fStartPos,
float& fWidth,
float& fHeight);
- void LoadText(const CFX_WideString& str, const CFX_RectF& rect);
+ void LoadText(const WideString& str, const CFX_RectF& rect);
void Reload(const CFX_RectF& rect);
void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect);
@@ -131,7 +131,7 @@ class CFDE_TextOut {
std::vector<int32_t> m_CharWidths;
FX_ARGB m_TxtColor;
uint32_t m_dwTxtBkStyles;
- CFX_WideString m_wsText;
+ WideString m_wsText;
CFX_Matrix m_Matrix;
std::deque<CFDE_TTOLine> m_ttoLines;
int32_t m_iCurLine;