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 "../../include/fxedit/fxet_stub.h" | 7 #include "../../include/fxedit/fxet_stub.h" |
8 #include "../../include/fxedit/fxet_edit.h" | 8 #include "../../include/fxedit/fxet_edit.h" |
9 | 9 |
10 #define FX_EDIT_UNDO_MAXITEM 10000 | 10 #define FX_EDIT_UNDO_MAXITEM 10000 |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 } | 1914 } |
1915 | 1915 |
1916 pIterator->SetAt(oldplace); | 1916 pIterator->SetAt(oldplace); |
1917 return bSet; | 1917 return bSet; |
1918 } | 1918 } |
1919 } | 1919 } |
1920 | 1920 |
1921 return FALSE; | 1921 return FALSE; |
1922 } | 1922 } |
1923 | 1923 |
1924 void CFX_Edit::SetText(FX_LPCWSTR text,int32_t charset /*= DEFAULT_CHARSET*/, | 1924 void CFX_Edit::SetText(const FX_WCHAR* text,int32_t charset /*= DEFAULT_CHARSET*
/, |
1925 const CPVT_SecProps * pSecProps
/*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/) | 1925 const CPVT_SecProps * pSecProps
/*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/) |
1926 { | 1926 { |
1927 SetText(text,charset,pSecProps,pWordProps,TRUE,TRUE); | 1927 SetText(text,charset,pSecProps,pWordProps,TRUE,TRUE); |
1928 } | 1928 } |
1929 | 1929 |
1930 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, int32_t charset /*= DEFAULT_CHARSET*/
, const CPVT_WordProps * pWordProps /*= NULL*/) | 1930 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, int32_t charset /*= DEFAULT_CHARSET*/
, const CPVT_WordProps * pWordProps /*= NULL*/) |
1931 { | 1931 { |
1932 return InsertWord(word,charset,pWordProps,TRUE,TRUE); | 1932 return InsertWord(word,charset,pWordProps,TRUE,TRUE); |
1933 } | 1933 } |
1934 | 1934 |
(...skipping 10 matching lines...) Expand all Loading... |
1945 FX_BOOL CFX_Edit::Delete() | 1945 FX_BOOL CFX_Edit::Delete() |
1946 { | 1946 { |
1947 return Delete(TRUE,TRUE); | 1947 return Delete(TRUE,TRUE); |
1948 } | 1948 } |
1949 | 1949 |
1950 FX_BOOL CFX_Edit::Clear() | 1950 FX_BOOL CFX_Edit::Clear() |
1951 { | 1951 { |
1952 return Clear(TRUE,TRUE); | 1952 return Clear(TRUE,TRUE); |
1953 } | 1953 } |
1954 | 1954 |
1955 FX_BOOL CFX_Edit::InsertText(FX_LPCWSTR text, int32_t charset /*= DEFAULT_CHARSE
T*/, | 1955 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset /*= DEFAULT_C
HARSET*/, |
1956 const CPVT_SecPr
ops * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/) | 1956 const CPVT_SecPr
ops * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/) |
1957 { | 1957 { |
1958 return InsertText(text,charset,pSecProps,pWordProps,TRUE,TRUE); | 1958 return InsertText(text,charset,pSecProps,pWordProps,TRUE,TRUE); |
1959 } | 1959 } |
1960 | 1960 |
1961 FX_FLOAT CFX_Edit::GetFontSize() const | 1961 FX_FLOAT CFX_Edit::GetFontSize() const |
1962 { | 1962 { |
1963 return m_pVT->GetFontSize(); | 1963 return m_pVT->GetFontSize(); |
1964 } | 1964 } |
1965 | 1965 |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 SetCaret(m_pVT->GetLineEndPlace(m_wpCare
t)); | 2955 SetCaret(m_pVT->GetLineEndPlace(m_wpCare
t)); |
2956 | 2956 |
2957 ScrollToCaret(); | 2957 ScrollToCaret(); |
2958 SetCaretOrigin(); | 2958 SetCaretOrigin(); |
2959 SetCaretInfo(); | 2959 SetCaretInfo(); |
2960 } | 2960 } |
2961 } | 2961 } |
2962 } | 2962 } |
2963 } | 2963 } |
2964 | 2964 |
2965 void CFX_Edit::SetText(FX_LPCWSTR text,int32_t charset, | 2965 void CFX_Edit::SetText(const FX_WCHAR* text,int32_t charset, |
2966 const CPVT_SecProps * pSecProps,
const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) | 2966 const CPVT_SecProps * pSecProps,
const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) |
2967 { | 2967 { |
2968 Empty(); | 2968 Empty(); |
2969 DoInsertText(CPVT_WordPlace(0,0,-1), text, charset, pSecProps, pWordProp
s); | 2969 DoInsertText(CPVT_WordPlace(0,0,-1), text, charset, pSecProps, pWordProp
s); |
2970 if (bPaint) Paint(); | 2970 if (bPaint) Paint(); |
2971 if (m_bOprNotify && m_pOprNotify) | 2971 if (m_bOprNotify && m_pOprNotify) |
2972 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); | 2972 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); |
2973 //if (bAddUndo) | 2973 //if (bAddUndo) |
2974 } | 2974 } |
2975 | 2975 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 if (m_bOprNotify && m_pOprNotify) | 3257 if (m_bOprNotify && m_pOprNotify) |
3258 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); | 3258 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); |
3259 | 3259 |
3260 return TRUE; | 3260 return TRUE; |
3261 } | 3261 } |
3262 } | 3262 } |
3263 | 3263 |
3264 return FALSE; | 3264 return FALSE; |
3265 } | 3265 } |
3266 | 3266 |
3267 FX_BOOL CFX_Edit::InsertText(FX_LPCWSTR text, int32_t charset, | 3267 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset, |
3268 const CPVT_SecProps * pSecProps, const C
PVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) | 3268 const CPVT_SecProps * pSecProps, const C
PVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) |
3269 { | 3269 { |
3270 if (IsTextOverflow()) return FALSE; | 3270 if (IsTextOverflow()) return FALSE; |
3271 | 3271 |
3272 m_pVT->UpdateWordPlace(m_wpCaret); | 3272 m_pVT->UpdateWordPlace(m_wpCaret); |
3273 SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps)); | 3273 SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps)); |
3274 m_SelState.Set(m_wpCaret,m_wpCaret); | 3274 m_SelState.Set(m_wpCaret,m_wpCaret); |
3275 | 3275 |
3276 if (m_wpCaret != m_wpOldCaret) | 3276 if (m_wpCaret != m_wpOldCaret) |
3277 { | 3277 { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3503 pIterator->GetLine(line); | 3503 pIterator->GetLine(line); |
3504 | 3504 |
3505 pIterator->SetAt(wpOld); | 3505 pIterator->SetAt(wpOld); |
3506 | 3506 |
3507 return line.ptLine.y + line.fLineDescent; | 3507 return line.ptLine.y + line.fLineDescent; |
3508 } | 3508 } |
3509 | 3509 |
3510 return 0.0f; | 3510 return 0.0f; |
3511 } | 3511 } |
3512 | 3512 |
3513 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, FX_LPCWSTR te
xt, int32_t charset, | 3513 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, const FX_WCHA
R* text, int32_t charset, |
3514 const
CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) | 3514 const
CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) |
3515 { | 3515 { |
3516 CPVT_WordPlace wp = place; | 3516 CPVT_WordPlace wp = place; |
3517 | 3517 |
3518 if (m_pVT->IsValid()) | 3518 if (m_pVT->IsValid()) |
3519 { | 3519 { |
3520 CFX_WideString sText = text; | 3520 CFX_WideString sText = text; |
3521 | 3521 |
3522 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) | 3522 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) |
3523 { | 3523 { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3584 } | 3584 } |
3585 } | 3585 } |
3586 | 3586 |
3587 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) | 3587 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) |
3588 { | 3588 { |
3589 m_Undo.AddItem(pUndoItem); | 3589 m_Undo.AddItem(pUndoItem); |
3590 if (m_bOprNotify && m_pOprNotify) | 3590 if (m_bOprNotify && m_pOprNotify) |
3591 m_pOprNotify->OnAddUndo(pUndoItem); | 3591 m_pOprNotify->OnAddUndo(pUndoItem); |
3592 } | 3592 } |
3593 | 3593 |
OLD | NEW |