From 068d34426272bd7f02ffc12139ddd33ee2e237e6 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 13 Mar 2017 10:15:36 -0400 Subject: Remove TextBreak rotation code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rotation value is always 0 so we end up doing nothing for the rotation. Change-Id: Ib12a269d4f3c16961b1b934bf9dfc04d1c368e51 Reviewed-on: https://pdfium-review.googlesource.com/2943 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez --- core/fxcrt/fx_ucd.h | 4 +- xfa/fde/cfde_txtedtengine.cpp | 2 - xfa/fde/cfde_txtedttextset.cpp | 2 - xfa/fde/ifde_txtedtengine.h | 1 - xfa/fgas/layout/fgas_textbreak.cpp | 146 +++++++++---------------------------- xfa/fgas/layout/fgas_textbreak.h | 17 ++--- xfa/fwl/cfwl_edit.cpp | 1 - 7 files changed, 42 insertions(+), 131 deletions(-) diff --git a/core/fxcrt/fx_ucd.h b/core/fxcrt/fx_ucd.h index ebcf6bbf2b..f8a92a18f2 100644 --- a/core/fxcrt/fx_ucd.h +++ b/core/fxcrt/fx_ucd.h @@ -154,14 +154,12 @@ class CFX_Char { class CFX_TxtChar : public CFX_Char { public: CFX_TxtChar() - : m_nRotation(0), - m_dwCharStyles(0), + : m_dwCharStyles(0), m_iBidiClass(0), m_iBidiLevel(0), m_iBidiPos(0), m_iBidiOrder(0) {} - int8_t m_nRotation; uint32_t m_dwCharStyles; int16_t m_iBidiClass; int16_t m_iBidiLevel; diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 8fd521a66b..a22ed7064f 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -40,7 +40,6 @@ FDE_TXTEDTPARAMS::FDE_TXTEDTPARAMS() bTabEquidistant(false), wDefChar(0xFEFF), wLineBreakChar('\n'), - nCharRotation(0), nLineEnd(0), nHorzScale(100), fCharSpace(0), @@ -1041,7 +1040,6 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() { m_pTextBreak->SetTabWidth(m_Param.fTabWidth, m_Param.bTabEquidistant); m_pTextBreak->SetDefaultChar(m_Param.wDefChar); m_pTextBreak->SetParagraphBreakChar(m_Param.wLineBreakChar); - m_pTextBreak->SetCharRotation(m_Param.nCharRotation); m_pTextBreak->SetLineBreakTolerance(m_Param.fFontSize * 0.2f); m_pTextBreak->SetHorizontalScale(m_Param.nHorzScale); m_pTextBreak->SetCharSpace(m_Param.fCharSpace); diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp index 8d32f75ff3..e13663457d 100644 --- a/xfa/fde/cfde_txtedttextset.cpp +++ b/xfa/fde/cfde_txtedttextset.cpp @@ -65,7 +65,6 @@ int32_t CFDE_TxtEdtTextSet::GetDisplayPos(const FDE_TEXTEDITPIECE& piece, tr.pFont = pTextParams->pFont; tr.fFontSize = pTextParams->fFontSize; tr.dwStyles = dwLayoutStyle; - tr.iCharRotation = pTextParams->nCharRotation; tr.dwCharStyles = piece.dwCharStyles; tr.pRect = &piece.rtPiece; tr.wLineBreakChar = pTextParams->wLineBreakChar; @@ -88,7 +87,6 @@ std::vector CFDE_TxtEdtTextSet::GetCharRects( tr.pFont = pTextParams->pFont; tr.fFontSize = pTextParams->fFontSize; tr.dwStyles = dwLayoutStyle; - tr.iCharRotation = pTextParams->nCharRotation; tr.dwCharStyles = pPiece->dwCharStyles; tr.pRect = &pPiece->rtPiece; tr.wLineBreakChar = pTextParams->wLineBreakChar; diff --git a/xfa/fde/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h index 6940a8c7d6..d511949c4b 100644 --- a/xfa/fde/ifde_txtedtengine.h +++ b/xfa/fde/ifde_txtedtengine.h @@ -88,7 +88,6 @@ struct FDE_TXTEDTPARAMS { bool bTabEquidistant; FX_WCHAR wDefChar; FX_WCHAR wLineBreakChar; - int32_t nCharRotation; int32_t nLineEnd; int32_t nHorzScale; FX_FLOAT fCharSpace; diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 845bc10c20..6442f1fb55 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -17,8 +17,7 @@ namespace { typedef CFX_BreakType (CFX_TxtBreak::*FX_TxtBreak_LPFAppendChar)( - CFX_TxtChar* pCurChar, - int32_t iRotation); + CFX_TxtChar* pCurChar); const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = { &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Tab, &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Control, @@ -53,9 +52,6 @@ CFX_TxtBreak::CFX_TxtBreak() m_wDefChar(0xFEFF), m_wParagBreakChar(L'\n'), m_iDefChar(0), - m_iLineRotation(0), - m_iCharRotation(0), - m_iRotation(0), m_iAlignment(CFX_TxtLineAlignment_Left), m_dwContextCharStyles(0), m_iCombWidth(360000), @@ -83,9 +79,6 @@ void CFX_TxtBreak::SetLayoutStyles(uint32_t dwLayoutStyles) { m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; ResetArabicContext(); - m_iLineRotation = GetLineRotation(m_dwLayoutStyles); - m_iRotation = m_iLineRotation + m_iCharRotation; - m_iRotation %= 4; } void CFX_TxtBreak::SetFont(const CFX_RetainPtr& pFont) { @@ -144,21 +137,6 @@ void CFX_TxtBreak::SetLineBreakTolerance(FX_FLOAT fTolerance) { m_iTolerance = FXSYS_round(fTolerance * 20000.0f); } -void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) { - if (iCharRotation < 0) - iCharRotation += (-iCharRotation / 4 + 1) * 4; - else if (iCharRotation > 3) - iCharRotation -= (iCharRotation / 4) * 4; - - if (m_iCharRotation == iCharRotation) - return; - - SetBreakStatus(); - m_iCharRotation = iCharRotation; - m_iRotation = m_iLineRotation + m_iCharRotation; - m_iRotation %= 4; -} - void CFX_TxtBreak::SetAlignment(int32_t iAlignment) { ASSERT(iAlignment >= CFX_TxtLineAlignment_Left && iAlignment <= CFX_TxtLineAlignment_Justified); @@ -199,12 +177,6 @@ void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) { m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); } -static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; - -int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { - return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; -} - CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const { std::vector& ca = m_pCurLine->m_LineChars; int32_t iCount = pdfium::CollectionSize(ca); @@ -251,8 +223,7 @@ void CFX_TxtBreak::AppendChar_PageLoad(CFX_TxtChar* pCurChar, pCurChar->m_dwCharStyles = m_dwContextCharStyles; } -CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, - int32_t iRotation) { +CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) { FX_WCHAR wch = pCurChar->m_wCharCode; FX_WCHAR wForm; int32_t iCharWidth = 0; @@ -260,35 +231,32 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, if (m_bCombText) { iCharWidth = m_iCombWidth; } else { - if (FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else { - wForm = wch; - CFX_TxtChar* pLastChar = GetLastChar(0, false); - if (pLastChar && - (pLastChar->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicShadda) == 0) { - bool bShadda = false; - if (wch == 0x0651) { - FX_WCHAR wLast = pLastChar->m_wCharCode; - if (wLast >= 0x064C && wLast <= 0x0650) { - wForm = FX_GetArabicFromShaddaTable(wLast); - bShadda = true; - } - } else if (wch >= 0x064C && wch <= 0x0650) { - if (pLastChar->m_wCharCode == 0x0651) { - wForm = FX_GetArabicFromShaddaTable(wch); - bShadda = true; - } + wForm = wch; + CFX_TxtChar* pLastChar = GetLastChar(0, false); + if (pLastChar && + (pLastChar->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicShadda) == 0) { + bool bShadda = false; + if (wch == 0x0651) { + FX_WCHAR wLast = pLastChar->m_wCharCode; + if (wLast >= 0x064C && wLast <= 0x0650) { + wForm = FX_GetArabicFromShaddaTable(wLast); + bShadda = true; } - if (bShadda) { - pLastChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicShadda; - pLastChar->m_iCharWidth = 0; - pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicShadda; + } else if (wch >= 0x064C && wch <= 0x0650) { + if (pLastChar->m_wCharCode == 0x0651) { + wForm = FX_GetArabicFromShaddaTable(wch); + bShadda = true; } } - if (!m_pFont->GetCharWidth(wForm, iCharWidth, false)) - iCharWidth = 0; + if (bShadda) { + pLastChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicShadda; + pLastChar->m_iCharWidth = 0; + pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicShadda; + } } + if (!m_pFont->GetCharWidth(wForm, iCharWidth, false)) + iCharWidth = 0; + iCharWidth *= m_iFontSize; iCharWidth = iCharWidth * m_iHorScale / 100; } @@ -296,14 +264,12 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, return CFX_BreakType::None; } -CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_TxtChar* pCurChar, - int32_t iRotation) { +CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_TxtChar* pCurChar) { m_eCharType = FX_CHARTYPE_Tab; return CFX_BreakType::None; } -CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar, - int32_t iRotation) { +CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar) { m_eCharType = FX_CHARTYPE_Control; CFX_BreakType dwRet = CFX_BreakType::None; if (!m_bSingleLine) { @@ -330,8 +296,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar, return dwRet; } -CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, - int32_t iRotation) { +CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); int32_t& iLineWidth = m_pCurLine->m_iWidth; FX_WCHAR wForm; @@ -350,11 +315,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); bAlef = (wForm == 0xFEFF && pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); - int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; - if (FX_IsOdd(iLastRotation)) - iCharWidth = 1000; - else - m_pFont->GetCharWidth(wForm, iCharWidth, false); + m_pFont->GetCharWidth(wForm, iCharWidth, false); if (wForm == 0xFEFF) iCharWidth = m_iDefChar; @@ -373,10 +334,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, if (m_bCombText) { iCharWidth = m_iCombWidth; } else { - if (FX_IsOdd(iRotation)) - iCharWidth = 1000; - else - m_pFont->GetCharWidth(wForm, iCharWidth, false); + m_pFont->GetCharWidth(wForm, iCharWidth, false); if (wForm == 0xFEFF) iCharWidth = m_iDefChar; @@ -392,8 +350,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, return CFX_BreakType::None; } -CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar, - int32_t iRotation) { +CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); int32_t& iLineWidth = m_pCurLine->m_iWidth; int32_t iCharWidth = 0; @@ -404,9 +361,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar, if (m_bCombText) { iCharWidth = m_iCombWidth; } else { - if (FX_IsOdd(iRotation)) - iCharWidth = 1000; - else if (!m_pFont->GetCharWidth(wForm, iCharWidth, false)) + if (!m_pFont->GetCharWidth(wForm, iCharWidth, false)) iCharWidth = m_iDefChar; iCharWidth *= m_iFontSize; @@ -431,7 +386,6 @@ CFX_BreakType CFX_TxtBreak::AppendChar(FX_WCHAR wch) { CFX_TxtChar* pCurChar = &m_pCurLine->m_LineChars.back(); pCurChar->m_wCharCode = static_cast(wch); - pCurChar->m_nRotation = m_iCharRotation; pCurChar->m_dwCharProps = dwProps; pCurChar->m_dwCharStyles = 0; pCurChar->m_iCharWidth = 0; @@ -456,10 +410,9 @@ CFX_BreakType CFX_TxtBreak::AppendChar(FX_WCHAR wch) { pCurChar = &m_pCurLine->m_LineChars[iCount - 1]; } - int32_t iRotation = m_iRotation; CFX_BreakType dwRet2 = (this->*g_FX_TxtBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( - pCurChar, iRotation); + pCurChar); return std::max(dwRet1, dwRet2); } @@ -937,8 +890,6 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, int32_t iMaxHeight = iAscent - iDescent; FX_FLOAT fFontHeight = fFontSize; FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; - FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; - int32_t iRotation = GetLineRotation(dwStyles) + pTxtRun->iCharRotation; FX_FLOAT fX = rtText.left; FX_FLOAT fY; FX_FLOAT fCharWidth; @@ -1063,8 +1014,6 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, bLam = false; dwProps = FX_GetUnicodeProperties(wForm); - int32_t iCharRotation = iRotation; - iCharRotation %= 4; bool bEmptyChar = (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); if (wForm == 0xFEFF) @@ -1159,32 +1108,10 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { pCharPos->m_bGlyphAdjust = true; - if (iCharRotation == 0) { - pCharPos->m_AdjustMatrix[0] = -1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = 1; - } else if (iCharRotation == 1) { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = -1; - pCharPos->m_AdjustMatrix[2] = -1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_Origin.x -= fDescent; - pCharPos->m_Origin.y -= fAscent + fDescent; - } else if (iCharRotation == 2) { - pCharPos->m_AdjustMatrix[0] = 1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_Origin.x += fCharWidth; - pCharPos->m_Origin.y -= fAscent; - } else { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = 1; - pCharPos->m_AdjustMatrix[2] = 1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_Origin.x += fAscent; - } + pCharPos->m_AdjustMatrix[0] = -1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = 1; if (iHorScale != 100 || iVerScale != 100) { pCharPos->m_AdjustMatrix[0] = @@ -1301,7 +1228,6 @@ FX_TXTRUN::FX_TXTRUN() dwStyles(0), iHorizontalScale(100), iVerticalScale(100), - iCharRotation(0), dwCharStyles(0), pRect(nullptr), wLineBreakChar(L'\n'), diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index 85831a1ea5..0bc5768d78 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -71,7 +71,6 @@ struct FX_TXTRUN { uint32_t dwStyles; int32_t iHorizontalScale; int32_t iVerticalScale; - int32_t iCharRotation; uint32_t dwCharStyles; const CFX_RectF* pRect; FX_WCHAR wLineBreakChar; @@ -186,7 +185,6 @@ class CFX_TxtBreak { void SetParagraphBreakChar(FX_WCHAR wch); void SetLineBreakTolerance(FX_FLOAT fTolerance); void SetHorizontalScale(int32_t iScale); - void SetCharRotation(int32_t iCharRotation); void SetCharSpace(FX_FLOAT fCharSpace); void SetAlignment(int32_t iAlignment); void SetCombWidth(FX_FLOAT fCombWidth); @@ -203,17 +201,15 @@ class CFX_TxtBreak { bool bCharBBox = false) const; void AppendChar_PageLoad(CFX_TxtChar* pCurChar, uint32_t dwProps); CFX_BreakType AppendChar(FX_WCHAR wch); - CFX_BreakType AppendChar_Combination(CFX_TxtChar* pCurChar, - int32_t iRotation); - CFX_BreakType AppendChar_Tab(CFX_TxtChar* pCurChar, int32_t iRotation); - CFX_BreakType AppendChar_Control(CFX_TxtChar* pCurChar, int32_t iRotation); - CFX_BreakType AppendChar_Arabic(CFX_TxtChar* pCurChar, int32_t iRotation); - CFX_BreakType AppendChar_Others(CFX_TxtChar* pCurChar, int32_t iRotation); + CFX_BreakType AppendChar_Combination(CFX_TxtChar* pCurChar); + CFX_BreakType AppendChar_Tab(CFX_TxtChar* pCurChar); + CFX_BreakType AppendChar_Control(CFX_TxtChar* pCurChar); + CFX_BreakType AppendChar_Arabic(CFX_TxtChar* pCurChar); + CFX_BreakType AppendChar_Others(CFX_TxtChar* pCurChar); private: void FontChanged(); void SetBreakStatus(); - int32_t GetLineRotation(uint32_t dwStyles) const; CFX_TxtChar* GetLastChar(int32_t index, bool bOmitChar = true) const; const CFX_TxtLine* GetTxtLine() const; const CFX_TxtPieceArray* GetTxtPieces() const; @@ -246,9 +242,6 @@ class CFX_TxtBreak { FX_WCHAR m_wDefChar; FX_WCHAR m_wParagBreakChar; int32_t m_iDefChar; - int32_t m_iLineRotation; - int32_t m_iCharRotation; - int32_t m_iRotation; int32_t m_iAlignment; uint32_t m_dwContextCharStyles; int32_t m_iCombWidth; diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index d36e28ab56..62dc7e7e5b 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -687,7 +687,6 @@ void CFWL_Edit::UpdateEditParams() { params.fTabWidth = params.fFontSize * 1; params.bTabEquidistant = true; params.wLineBreakChar = L'\n'; - params.nCharRotation = 0; params.pEventSink = this; m_EdtEngine.SetEditParams(params); } -- cgit v1.2.3