| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/fxedit/include/fxet_edit.h" | 7 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 } | 834 } |
| 835 | 835 |
| 836 CFX_ByteTextBuf sAppStream; | 836 CFX_ByteTextBuf sAppStream; |
| 837 if (sEditStream.GetSize() > 0) { | 837 if (sEditStream.GetSize() > 0) { |
| 838 int32_t nHorzScale = pEdit->GetHorzScale(); | 838 int32_t nHorzScale = pEdit->GetHorzScale(); |
| 839 if (nHorzScale != 100) { | 839 if (nHorzScale != 100) { |
| 840 sAppStream << nHorzScale << " Tz\n"; | 840 sAppStream << nHorzScale << " Tz\n"; |
| 841 } | 841 } |
| 842 | 842 |
| 843 FX_FLOAT fCharSpace = pEdit->GetCharSpace(); | 843 FX_FLOAT fCharSpace = pEdit->GetCharSpace(); |
| 844 if (!FX_EDIT_IsFloatZero(fCharSpace)) { | 844 if (!IsFloatZero(fCharSpace)) { |
| 845 sAppStream << fCharSpace << " Tc\n"; | 845 sAppStream << fCharSpace << " Tc\n"; |
| 846 } | 846 } |
| 847 | 847 |
| 848 sAppStream << sEditStream; | 848 sAppStream << sEditStream; |
| 849 } | 849 } |
| 850 | 850 |
| 851 return sAppStream.MakeString(); | 851 return sAppStream.MakeString(); |
| 852 } | 852 } |
| 853 | 853 |
| 854 // static | 854 // static |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 m_bNotifyFlag = FALSE; | 1902 m_bNotifyFlag = FALSE; |
| 1903 } | 1903 } |
| 1904 } | 1904 } |
| 1905 } | 1905 } |
| 1906 | 1906 |
| 1907 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { | 1907 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { |
| 1908 if (!m_bEnableScroll) | 1908 if (!m_bEnableScroll) |
| 1909 return; | 1909 return; |
| 1910 | 1910 |
| 1911 if (m_pVT->IsValid()) { | 1911 if (m_pVT->IsValid()) { |
| 1912 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { | 1912 if (!IsFloatEqual(m_ptScrollPos.x, fx)) { |
| 1913 m_ptScrollPos.x = fx; | 1913 m_ptScrollPos.x = fx; |
| 1914 Refresh(); | 1914 Refresh(); |
| 1915 } | 1915 } |
| 1916 } | 1916 } |
| 1917 } | 1917 } |
| 1918 | 1918 |
| 1919 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { | 1919 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { |
| 1920 if (!m_bEnableScroll) | 1920 if (!m_bEnableScroll) |
| 1921 return; | 1921 return; |
| 1922 | 1922 |
| 1923 if (m_pVT->IsValid()) { | 1923 if (m_pVT->IsValid()) { |
| 1924 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { | 1924 if (!IsFloatEqual(m_ptScrollPos.y, fy)) { |
| 1925 m_ptScrollPos.y = fy; | 1925 m_ptScrollPos.y = fy; |
| 1926 Refresh(); | 1926 Refresh(); |
| 1927 | 1927 |
| 1928 if (m_pNotify) { | 1928 if (m_pNotify) { |
| 1929 if (!m_bNotifyFlag) { | 1929 if (!m_bNotifyFlag) { |
| 1930 m_bNotifyFlag = TRUE; | 1930 m_bNotifyFlag = TRUE; |
| 1931 m_pNotify->IOnSetScrollPosY(fy); | 1931 m_pNotify->IOnSetScrollPosY(fy); |
| 1932 m_bNotifyFlag = FALSE; | 1932 m_bNotifyFlag = FALSE; |
| 1933 } | 1933 } |
| 1934 } | 1934 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 void CFX_Edit::SetScrollLimit() { | 1950 void CFX_Edit::SetScrollLimit() { |
| 1951 if (m_pVT->IsValid()) { | 1951 if (m_pVT->IsValid()) { |
| 1952 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1952 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
| 1953 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); | 1953 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); |
| 1954 | 1954 |
| 1955 if (rcPlate.Width() > rcContent.Width()) { | 1955 if (rcPlate.Width() > rcContent.Width()) { |
| 1956 SetScrollPosX(rcPlate.left); | 1956 SetScrollPosX(rcPlate.left); |
| 1957 } else { | 1957 } else { |
| 1958 if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left)) { | 1958 if (IsFloatSmaller(m_ptScrollPos.x, rcContent.left)) { |
| 1959 SetScrollPosX(rcContent.left); | 1959 SetScrollPosX(rcContent.left); |
| 1960 } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, | 1960 } else if (IsFloatBigger(m_ptScrollPos.x, |
| 1961 rcContent.right - rcPlate.Width())) { | 1961 rcContent.right - rcPlate.Width())) { |
| 1962 SetScrollPosX(rcContent.right - rcPlate.Width()); | 1962 SetScrollPosX(rcContent.right - rcPlate.Width()); |
| 1963 } | 1963 } |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 if (rcPlate.Height() > rcContent.Height()) { | 1966 if (rcPlate.Height() > rcContent.Height()) { |
| 1967 SetScrollPosY(rcPlate.top); | 1967 SetScrollPosY(rcPlate.top); |
| 1968 } else { | 1968 } else { |
| 1969 if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, | 1969 if (IsFloatSmaller(m_ptScrollPos.y, |
| 1970 rcContent.bottom + rcPlate.Height())) { | 1970 rcContent.bottom + rcPlate.Height())) { |
| 1971 SetScrollPosY(rcContent.bottom + rcPlate.Height()); | 1971 SetScrollPosY(rcContent.bottom + rcPlate.Height()); |
| 1972 } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top)) { | 1972 } else if (IsFloatBigger(m_ptScrollPos.y, rcContent.top)) { |
| 1973 SetScrollPosY(rcContent.top); | 1973 SetScrollPosY(rcContent.top); |
| 1974 } | 1974 } |
| 1975 } | 1975 } |
| 1976 } | 1976 } |
| 1977 } | 1977 } |
| 1978 | 1978 |
| 1979 void CFX_Edit::ScrollToCaret() { | 1979 void CFX_Edit::ScrollToCaret() { |
| 1980 SetScrollLimit(); | 1980 SetScrollLimit(); |
| 1981 | 1981 |
| 1982 if (!m_pVT->IsValid()) | 1982 if (!m_pVT->IsValid()) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2000 ptHead.y = line.ptLine.y + line.fLineAscent; | 2000 ptHead.y = line.ptLine.y + line.fLineAscent; |
| 2001 ptFoot.x = line.ptLine.x; | 2001 ptFoot.x = line.ptLine.x; |
| 2002 ptFoot.y = line.ptLine.y + line.fLineDescent; | 2002 ptFoot.y = line.ptLine.y + line.fLineDescent; |
| 2003 } | 2003 } |
| 2004 | 2004 |
| 2005 CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead); | 2005 CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead); |
| 2006 CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot); | 2006 CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot); |
| 2007 | 2007 |
| 2008 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); | 2008 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); |
| 2009 | 2009 |
| 2010 if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) { | 2010 if (!IsFloatEqual(rcPlate.left, rcPlate.right)) { |
| 2011 if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) || | 2011 if (IsFloatSmaller(ptHeadEdit.x, rcPlate.left) || |
| 2012 FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)) { | 2012 IsFloatEqual(ptHeadEdit.x, rcPlate.left)) { |
| 2013 SetScrollPosX(ptHead.x); | 2013 SetScrollPosX(ptHead.x); |
| 2014 } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right)) { | 2014 } else if (IsFloatBigger(ptHeadEdit.x, rcPlate.right)) { |
| 2015 SetScrollPosX(ptHead.x - rcPlate.Width()); | 2015 SetScrollPosX(ptHead.x - rcPlate.Width()); |
| 2016 } | 2016 } |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 if (!FX_EDIT_IsFloatEqual(rcPlate.top, rcPlate.bottom)) { | 2019 if (!IsFloatEqual(rcPlate.top, rcPlate.bottom)) { |
| 2020 if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) || | 2020 if (IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) || |
| 2021 FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) { | 2021 IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) { |
| 2022 if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) { | 2022 if (IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) { |
| 2023 SetScrollPosY(ptFoot.y + rcPlate.Height()); | 2023 SetScrollPosY(ptFoot.y + rcPlate.Height()); |
| 2024 } | 2024 } |
| 2025 } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { | 2025 } else if (IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { |
| 2026 if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { | 2026 if (IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { |
| 2027 SetScrollPosY(ptHead.y); | 2027 SetScrollPosY(ptHead.y); |
| 2028 } | 2028 } |
| 2029 } | 2029 } |
| 2030 } | 2030 } |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 void CFX_Edit::Refresh() { | 2033 void CFX_Edit::Refresh() { |
| 2034 if (m_bEnableRefresh && m_pVT->IsValid()) { | 2034 if (m_bEnableRefresh && m_pVT->IsValid()) { |
| 2035 m_Refresh.BeginRefresh(); | 2035 m_Refresh.BeginRefresh(); |
| 2036 RefreshPushLineRects(GetVisibleWordRange()); | 2036 RefreshPushLineRects(GetVisibleWordRange()); |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2781 | 2781 |
| 2782 return IsTextOverflow() || (nLimitChar > 0 && nTotalWords >= nLimitChar) || | 2782 return IsTextOverflow() || (nLimitChar > 0 && nTotalWords >= nLimitChar) || |
| 2783 (nCharArray > 0 && nTotalWords >= nCharArray); | 2783 (nCharArray > 0 && nTotalWords >= nCharArray); |
| 2784 } | 2784 } |
| 2785 | 2785 |
| 2786 FX_BOOL CFX_Edit::IsTextOverflow() const { | 2786 FX_BOOL CFX_Edit::IsTextOverflow() const { |
| 2787 if (!m_bEnableScroll && !m_bEnableOverflow) { | 2787 if (!m_bEnableScroll && !m_bEnableOverflow) { |
| 2788 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); | 2788 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); |
| 2789 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 2789 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
| 2790 | 2790 |
| 2791 if (m_pVT->IsMultiLine() && GetTotalLines() > 1) { | 2791 if (m_pVT->IsMultiLine() && GetTotalLines() > 1 && |
| 2792 if (FX_EDIT_IsFloatBigger(rcContent.Height(), rcPlate.Height())) | 2792 IsFloatBigger(rcContent.Height(), rcPlate.Height())) { |
| 2793 return TRUE; | 2793 return TRUE; |
| 2794 } | 2794 } |
| 2795 | 2795 |
| 2796 if (FX_EDIT_IsFloatBigger(rcContent.Width(), rcPlate.Width())) | 2796 if (IsFloatBigger(rcContent.Width(), rcPlate.Width())) |
| 2797 return TRUE; | 2797 return TRUE; |
| 2798 } | 2798 } |
| 2799 | 2799 |
| 2800 return FALSE; | 2800 return FALSE; |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace& place) const { | 2803 CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace& place) const { |
| 2804 return m_pVT->GetLineBeginPlace(place); | 2804 return m_pVT->GetLineBeginPlace(place); |
| 2805 } | 2805 } |
| 2806 | 2806 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 int32_t CFX_Edit_RectArray::GetSize() const { | 3053 int32_t CFX_Edit_RectArray::GetSize() const { |
| 3054 return m_Rects.GetSize(); | 3054 return m_Rects.GetSize(); |
| 3055 } | 3055 } |
| 3056 | 3056 |
| 3057 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 3057 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
| 3058 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 3058 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 3059 return nullptr; | 3059 return nullptr; |
| 3060 | 3060 |
| 3061 return m_Rects.GetAt(nIndex); | 3061 return m_Rects.GetAt(nIndex); |
| 3062 } | 3062 } |
| OLD | NEW |