summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp11
-rw-r--r--xfa/fde/ifde_txtedtengine.h1
-rw-r--r--xfa/fde/tto/fde_textout.cpp4
-rw-r--r--xfa/fgas/layout/cfx_break.cpp138
-rw-r--r--xfa/fgas/layout/cfx_break.h81
-rw-r--r--xfa/fgas/layout/cfx_breakpiece.cpp1
-rw-r--r--xfa/fgas/layout/cfx_breakpiece.h1
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp151
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h41
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak_unittest.cpp4
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp148
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h49
-rw-r--r--xfa/fwl/cfwl_edit.cpp1
-rw-r--r--xfa/fxfa/app/cxfa_textlayout.cpp4
14 files changed, 294 insertions, 341 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 380948e899..7c2ba5c50f 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -37,7 +37,6 @@ FDE_TXTEDTPARAMS::FDE_TXTEDTPARAMS()
dwFontColor(0xff000000),
fLineSpace(10.0f),
fTabWidth(36),
- bTabEquidistant(false),
wDefChar(0xFEFF),
wLineBreakChar('\n'),
nLineEnd(0),
@@ -1001,14 +1000,14 @@ void CFDE_TxtEdtEngine::UpdatePages() {
void CFDE_TxtEdtEngine::UpdateTxtBreak() {
uint32_t dwStyle = m_pTextBreak->GetLayoutStyles();
if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)
- dwStyle &= ~FX_TXTLAYOUTSTYLE_SingleLine;
+ dwStyle &= ~FX_LAYOUTSTYLE_SingleLine;
else
- dwStyle |= FX_TXTLAYOUTSTYLE_SingleLine;
+ dwStyle |= FX_LAYOUTSTYLE_SingleLine;
if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText)
- dwStyle |= FX_TXTLAYOUTSTYLE_CombText;
+ dwStyle |= FX_LAYOUTSTYLE_CombText;
else
- dwStyle &= ~FX_TXTLAYOUTSTYLE_CombText;
+ dwStyle &= ~FX_LAYOUTSTYLE_CombText;
m_pTextBreak->SetLayoutStyles(dwStyle);
uint32_t dwAligment = 0;
@@ -1037,7 +1036,7 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() {
}
m_pTextBreak->SetFont(m_Param.pFont);
m_pTextBreak->SetFontSize(m_Param.fFontSize);
- m_pTextBreak->SetTabWidth(m_Param.fTabWidth, m_Param.bTabEquidistant);
+ m_pTextBreak->SetTabWidth(m_Param.fTabWidth);
m_pTextBreak->SetDefaultChar(m_Param.wDefChar);
m_pTextBreak->SetParagraphBreakChar(m_Param.wLineBreakChar);
m_pTextBreak->SetLineBreakTolerance(m_Param.fFontSize * 0.2f);
diff --git a/xfa/fde/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h
index 488e8ea271..7fef6f0315 100644
--- a/xfa/fde/ifde_txtedtengine.h
+++ b/xfa/fde/ifde_txtedtengine.h
@@ -84,7 +84,6 @@ struct FDE_TXTEDTPARAMS {
FX_ARGB dwFontColor;
float fLineSpace;
float fTabWidth;
- bool bTabEquidistant;
wchar_t wDefChar;
wchar_t wLineBreakChar;
int32_t nLineEnd;
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index f816176841..6808ff0c6c 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -67,14 +67,14 @@ void CFDE_TextOut::SetStyles(uint32_t dwStyles) {
m_dwStyles = dwStyles;
m_dwTxtBkStyles = 0;
if (dwStyles & FDE_TTOSTYLE_SingleLine)
- m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_SingleLine;
+ m_dwTxtBkStyles |= FX_LAYOUTSTYLE_SingleLine;
m_pTxtBreak->SetLayoutStyles(m_dwTxtBkStyles);
}
void CFDE_TextOut::SetTabWidth(float fTabWidth) {
ASSERT(fTabWidth > 1.0f);
- m_pTxtBreak->SetTabWidth(fTabWidth, false);
+ m_pTxtBreak->SetTabWidth(fTabWidth);
}
void CFDE_TextOut::SetEllipsisString(const CFX_WideString& wsEllipsis) {
diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp
new file mode 100644
index 0000000000..8be1d1704a
--- /dev/null
+++ b/xfa/fgas/layout/cfx_break.cpp
@@ -0,0 +1,138 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fgas/layout/cfx_break.h"
+
+#include <algorithm>
+
+namespace {
+
+const int kMinimumTabWidth = 160000;
+
+} // namespace
+
+CFX_Break::CFX_Break(uint32_t dwLayoutStyles)
+ : m_eCharType(FX_CHARTYPE_Unknown),
+ m_bSingleLine(false),
+ m_bCombText(false),
+ m_dwLayoutStyles(dwLayoutStyles),
+ m_iLineStart(0),
+ m_iLineWidth(2000000),
+ m_wParagraphBreakChar(L'\n'),
+ m_iFontSize(240),
+ m_iTabWidth(720000),
+ m_iHorizontalScale(100),
+ m_iVerticalScale(100),
+ m_iTolerance(0),
+ m_iCharSpace(0),
+ m_iDefChar(0),
+ m_wDefChar(0xFEFF),
+ m_pFont(nullptr),
+ m_pCurLine(nullptr),
+ m_iReadyLineIndex(-1) {
+ m_pCurLine = &m_Line[0];
+}
+
+CFX_Break::~CFX_Break() {}
+
+void CFX_Break::SetLayoutStyles(uint32_t dwLayoutStyles) {
+ m_dwLayoutStyles = dwLayoutStyles;
+ m_bSingleLine = (m_dwLayoutStyles & FX_LAYOUTSTYLE_SingleLine) != 0;
+ m_bCombText = (m_dwLayoutStyles & FX_LAYOUTSTYLE_CombText) != 0;
+
+ ResetArabicContext();
+}
+
+void CFX_Break::SetHorizontalScale(int32_t iScale) {
+ iScale = std::max(iScale, 0);
+ if (m_iHorizontalScale == iScale)
+ return;
+
+ SetBreakStatus();
+ m_iHorizontalScale = iScale;
+}
+
+void CFX_Break::SetVerticalScale(int32_t iScale) {
+ if (iScale < 0)
+ iScale = 0;
+ if (m_iVerticalScale == iScale)
+ return;
+
+ SetBreakStatus();
+ m_iVerticalScale = iScale;
+}
+
+void CFX_Break::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont) {
+ if (!pFont || pFont == m_pFont)
+ return;
+
+ SetBreakStatus();
+ m_pFont = pFont;
+ FontChanged();
+}
+
+void CFX_Break::SetFontSize(float fFontSize) {
+ int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
+ if (m_iFontSize == iFontSize)
+ return;
+
+ SetBreakStatus();
+ m_iFontSize = iFontSize;
+ FontChanged();
+}
+
+void CFX_Break::FontChanged() {
+ m_iDefChar = 0;
+ if (!m_pFont || m_wDefChar == 0xFEFF)
+ return;
+
+ m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
+ m_iDefChar *= m_iFontSize;
+}
+
+void CFX_Break::SetTabWidth(float fTabWidth) {
+ // Note, the use of max here was only done in the TxtBreak code. Leaving this
+ // in for the RTFBreak code for consistency. If we see issues with tab widths
+ // we may need to fix this.
+ m_iTabWidth = std::max(FXSYS_round(fTabWidth * 20000.0f), kMinimumTabWidth);
+}
+
+void CFX_Break::SetDefaultChar(wchar_t wch) {
+ m_wDefChar = wch;
+ m_iDefChar = 0;
+ if (m_wDefChar == 0xFEFF || !m_pFont)
+ return;
+
+ m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
+ if (m_iDefChar < 0)
+ m_iDefChar = 0;
+ else
+ m_iDefChar *= m_iFontSize;
+}
+
+void CFX_Break::SetParagraphBreakChar(wchar_t wch) {
+ if (wch != L'\r' && wch != L'\n')
+ return;
+ m_wParagraphBreakChar = wch;
+}
+
+void CFX_Break::SetLineBreakTolerance(float fTolerance) {
+ m_iTolerance = FXSYS_round(fTolerance * 20000.0f);
+}
+
+void CFX_Break::SetCharSpace(float fCharSpace) {
+ m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f);
+}
+
+void CFX_Break::SetLineBoundary(float fLineStart, float fLineEnd) {
+ if (fLineStart > fLineEnd)
+ return;
+
+ m_iLineStart = FXSYS_round(fLineStart * 20000.0f);
+ m_iLineWidth = FXSYS_round(fLineEnd * 20000.0f);
+ m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iLineWidth);
+ m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iLineStart);
+}
diff --git a/xfa/fgas/layout/cfx_break.h b/xfa/fgas/layout/cfx_break.h
new file mode 100644
index 0000000000..d1bbde0682
--- /dev/null
+++ b/xfa/fgas/layout/cfx_break.h
@@ -0,0 +1,81 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FGAS_LAYOUT_CFX_BREAK_H_
+#define XFA_FGAS_LAYOUT_CFX_BREAK_H_
+
+#include <stdint.h>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
+#include "xfa/fgas/layout/cfx_breakline.h"
+
+struct FX_TPO {
+ bool operator<(const FX_TPO& that) const { return pos < that.pos; }
+
+ int32_t index;
+ int32_t pos;
+};
+
+enum FX_LAYOUTSTYLE {
+ FX_LAYOUTSTYLE_None = 0,
+ FX_LAYOUTSTYLE_Pagination = 0x01,
+ FX_LAYOUTSTYLE_ExpandTab = 0x10,
+ FX_LAYOUTSTYLE_SingleLine = 0x200,
+ FX_LAYOUTSTYLE_CombText = 0x400
+};
+
+class CFX_Break {
+ public:
+ virtual ~CFX_Break();
+
+ void SetLayoutStyles(uint32_t dwLayoutStyles);
+ uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
+
+ void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont);
+ void SetFontSize(float fFontSize);
+ void SetTabWidth(float fTabWidth);
+
+ void SetHorizontalScale(int32_t iScale);
+ void SetVerticalScale(int32_t iScale);
+ void SetLineBreakTolerance(float fTolerance);
+ void SetLineBoundary(float fLineStart, float fLineEnd);
+
+ void SetCharSpace(float fCharSpace);
+ void SetParagraphBreakChar(wchar_t wch);
+ void SetDefaultChar(wchar_t wch);
+
+ virtual void SetBreakStatus() = 0;
+ virtual void ResetArabicContext() {}
+
+ protected:
+ explicit CFX_Break(uint32_t dwLayoutStyles);
+
+ FX_CHARTYPE m_eCharType;
+ bool m_bSingleLine;
+ bool m_bCombText;
+ uint32_t m_dwLayoutStyles;
+ int32_t m_iLineStart;
+ int32_t m_iLineWidth;
+ wchar_t m_wParagraphBreakChar;
+ int32_t m_iFontSize;
+ int32_t m_iTabWidth;
+ int32_t m_iHorizontalScale;
+ int32_t m_iVerticalScale;
+ int32_t m_iTolerance;
+ int32_t m_iCharSpace;
+ int32_t m_iDefChar;
+ wchar_t m_wDefChar;
+ CFX_RetainPtr<CFGAS_GEFont> m_pFont;
+ CFX_BreakLine m_Line[2];
+ CFX_BreakLine* m_pCurLine;
+ int8_t m_iReadyLineIndex;
+
+ private:
+ void FontChanged();
+};
+
+#endif // XFA_FGAS_LAYOUT_CFX_BREAK_H_
diff --git a/xfa/fgas/layout/cfx_breakpiece.cpp b/xfa/fgas/layout/cfx_breakpiece.cpp
index dd8b451790..8cb676b58f 100644
--- a/xfa/fgas/layout/cfx_breakpiece.cpp
+++ b/xfa/fgas/layout/cfx_breakpiece.cpp
@@ -15,7 +15,6 @@ CFX_BreakPiece::CFX_BreakPiece()
m_iBidiLevel(0),
m_iBidiPos(0),
m_iFontSize(0),
- m_iFontHeight(0),
m_iHorizontalScale(100),
m_iVerticalScale(100),
m_dwIdentity(0),
diff --git a/xfa/fgas/layout/cfx_breakpiece.h b/xfa/fgas/layout/cfx_breakpiece.h
index 64622b25c1..87627fef40 100644
--- a/xfa/fgas/layout/cfx_breakpiece.h
+++ b/xfa/fgas/layout/cfx_breakpiece.h
@@ -34,7 +34,6 @@ class CFX_BreakPiece {
int32_t m_iBidiLevel;
int32_t m_iBidiPos;
int32_t m_iFontSize;
- int32_t m_iFontHeight;
int32_t m_iHorizontalScale;
int32_t m_iVerticalScale;
uint32_t m_dwIdentity;
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index 68e8929c9a..f4faf00fca 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -14,91 +14,27 @@
#include "xfa/fgas/layout/fgas_linebreak.h"
CFX_RTFBreak::CFX_RTFBreak(uint32_t dwLayoutStyles)
- : m_iBoundaryStart(0),
- m_iBoundaryEnd(2000000),
- m_dwLayoutStyles(dwLayoutStyles),
+ : CFX_Break(dwLayoutStyles),
m_bPagination(false),
- m_pFont(nullptr),
- m_iFontHeight(240),
- m_iFontSize(240),
- m_iTabWidth(720000),
- m_wDefChar(0xFEFF),
- m_iDefChar(0),
- m_wLineBreakChar(L'\n'),
- m_iHorizontalScale(100),
- m_iVerticalScale(100),
- m_iCharSpace(0),
m_iAlignment(CFX_RTFLineAlignment::Left),
m_pUserData(nullptr),
- m_eCharType(FX_CHARTYPE_Unknown),
- m_dwIdentity(0),
- m_pCurLine(nullptr),
- m_iTolerance(0),
- m_iReadyLineIndex(-1) {
- m_pCurLine = &m_RTFLine[0];
-
+ m_dwIdentity(0) {
SetBreakStatus();
- m_bPagination = !!(m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination);
+ m_bPagination = !!(m_dwLayoutStyles & FX_LAYOUTSTYLE_Pagination);
}
CFX_RTFBreak::~CFX_RTFBreak() {}
-void CFX_RTFBreak::SetLineBoundary(float fLineStart, float fLineEnd) {
- if (fLineStart > fLineEnd)
- return;
-
- m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f);
- m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f);
- m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd);
- m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart);
-}
-
void CFX_RTFBreak::SetLineStartPos(float fLinePos) {
int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f);
- iLinePos = std::min(iLinePos, m_iBoundaryEnd);
- iLinePos = std::max(iLinePos, m_iBoundaryStart);
+ iLinePos = std::min(iLinePos, m_iLineWidth);
+ iLinePos = std::max(iLinePos, m_iLineStart);
m_pCurLine->m_iStart = iLinePos;
}
-void CFX_RTFBreak::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont) {
- if (!pFont || pFont == m_pFont)
- return;
-
- SetBreakStatus();
- m_pFont = pFont;
- FontChanged();
-}
-
-void CFX_RTFBreak::SetFontSize(float fFontSize) {
- int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
- if (m_iFontSize == iFontSize)
- return;
-
- SetBreakStatus();
- m_iFontSize = iFontSize;
- FontChanged();
-}
-
-void CFX_RTFBreak::FontChanged() {
- m_iDefChar = 0;
- if (!m_pFont)
- return;
-
- m_iFontHeight = m_iFontSize;
- if (m_wDefChar == 0xFEFF)
- return;
-
- m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
- m_iDefChar *= m_iFontSize;
-}
-
-void CFX_RTFBreak::SetTabWidth(float fTabWidth) {
- m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f);
-}
-
void CFX_RTFBreak::AddPositionedTab(float fTabPos) {
- int32_t iTabPos = std::min(FXSYS_round(fTabPos * 20000.0f) + m_iBoundaryStart,
- m_iBoundaryEnd);
+ int32_t iTabPos =
+ std::min(FXSYS_round(fTabPos * 20000.0f) + m_iLineStart, m_iLineWidth);
auto it = std::lower_bound(m_PositionedTabs.begin(), m_PositionedTabs.end(),
iTabPos);
if (it != m_PositionedTabs.end() && *it == iTabPos)
@@ -106,34 +42,6 @@ void CFX_RTFBreak::AddPositionedTab(float fTabPos) {
m_PositionedTabs.insert(it, iTabPos);
}
-void CFX_RTFBreak::SetLineBreakTolerance(float fTolerance) {
- m_iTolerance = FXSYS_round(fTolerance * 20000.0f);
-}
-
-void CFX_RTFBreak::SetHorizontalScale(int32_t iScale) {
- if (iScale < 0)
- iScale = 0;
- if (m_iHorizontalScale == iScale)
- return;
-
- SetBreakStatus();
- m_iHorizontalScale = iScale;
-}
-
-void CFX_RTFBreak::SetVerticalScale(int32_t iScale) {
- if (iScale < 0)
- iScale = 0;
- if (m_iVerticalScale == iScale)
- return;
-
- SetBreakStatus();
- m_iVerticalScale = iScale;
-}
-
-void CFX_RTFBreak::SetCharSpace(float fCharSpace) {
- m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f);
-}
-
void CFX_RTFBreak::SetUserData(const CFX_RetainPtr<CFX_Retainable>& pUserData) {
if (m_pUserData == pUserData)
return;
@@ -177,7 +85,7 @@ inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType(
}
int32_t CFX_RTFBreak::GetLastPositionedTab() const {
- return m_PositionedTabs.empty() ? m_iBoundaryStart : m_PositionedTabs.back();
+ return m_PositionedTabs.empty() ? m_iLineStart : m_PositionedTabs.back();
}
bool CFX_RTFBreak::GetPositionedTab(int32_t* iTabPos) const {
@@ -202,7 +110,6 @@ CFX_BreakType CFX_RTFBreak::AppendChar(wchar_t wch) {
pCurChar->m_wCharCode = wch;
pCurChar->m_dwCharProps = dwProps;
pCurChar->m_iFontSize = m_iFontSize;
- pCurChar->m_iFontHeight = m_iFontHeight;
pCurChar->m_iHorizontalScale = m_iHorizontalScale;
pCurChar->m_iVerticalScale = m_iVerticalScale;
pCurChar->m_iCharWidth = 0;
@@ -213,7 +120,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar(wchar_t wch) {
if (chartype != FX_CHARTYPE_Combination &&
GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype) &&
m_eCharType != FX_CHARTYPE_Unknown &&
- m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance &&
+ m_pCurLine->GetLineEnd() > m_iLineWidth + m_iTolerance &&
(m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control)) {
dwRet1 = EndBreak(CFX_BreakType::Line);
int32_t iCount = m_pCurLine->CountChars();
@@ -272,7 +179,7 @@ void CFX_RTFBreak::AppendChar_Combination(CFX_Char* pCurChar) {
}
void CFX_RTFBreak::AppendChar_Tab(CFX_Char* pCurChar) {
- if (!(m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab))
+ if (!(m_dwLayoutStyles & FX_LAYOUTSTYLE_ExpandTab))
return;
int32_t& iLineWidth = m_pCurLine->m_iWidth;
@@ -300,7 +207,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_Char* pCurChar) {
dwRet2 = CFX_BreakType::Paragraph;
break;
default:
- if (pCurChar->m_wCharCode == m_wLineBreakChar)
+ if (pCurChar->m_wCharCode == m_wParagraphBreakChar)
dwRet2 = CFX_BreakType::Paragraph;
break;
}
@@ -350,7 +257,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
m_pCurLine->m_iWidth += iCharWidth;
m_pCurLine->m_iArabicChars++;
- if (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance)
+ if (m_pCurLine->GetLineEnd() > m_iLineWidth + m_iTolerance)
return EndBreak(CFX_BreakType::Line);
return CFX_BreakType::None;
}
@@ -369,7 +276,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Others(CFX_Char* pCurChar) {
pCurChar->m_iCharWidth = iCharWidth;
m_pCurLine->m_iWidth += iCharWidth;
if (chartype != FX_CHARTYPE_Space &&
- m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) {
+ m_pCurLine->GetLineEnd() > m_iLineWidth + m_iTolerance) {
return EndBreak(CFX_BreakType::Line);
}
return CFX_BreakType::None;
@@ -386,10 +293,10 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) {
}
if (HasRTFLine()) {
- if (!m_RTFLine[m_iReadyLineIndex].m_LinePieces.empty()) {
+ if (!m_Line[m_iReadyLineIndex].m_LinePieces.empty()) {
if (dwStatus != CFX_BreakType::Piece)
- m_RTFLine[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
- return m_RTFLine[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
+ m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
+ return m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
}
return CFX_BreakType::None;
}
@@ -403,8 +310,8 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) {
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
- m_iReadyLineIndex = m_pCurLine == &m_RTFLine[0] ? 0 : 1;
- CFX_BreakLine* pNextLine = &m_RTFLine[1 - m_iReadyLineIndex];
+ m_iReadyLineIndex = m_pCurLine == &m_Line[0] ? 0 : 1;
+ CFX_BreakLine* pNextLine = &m_Line[1 - m_iReadyLineIndex];
bool bAllChars = m_iAlignment == CFX_RTFLineAlignment::Justified ||
m_iAlignment == CFX_RTFLineAlignment::Distributed;
@@ -415,7 +322,7 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) {
EndBreak_Alignment(tpos, bAllChars, dwStatus);
}
m_pCurLine = pNextLine;
- m_pCurLine->m_iStart = m_iBoundaryStart;
+ m_pCurLine->m_iStart = m_iLineStart;
CFX_Char* pTC = GetLastChar(0);
m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown;
@@ -426,7 +333,7 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
bool bAllChars,
CFX_BreakType dwStatus) {
bool bDone = false;
- if (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) {
+ if (m_pCurLine->GetLineEnd() > m_iLineWidth + m_iTolerance) {
const CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1);
switch (tc->GetCharType()) {
case FX_CHARTYPE_Tab:
@@ -463,7 +370,6 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
tp.m_iWidth = 0;
tp.m_dwStatus = pTC->m_dwStatus;
tp.m_iFontSize = pTC->m_iFontSize;
- tp.m_iFontHeight = pTC->m_iFontHeight;
tp.m_iHorizontalScale = pTC->m_iHorizontalScale;
tp.m_iVerticalScale = pTC->m_iVerticalScale;
dwIdentity = pTC->m_dwIdentity;
@@ -537,7 +443,6 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
tp.m_iBidiLevel = iBidiLevel;
tp.m_iBidiPos = pTC->m_iBidiOrder;
tp.m_iFontSize = pTC->m_iFontSize;
- tp.m_iFontHeight = pTC->m_iFontHeight;
tp.m_iHorizontalScale = pTC->m_iHorizontalScale;
tp.m_iVerticalScale = pTC->m_iVerticalScale;
dwIdentity = pTC->m_dwIdentity;
@@ -622,7 +527,7 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
break;
}
- int32_t iOffset = m_iBoundaryEnd - iNetWidth;
+ int32_t iOffset = m_iLineWidth - iNetWidth;
if (iGapChars > 0 && (m_iAlignment == CFX_RTFLineAlignment::Distributed ||
(m_iAlignment == CFX_RTFLineAlignment::Justified &&
dwStatus != CFX_BreakType::Paragraph))) {
@@ -674,7 +579,7 @@ int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_Char>& tca,
int32_t iIndirectPos = -1;
int32_t iLast = -1;
int32_t iLastPos = -1;
- if (iEndPos <= m_iBoundaryEnd) {
+ if (iEndPos <= m_iLineWidth) {
if (!bAllChars)
return iLength;
@@ -716,7 +621,7 @@ int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_Char>& tca,
if (!bOnlyBrk) {
iCharWidth = pCur->m_iCharWidth;
- if (iEndPos <= m_iBoundaryEnd || bNeedBreak) {
+ if (iEndPos <= m_iLineWidth || bNeedBreak) {
if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) {
iBreak = iLength;
iBreakPos = iEndPos;
@@ -795,7 +700,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_BreakLine* pCurLine,
int32_t CFX_RTFBreak::CountBreakPieces() const {
return HasRTFLine() ? pdfium::CollectionSize<int32_t>(
- m_RTFLine[m_iReadyLineIndex].m_LinePieces)
+ m_Line[m_iReadyLineIndex].m_LinePieces)
: 0;
}
@@ -804,7 +709,7 @@ const CFX_BreakPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const {
return nullptr;
const std::vector<CFX_BreakPiece>& pRTFPieces =
- m_RTFLine[m_iReadyLineIndex].m_LinePieces;
+ m_Line[m_iReadyLineIndex].m_LinePieces;
if (!pdfium::IndexInBounds(pRTFPieces, index))
return nullptr;
@@ -813,15 +718,15 @@ const CFX_BreakPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const {
void CFX_RTFBreak::ClearBreakPieces() {
if (HasRTFLine())
- m_RTFLine[m_iReadyLineIndex].Clear();
+ m_Line[m_iReadyLineIndex].Clear();
m_iReadyLineIndex = -1;
}
void CFX_RTFBreak::Reset() {
m_eCharType = FX_CHARTYPE_Unknown;
- m_RTFLine[0].Clear();
- m_RTFLine[1].Clear();
+ m_Line[0].Clear();
+ m_Line[1].Clear();
}
int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 978634d1c8..681dc58455 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -12,14 +12,13 @@
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_ucd.h"
-#include "xfa/fgas/layout/fgas_textbreak.h"
+#include "core/fxge/cfx_renderdevice.h"
+#include "xfa/fgas/layout/cfx_break.h"
class CFGAS_GEFont;
-#define FX_RTFLAYOUTSTYLE_Pagination 0x01
-#define FX_RTFLAYOUTSTYLE_ExpandTab 0x10
-
enum class CFX_RTFLineAlignment {
Left = 0,
Center,
@@ -44,20 +43,13 @@ struct FX_RTFTEXTOBJ {
int32_t iVerticalScale;
};
-class CFX_RTFBreak {
+class CFX_RTFBreak : public CFX_Break {
public:
explicit CFX_RTFBreak(uint32_t dwLayoutStyles);
- ~CFX_RTFBreak();
+ ~CFX_RTFBreak() override;
- void SetLineBoundary(float fLineStart, float fLineEnd);
void SetLineStartPos(float fLinePos);
- void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont);
- void SetFontSize(float fFontSize);
- void SetTabWidth(float fTabWidth);
- void SetLineBreakTolerance(float fTolerance);
- void SetHorizontalScale(int32_t iScale);
- void SetVerticalScale(int32_t iScale);
- void SetCharSpace(float fCharSpace);
+
void SetAlignment(CFX_RTFLineAlignment align) { m_iAlignment = align; }
void SetUserData(const CFX_RetainPtr<CFX_Retainable>& pUserData);
@@ -84,8 +76,7 @@ class CFX_RTFBreak {
CFX_BreakType AppendChar_Control(CFX_Char* pCurChar);
CFX_BreakType AppendChar_Arabic(CFX_Char* pCurChar);
CFX_BreakType AppendChar_Others(CFX_Char* pCurChar);
- void FontChanged();
- void SetBreakStatus();
+ void SetBreakStatus() override;
CFX_Char* GetLastChar(int32_t index) const;
bool HasRTFLine() const { return m_iReadyLineIndex >= 0; }
FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE chartype) const;
@@ -107,29 +98,11 @@ class CFX_RTFBreak {
bool bAllChars,
CFX_BreakType dwStatus);
- int32_t m_iBoundaryStart;
- int32_t m_iBoundaryEnd;
- uint32_t m_dwLayoutStyles;
bool m_bPagination;
- CFX_RetainPtr<CFGAS_GEFont> m_pFont;
- int32_t m_iFontHeight;
- int32_t m_iFontSize;
- int32_t m_iTabWidth;
std::vector<int32_t> m_PositionedTabs;
- wchar_t m_wDefChar;
- int32_t m_iDefChar;
- wchar_t m_wLineBreakChar;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- int32_t m_iCharSpace;
CFX_RTFLineAlignment m_iAlignment;
CFX_RetainPtr<CFX_Retainable> m_pUserData;
- FX_CHARTYPE m_eCharType;
uint32_t m_dwIdentity;
- CFX_BreakLine m_RTFLine[2];
- CFX_BreakLine* m_pCurLine;
- int32_t m_iTolerance;
- int8_t m_iReadyLineIndex;
};
#endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_
diff --git a/xfa/fgas/layout/fgas_rtfbreak_unittest.cpp b/xfa/fgas/layout/fgas_rtfbreak_unittest.cpp
index b20afb7103..d84621a595 100644
--- a/xfa/fgas/layout/fgas_rtfbreak_unittest.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak_unittest.cpp
@@ -50,7 +50,7 @@ class RTFBreakTest : public testing::Test {
// and must be consumed before you get any more characters ....
TEST_F(RTFBreakTest, AddChars) {
- auto b = CreateBreak(FX_RTFLAYOUTSTYLE_ExpandTab);
+ auto b = CreateBreak(FX_LAYOUTSTYLE_ExpandTab);
CFX_WideString str(L"Input String.");
for (int32_t i = 0; i < str.GetLength(); i++)
@@ -75,7 +75,7 @@ TEST_F(RTFBreakTest, AddChars) {
}
TEST_F(RTFBreakTest, ControlCharacters) {
- auto b = CreateBreak(FX_RTFLAYOUTSTYLE_ExpandTab);
+ auto b = CreateBreak(FX_LAYOUTSTYLE_ExpandTab);
EXPECT_EQ(CFX_BreakType::Line, b->AppendChar(L'\v'));
EXPECT_EQ(CFX_BreakType::Page, b->AppendChar(L'\f'));
// 0x2029 is the Paragraph Separator unicode character.
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 44545574e5..6e36da1b68 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -34,34 +34,15 @@ bool IsCtrlCode(wchar_t ch) {
return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control;
}
-const int kMinimumTabWidth = 160000;
-
} // namespace
CFX_TxtBreak::CFX_TxtBreak()
- : m_iLineWidth(2000000),
- m_dwLayoutStyles(0),
- m_bSingleLine(false),
- m_bCombText(false),
- m_bEquidistant(true),
+ : CFX_Break(FX_LAYOUTSTYLE_None),
m_iArabicContext(1),
m_iCurArabicContext(1),
- m_pFont(nullptr),
- m_iFontSize(240),
- m_iTabWidth(720000),
- m_wDefChar(0xFEFF),
- m_wParagBreakChar(L'\n'),
- m_iDefChar(0),
m_iAlignment(CFX_TxtLineAlignment_Left),
m_dwContextCharStyles(0),
- m_iCombWidth(360000),
- m_eCharType(FX_CHARTYPE_Unknown),
- m_pCurLine(nullptr),
- m_iTolerance(0),
- m_iHorScale(100),
- m_iCharSpace(0),
- m_iReadyLineIndex(-1) {
- m_pCurLine = &m_TxtLine[0];
+ m_iCombWidth(360000) {
ResetArabicContext();
}
@@ -72,68 +53,6 @@ void CFX_TxtBreak::SetLineWidth(float fLineWidth) {
ASSERT(m_iLineWidth >= 20000);
}
-void CFX_TxtBreak::SetLayoutStyles(uint32_t dwLayoutStyles) {
- m_dwLayoutStyles = dwLayoutStyles;
- m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0;
- m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0;
- ResetArabicContext();
-}
-
-void CFX_TxtBreak::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont) {
- if (!pFont || pFont == m_pFont)
- return;
-
- SetBreakStatus();
- m_pFont = pFont;
- FontChanged();
-}
-
-void CFX_TxtBreak::SetFontSize(float fFontSize) {
- int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
- if (m_iFontSize == iFontSize)
- return;
-
- SetBreakStatus();
- m_iFontSize = iFontSize;
- FontChanged();
-}
-
-void CFX_TxtBreak::FontChanged() {
- m_iDefChar = 0;
- if (m_wDefChar == 0xFEFF || !m_pFont)
- return;
-
- m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
- m_iDefChar *= m_iFontSize;
-}
-
-void CFX_TxtBreak::SetTabWidth(float fTabWidth, bool bEquidistant) {
- m_iTabWidth = std::max(FXSYS_round(fTabWidth * 20000.0f), kMinimumTabWidth);
- m_bEquidistant = bEquidistant;
-}
-
-void CFX_TxtBreak::SetDefaultChar(wchar_t wch) {
- m_wDefChar = wch;
- m_iDefChar = 0;
- if (m_wDefChar == 0xFEFF || !m_pFont)
- return;
-
- m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
- if (m_iDefChar < 0)
- m_iDefChar = 0;
- else
- m_iDefChar *= m_iFontSize;
-}
-
-void CFX_TxtBreak::SetParagraphBreakChar(wchar_t wch) {
- if (wch != L'\r' && wch != L'\n')
- return;
- m_wParagBreakChar = wch;
-}
-
-void CFX_TxtBreak::SetLineBreakTolerance(float fTolerance) {
- m_iTolerance = FXSYS_round(fTolerance * 20000.0f);
-}
void CFX_TxtBreak::SetAlignment(int32_t iAlignment) {
ASSERT(iAlignment >= CFX_TxtLineAlignment_Left &&
@@ -142,11 +61,6 @@ void CFX_TxtBreak::SetAlignment(int32_t iAlignment) {
ResetArabicContext();
}
-void CFX_TxtBreak::ResetContextCharStyles() {
- m_dwContextCharStyles = m_iAlignment;
- m_dwContextCharStyles |= (m_iArabicContext << 8);
-}
-
void CFX_TxtBreak::SetCombWidth(float fCombWidth) {
m_iCombWidth = FXSYS_round(fCombWidth * 20000.0f);
}
@@ -160,21 +74,6 @@ void CFX_TxtBreak::SetBreakStatus() {
if (pTC->m_dwStatus == CFX_BreakType::None)
pTC->m_dwStatus = CFX_BreakType::Piece;
}
-
-void CFX_TxtBreak::SetHorizontalScale(int32_t iScale) {
- if (iScale < 0)
- iScale = 0;
- if (iScale == m_iHorScale)
- return;
-
- SetBreakStatus();
- m_iHorScale = iScale;
-}
-
-void CFX_TxtBreak::SetCharSpace(float fCharSpace) {
- m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f);
-}
-
CFX_Char* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const {
std::vector<CFX_Char>& ca = m_pCurLine->m_LineChars;
int32_t iCount = pdfium::CollectionSize<int32_t>(ca);
@@ -199,7 +98,8 @@ inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType(
void CFX_TxtBreak::ResetArabicContext() {
m_iCurAlignment = m_iAlignment;
- ResetContextCharStyles();
+ m_dwContextCharStyles = m_iAlignment;
+ m_dwContextCharStyles |= (m_iArabicContext << 8);
}
void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps) {
@@ -242,7 +142,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) {
iCharWidth = 0;
iCharWidth *= m_iFontSize;
- iCharWidth = iCharWidth * m_iHorScale / 100;
+ iCharWidth = iCharWidth * m_iHorizontalScale / 100;
}
pCurChar->m_iCharWidth = -iCharWidth;
return CFX_BreakType::None;
@@ -270,7 +170,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) {
dwRet = CFX_BreakType::Paragraph;
break;
default:
- if (wch == m_wParagBreakChar)
+ if (wch == m_wParagraphBreakChar)
dwRet = CFX_BreakType::Paragraph;
break;
}
@@ -305,7 +205,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
iCharWidth = m_iDefChar;
iCharWidth *= m_iFontSize;
- iCharWidth = iCharWidth * m_iHorScale / 100;
+ iCharWidth = iCharWidth * m_iHorizontalScale / 100;
pLastChar->m_iCharWidth = iCharWidth;
iLineWidth += iCharWidth;
iCharWidth = 0;
@@ -324,7 +224,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
iCharWidth = m_iDefChar;
iCharWidth *= m_iFontSize;
- iCharWidth = iCharWidth * m_iHorScale / 100;
+ iCharWidth = iCharWidth * m_iHorizontalScale / 100;
}
pCurChar->m_iCharWidth = iCharWidth;
iLineWidth += iCharWidth;
@@ -349,7 +249,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) {
iCharWidth = m_iDefChar;
iCharWidth *= m_iFontSize;
- iCharWidth = iCharWidth * m_iHorScale / 100;
+ iCharWidth = iCharWidth * m_iHorizontalScale / 100;
}
iCharWidth += m_iCharSpace;
@@ -373,7 +273,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
pCurChar->m_dwCharProps = dwProps;
pCurChar->m_dwCharStyles = 0;
pCurChar->m_iCharWidth = 0;
- pCurChar->m_iHorizontalScale = m_iHorScale;
+ pCurChar->m_iHorizontalScale = m_iHorizontalScale;
pCurChar->m_iVerticalScale = 100;
pCurChar->m_dwStatus = CFX_BreakType::None;
pCurChar->m_iBidiClass = 0;
@@ -617,10 +517,10 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
}
if (HasTxtLine()) {
- if (!m_TxtLine[m_iReadyLineIndex].m_LinePieces.empty()) {
+ if (!m_Line[m_iReadyLineIndex].m_LinePieces.empty()) {
if (dwStatus != CFX_BreakType::Piece)
- m_TxtLine[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
- return m_TxtLine[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
+ m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
+ return m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
}
return CFX_BreakType::None;
}
@@ -633,8 +533,8 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
- m_iReadyLineIndex = m_pCurLine == &m_TxtLine[0] ? 0 : 1;
- CFX_BreakLine* pNextLine = &m_TxtLine[1 - m_iReadyLineIndex];
+ m_iReadyLineIndex = m_pCurLine == &m_Line[0] ? 0 : 1;
+ CFX_BreakLine* pNextLine = &m_Line[1 - m_iReadyLineIndex];
bool bAllChars = m_iCurAlignment > CFX_TxtLineAlignment_Right;
if (!EndBreak_SplitLine(pNextLine, bAllChars)) {
std::deque<FX_TPO> tpos;
@@ -789,7 +689,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine,
int32_t CFX_TxtBreak::CountBreakPieces() const {
return HasTxtLine() ? pdfium::CollectionSize<int32_t>(
- m_TxtLine[m_iReadyLineIndex].m_LinePieces)
+ m_Line[m_iReadyLineIndex].m_LinePieces)
: 0;
}
@@ -797,15 +697,15 @@ const CFX_BreakPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const {
if (!HasTxtLine())
return nullptr;
- if (!pdfium::IndexInBounds(m_TxtLine[m_iReadyLineIndex].m_LinePieces, index))
+ if (!pdfium::IndexInBounds(m_Line[m_iReadyLineIndex].m_LinePieces, index))
return nullptr;
- return &m_TxtLine[m_iReadyLineIndex].m_LinePieces[index];
+ return &m_Line[m_iReadyLineIndex].m_LinePieces[index];
}
void CFX_TxtBreak::ClearBreakPieces() {
if (HasTxtLine())
- m_TxtLine[m_iReadyLineIndex].Clear();
+ m_Line[m_iReadyLineIndex].Clear();
m_iReadyLineIndex = -1;
}
@@ -814,8 +714,8 @@ void CFX_TxtBreak::Reset() {
m_iArabicContext = 1;
m_iCurArabicContext = 1;
ResetArabicContext();
- m_TxtLine[0].Clear();
- m_TxtLine[1].Clear();
+ m_Line[0].Clear();
+ m_Line[1].Clear();
}
struct FX_FORMCHAR {
@@ -1032,7 +932,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) {
pCharPos->m_Origin = CFX_PointF(fX, fY);
- if ((dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0) {
+ if ((dwStyles & FX_LAYOUTSTYLE_CombText) != 0) {
int32_t iFormWidth = iCharWidth;
pFont->GetCharWidth(wForm, iFormWidth, false);
float fOffset = fFontSize * (iCharWidth - iFormWidth) / 2000.0f;
@@ -1115,8 +1015,8 @@ std::vector<CFX_RectF> CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
float fLeft = std::max(0.0f, bbox.left * fScale);
float fHeight = FXSYS_fabs(bbox.height * fScale);
bool bRTLPiece = !!(pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel);
- bool bSingleLine = !!(pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine);
- bool bCombText = !!(pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText);
+ bool bSingleLine = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_SingleLine);
+ bool bCombText = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_CombText);
wchar_t wch;
wchar_t wLineBreakChar = pTxtRun->wLineBreakChar;
int32_t iCharSize;
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index d4aa1418e7..054fe39344 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -15,14 +15,11 @@
#include "core/fxge/cfx_renderdevice.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/cfde_txtedtpage.h"
-#include "xfa/fgas/layout/cfx_breakline.h"
+#include "xfa/fgas/layout/cfx_break.h"
class CFGAS_GEFont;
struct FDE_TEXTEDITPIECE;
-#define FX_TXTLAYOUTSTYLE_SingleLine 0x0200
-#define FX_TXTLAYOUTSTYLE_CombText 0x0400
-
#define FX_TXTCHARSTYLE_ArabicShadda 0x0020
#define FX_TXTCHARSTYLE_OddBidiLevel 0x0040
@@ -33,13 +30,6 @@ enum CFX_TxtLineAlignment {
CFX_TxtLineAlignment_Justified = 1 << 2
};
-struct FX_TPO {
- int32_t index;
- int32_t pos;
-
- bool operator<(const FX_TPO& that) const { return pos < that.pos; }
-};
-
inline bool CFX_BreakTypeNoneOrPiece(CFX_BreakType type) {
return type == CFX_BreakType::None || type == CFX_BreakType::Piece;
}
@@ -65,22 +55,12 @@ struct FX_TXTRUN {
bool bSkipSpace;
};
-class CFX_TxtBreak {
+class CFX_TxtBreak : public CFX_Break {
public:
CFX_TxtBreak();
- ~CFX_TxtBreak();
+ ~CFX_TxtBreak() override;
void SetLineWidth(float fLineWidth);
- uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
- void SetLayoutStyles(uint32_t dwLayoutStyles);
- void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont);
- void SetFontSize(float fFontSize);
- void SetTabWidth(float fTabWidth, bool bEquidistant);
- void SetDefaultChar(wchar_t wch);
- void SetParagraphBreakChar(wchar_t wch);
- void SetLineBreakTolerance(float fTolerance);
- void SetHorizontalScale(int32_t iScale);
- void SetCharSpace(float fCharSpace);
void SetAlignment(int32_t iAlignment);
void SetCombWidth(float fCombWidth);
CFX_BreakType EndBreak(CFX_BreakType dwStatus);
@@ -103,12 +83,11 @@ class CFX_TxtBreak {
CFX_BreakType AppendChar_Others(CFX_Char* pCurChar);
private:
- void FontChanged();
- void SetBreakStatus();
+ void SetBreakStatus() override;
CFX_Char* GetLastChar(int32_t index, bool bOmitChar = true) const;
bool HasTxtLine() const { return m_iReadyLineIndex >= 0; }
FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const;
- void ResetArabicContext();
+ void ResetArabicContext() override;
void ResetContextCharStyles();
bool EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars);
void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus);
@@ -123,30 +102,12 @@ class CFX_TxtBreak {
CFX_BreakLine* pNextLine,
bool bAllChars = false);
- int32_t m_iLineWidth;
- uint32_t m_dwLayoutStyles;
- bool m_bSingleLine;
- bool m_bCombText;
- bool m_bEquidistant;
int32_t m_iArabicContext;
int32_t m_iCurArabicContext;
- CFX_RetainPtr<CFGAS_GEFont> m_pFont;
- int32_t m_iFontSize;
- int32_t m_iTabWidth;
- wchar_t m_wDefChar;
- wchar_t m_wParagBreakChar;
- int32_t m_iDefChar;
int32_t m_iAlignment;
uint32_t m_dwContextCharStyles;
int32_t m_iCombWidth;
- FX_CHARTYPE m_eCharType;
int32_t m_iCurAlignment;
- CFX_BreakLine m_TxtLine[2];
- CFX_BreakLine* m_pCurLine;
- int32_t m_iTolerance;
- int32_t m_iHorScale;
- int32_t m_iCharSpace;
- int8_t m_iReadyLineIndex;
};
#endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 4ddc3a624b..a17d5fec3d 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -685,7 +685,6 @@ void CFWL_Edit::UpdateEditParams() {
if (params.nLineCount <= 0)
params.nLineCount = 1;
params.fTabWidth = params.fFontSize * 1;
- params.bTabEquidistant = true;
params.wLineBreakChar = L'\n';
params.pEventSink = this;
m_EdtEngine.SetEditParams(params);
diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp
index f25f6cceee..532fd67f42 100644
--- a/xfa/fxfa/app/cxfa_textlayout.cpp
+++ b/xfa/fxfa/app/cxfa_textlayout.cpp
@@ -90,9 +90,9 @@ CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() {
}
std::unique_ptr<CFX_RTFBreak> CXFA_TextLayout::CreateBreak(bool bDefault) {
- uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab;
+ uint32_t dwStyle = FX_LAYOUTSTYLE_ExpandTab;
if (!bDefault)
- dwStyle |= FX_RTFLAYOUTSTYLE_Pagination;
+ dwStyle |= FX_LAYOUTSTYLE_Pagination;
auto pBreak = pdfium::MakeUnique<CFX_RTFBreak>(dwStyle);
pBreak->SetLineBreakTolerance(1);