summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp30
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h27
2 files changed, 23 insertions, 34 deletions
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;