summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp36
-rw-r--r--xfa/fde/tto/fde_textout.cpp6
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp30
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h27
4 files changed, 43 insertions, 56 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index fbc5e159ed..9d9fed5ab1 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -1001,20 +1001,19 @@ void CFDE_TxtEdtEngine::UpdatePages() {
void CFDE_TxtEdtEngine::UpdateTxtBreak() {
uint32_t dwStyle = m_pTextBreak->GetLayoutStyles();
- if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines) {
+ if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)
dwStyle &= ~FX_TXTLAYOUTSTYLE_SingleLine;
- } else {
+ else
dwStyle |= FX_TXTLAYOUTSTYLE_SingleLine;
- }
+
dwStyle &= ~FX_TXTLAYOUTSTYLE_VerticalLayout;
dwStyle &= ~FX_TXTLAYOUTSTYLE_ReverseLine;
dwStyle &= ~FX_TXTLAYOUTSTYLE_RTLReadingOrder;
- if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) {
+ if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText)
dwStyle |= FX_TXTLAYOUTSTYLE_CombText;
- } else {
+ else
dwStyle &= ~FX_TXTLAYOUTSTYLE_CombText;
- }
dwStyle &= ~FX_TXTLAYOUTSTYLE_VerticalChars;
dwStyle &= ~FX_TXTLAYOUTSTYLE_ExpandTab;
@@ -1023,28 +1022,27 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() {
m_pTextBreak->SetLayoutStyles(dwStyle);
uint32_t dwAligment = 0;
- if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Justified) {
- dwAligment |= FX_TXTLINEALIGNMENT_Justified;
- }
- if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Center) {
- dwAligment |= FX_TXTLINEALIGNMENT_Center;
- } else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Right) {
- dwAligment |= FX_TXTLINEALIGNMENT_Right;
- }
+ if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Justified)
+ dwAligment |= CFX_TxtLineAlignment_Justified;
+
+ if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Center)
+ dwAligment |= CFX_TxtLineAlignment_Center;
+ else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Right)
+ dwAligment |= CFX_TxtLineAlignment_Right;
+
m_pTextBreak->SetAlignment(dwAligment);
- if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) {
+ if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap)
m_pTextBreak->SetLineWidth(m_Param.fPlateWidth);
- } else {
+ else
m_pTextBreak->SetLineWidth(kPageWidthMax);
- }
m_nPageLineCount = m_Param.nLineCount;
if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) {
FX_FLOAT fCombWidth = m_Param.fPlateWidth;
- if (m_nLimit > 0) {
+ if (m_nLimit > 0)
fCombWidth /= m_nLimit;
- }
+
m_pTextBreak->SetCombWidth(fCombWidth);
}
m_pTextBreak->SetFont(m_Param.pFont);
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index 93be50d34a..0a92bd53d7 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -107,15 +107,15 @@ void CFDE_TextOut::SetAlignment(int32_t iAlignment) {
case FDE_TTOALIGNMENT_TopCenter:
case FDE_TTOALIGNMENT_Center:
case FDE_TTOALIGNMENT_BottomCenter:
- m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Center;
+ m_iTxtBkAlignment = CFX_TxtLineAlignment_Center;
break;
case FDE_TTOALIGNMENT_TopRight:
case FDE_TTOALIGNMENT_CenterRight:
case FDE_TTOALIGNMENT_BottomRight:
- m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Right;
+ m_iTxtBkAlignment = CFX_TxtLineAlignment_Right;
break;
default:
- m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Left;
+ m_iTxtBkAlignment = CFX_TxtLineAlignment_Left;
break;
}
m_pTxtBreak->SetAlignment(m_iTxtBkAlignment);
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 4989a26e23..44fa682c24 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -60,7 +60,7 @@ CFX_TxtBreak::CFX_TxtBreak()
m_iLineRotation(0),
m_iCharRotation(0),
m_iRotation(0),
- m_iAlignment(FX_TXTLINEALIGNMENT_Left),
+ m_iAlignment(CFX_TxtLineAlignment_Left),
m_dwContextCharStyles(0),
m_iCombWidth(360000),
m_eCharType(FX_CHARTYPE_Unknown),
@@ -170,8 +170,8 @@ void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) {
}
void CFX_TxtBreak::SetAlignment(int32_t iAlignment) {
- ASSERT(iAlignment >= FX_TXTLINEALIGNMENT_Left &&
- iAlignment <= FX_TXTLINEALIGNMENT_Distributed);
+ ASSERT(iAlignment >= CFX_TxtLineAlignment_Left &&
+ iAlignment <= CFX_TxtLineAlignment_Justified);
m_iAlignment = iAlignment;
ResetArabicContext();
}
@@ -259,9 +259,9 @@ inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType(
void CFX_TxtBreak::ResetArabicContext() {
if (m_bArabicContext) {
m_bCurRTL = m_iCurArabicContext > 1;
- m_iCurAlignment = m_iCurArabicContext > 1 ? FX_TXTLINEALIGNMENT_Right
- : FX_TXTLINEALIGNMENT_Left;
- m_iCurAlignment |= (m_iAlignment & FX_TXTLINEALIGNMENT_HigherMask);
+ m_iCurAlignment = m_iCurArabicContext > 1 ? CFX_TxtLineAlignment_Right
+ : CFX_TxtLineAlignment_Left;
+ m_iCurAlignment |= (m_iAlignment & CFX_TxtLineAlignment_Justified);
m_bArabicNumber = m_iArabicContext >= 1 && m_bArabicShapes;
} else {
m_bCurRTL = m_bRTL;
@@ -791,11 +791,8 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
}
int32_t iOffset = m_iLineWidth - iNetWidth;
- int32_t iLowerAlignment = (m_iCurAlignment & FX_TXTLINEALIGNMENT_LowerMask);
- int32_t iHigherAlignment = (m_iCurAlignment & FX_TXTLINEALIGNMENT_HigherMask);
- if (iGapChars > 0 && (iHigherAlignment == FX_TXTLINEALIGNMENT_Distributed ||
- (iHigherAlignment == FX_TXTLINEALIGNMENT_Justified &&
- dwStatus != CFX_BreakType::Paragraph))) {
+ if (iGapChars > 0 && m_iCurAlignment & CFX_TxtLineAlignment_Justified &&
+ dwStatus != CFX_BreakType::Paragraph) {
int32_t iStart = -1;
for (i = 0; i < iCount; i++) {
tpo = tpos[i];
@@ -820,9 +817,12 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
}
iStart += ttp.m_iWidth;
}
- } else if (iLowerAlignment > FX_TXTLINEALIGNMENT_Left) {
- if (iLowerAlignment == FX_TXTLINEALIGNMENT_Center)
+ } else if (m_iCurAlignment & CFX_TxtLineAlignment_Center ||
+ m_iCurAlignment & CFX_TxtLineAlignment_Right) {
+ if (m_iCurAlignment & CFX_TxtLineAlignment_Center &&
+ !(m_iCurAlignment & CFX_TxtLineAlignment_Right)) {
iOffset /= 2;
+ }
if (iOffset > 0) {
for (i = 0; i < iCount; i++) {
CFX_TxtPiece& ttp = pCurPieces->GetAt(i);
@@ -872,14 +872,14 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
m_iReady = m_pCurLine == &m_TxtLine1 ? 1 : 2;
CFX_TxtLine* pNextLine =
m_pCurLine == &m_TxtLine1 ? &m_TxtLine2 : &m_TxtLine1;
- bool bAllChars = (m_iCurAlignment > FX_TXTLINEALIGNMENT_Right);
+ bool bAllChars = m_iCurAlignment > CFX_TxtLineAlignment_Right;
if (m_bArabicShapes)
EndBreak_UpdateArabicShapes();
if (!EndBreak_SplitLine(pNextLine, bAllChars)) {
std::deque<FX_TPO> tpos;
EndBreak_BidiLine(&tpos, dwStatus);
- if (m_iCurAlignment > FX_TXTLINEALIGNMENT_Left)
+ if (m_iCurAlignment > CFX_TxtLineAlignment_Left)
EndBreak_Alignment(tpos, bAllChars, dwStatus);
}
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index e9c37ee5d9..36085bbe4e 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -33,6 +33,7 @@ struct FDE_TEXTEDITPIECE;
#define FX_TXTLAYOUTSTYLE_ExpandTab 0x0100
#define FX_TXTLAYOUTSTYLE_SingleLine 0x0200
#define FX_TXTLAYOUTSTYLE_CombText 0x0400
+
#define FX_TXTCHARSTYLE_Alignment 0x000F
#define FX_TXTCHARSTYLE_ArabicNumber 0x0010
#define FX_TXTCHARSTYLE_ArabicShadda 0x0020
@@ -41,25 +42,13 @@ struct FDE_TEXTEDITPIECE;
#define FX_TXTCHARSTYLE_ArabicContext 0x0300
#define FX_TXTCHARSTYLE_ArabicIndic 0x0400
#define FX_TXTCHARSTYLE_ArabicComma 0x0800
-#define FX_TXTLINEALIGNMENT_Left 0
-#define FX_TXTLINEALIGNMENT_Center 1
-#define FX_TXTLINEALIGNMENT_Right 2
-#define FX_TXTLINEALIGNMENT_Justified (1 << 2)
-#define FX_TXTLINEALIGNMENT_Distributed (2 << 2)
-#define FX_TXTLINEALIGNMENT_JustifiedLeft \
- (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Justified)
-#define FX_TXTLINEALIGNMENT_JustifiedCenter \
- (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Justified)
-#define FX_TXTLINEALIGNMENT_JustifiedRight \
- (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Justified)
-#define FX_TXTLINEALIGNMENT_DistributedLeft \
- (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Distributed)
-#define FX_TXTLINEALIGNMENT_DistributedCenter \
- (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Distributed)
-#define FX_TXTLINEALIGNMENT_DistributedRight \
- (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Distributed)
-#define FX_TXTLINEALIGNMENT_LowerMask 0x03
-#define FX_TXTLINEALIGNMENT_HigherMask 0x0C
+
+enum CFX_TxtLineAlignment {
+ CFX_TxtLineAlignment_Left = 0,
+ CFX_TxtLineAlignment_Center = 1 << 0,
+ CFX_TxtLineAlignment_Right = 1 << 1,
+ CFX_TxtLineAlignment_Justified = 1 << 2
+};
struct FX_TPO {
int32_t index;