7#ifndef FPDFSDK_PWL_CPWL_EDIT_IMPL_H_
8#define FPDFSDK_PWL_CPWL_EDIT_IMPL_H_
15#include "core/fpdfdoc/cpvt_variabletext.h"
16#include "core/fpdfdoc/cpvt_wordrange.h"
17#include "core/fxcrt/bytestring.h"
18#include "core/fxcrt/fx_codepage_forward.h"
19#include "core/fxcrt/unowned_ptr.h"
20#include "core/fxge/dib/fx_dib.h"
21#include "fpdfsdk/pwl/ipwl_fillernotify.h"
36 void SetAt(int32_t nWordIndex);
50 FX_COLORREF crTextFill,
52 const CFX_PointF& ptOffset,
87 void OnMouseDown(
const CFX_PointF& point,
bool bShift,
bool bCtrl);
88 void OnMouseMove(
const CFX_PointF& point,
bool bShift,
bool bCtrl);
94 void OnVK_END(
bool bShift,
bool bCtrl);
95 void SetText(
const WideString& sText);
118 void SetSelection(int32_t nStartChar, int32_t nEndChar);
147 std::vector<CFX_FloatRect>* GetRefreshRects();
153 : m_wrLine(wrLine), m_rcLine
(rcLine
) {}
161 std::vector<LineRect> m_NewLineRects;
162 std::vector<LineRect> m_OldLineRects;
163 std::vector<CFX_FloatRect> m_RefreshRects;
176 bool IsEmpty()
const;
182 class UndoItemIface {
184 virtual ~UndoItemIface() =
default;
197 virtual int Undo() = 0;
198 virtual int Redo() = 0;
199 void set_undo_remaining(
int undo_remaining) {
200 undo_remaining_ = undo_remaining;
202 int undo_remaining()
const {
return undo_remaining_; }
205 int undo_remaining_ = 0;
213 void AddItem(std::unique_ptr<UndoItemIface> pItem);
216 bool CanUndo()
const;
217 bool CanRedo()
const;
220 UndoItemIface* GetLastAddItem();
226 std::deque<std::unique_ptr<UndoItemIface>> m_UndoItemStack;
227 size_t m_nCurUndoPos = 0;
228 bool m_bWorking =
false;
235 class UndoInsertReturn;
236 class UndoInsertText;
237 class UndoInsertWord;
238 class UndoReplaceSelection;
240 bool IsTextOverflow()
const;
243 const WideString& sText,
246 int32_t GetTotalLines()
const;
248 bool Delete(
bool bAddUndo);
249 bool Clear(
bool bAddUndo);
250 bool InsertText(
const WideString& sText,
FX_Charset charset,
bool bAddUndo);
251 bool InsertWord(uint16_t word,
FX_Charset charset,
bool bAddUndo);
252 bool InsertReturn(
bool bAddUndo);
253 bool Backspace(
bool bAddUndo);
256 CFX_PointF VTToEdit(
const CFX_PointF& point)
const;
260 void ScrollToCaret();
261 void SetScrollInfo();
262 void SetScrollPosX(
float fx);
263 void SetScrollPosY(
float fy);
264 void SetScrollLimit();
265 void SetContentChanged();
270 CFX_PointF EditToVT(
const CFX_PointF& point)
const;
277 void SetCaretOrigin();
279 void AddEditUndoItem(std::unique_ptr<UndoItemIface> pEditUndoItem);
281 bool m_bEnableScroll =
false;
282 bool m_bNotifyFlag =
false;
283 bool m_bEnableOverflow =
false;
284 bool m_bEnableRefresh =
true;
285 bool m_bEnableUndo =
true;
286 int32_t m_nAlignment = 0;
287 std::unique_ptr<Provider> m_pVTProvider;
288 std::unique_ptr<CPVT_VariableText> m_pVT;
292 SelectState m_SelState;
293 CFX_PointF m_ptScrollPos;
294 CFX_PointF m_ptRefreshScrollPos;
295 std::unique_ptr<Iterator> m_pIterator;
296 RefreshState m_Refresh;
297 CFX_PointF m_ptCaret;
CFX_FloatRect(const CFX_FloatRect &that)=default
CFX_FloatRect GetCenterSquare() const
constexpr CFX_FloatRect(float l, float b, float r, float t)
void ScaleFromCenterPoint(float fScale)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
CFX_FloatRect GetDeflated(float x, float y) const
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void SetAsTextField(absl::optional< WideString > sValue)
CPDFSDK_AppStream(CPDFSDK_Widget *widget, CPDF_Dictionary *dict)
void SetAsComboBox(absl::optional< WideString > sValue)
bool IsModifiedAPStream(const CPDF_Stream *stream) const
RetainPtr< CPDF_Stream > CreateModifiedAPStream()
bool GetFittingBounds() const
void SetAt(int32_t nWordIndex)
Iterator(CPWL_EditImpl *pEdit, CPVT_VariableText::Iterator *pVTIterator)
bool GetWord(CPVT_Word &word) const
bool GetLine(CPVT_Line &line) const
const CPVT_WordPlace & GetAt() const
void SetAt(const CPVT_WordPlace &place)
WideString GetRangeText(const CPVT_WordRange &range) const
void OnVK_DOWN(bool bShift)
WideString GetText() const
uint16_t GetPasswordChar() const
void EnableUndo(bool bUndo)
CFX_FloatRect GetContentRect() const
void SetText(const WideString &sText)
int32_t GetCharArray() const
std::pair< int32_t, int32_t > GetSelection() const
void OnMouseMove(const CFX_PointF &point, bool bShift, bool bCtrl)
void SetFontMap(IPVT_FontMap *pFontMap)
CPVT_WordPlace GetCaretWordPlace() const
CPVT_WordRange GetSelectWordRange() const
void OnMouseDown(const CFX_PointF &point, bool bShift, bool bCtrl)
void DrawEdit(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, FX_COLORREF crTextFill, const CFX_FloatRect &rcClip, const CFX_PointF &ptOffset, const CPVT_WordRange *pRange, IPWL_FillerNotify *pFillerNotify, IPWL_FillerNotify::PerWindowData *pSystemData)
void SetAutoScroll(bool bAuto)
void SetAutoReturn(bool bAuto)
void SetTextOverflow(bool bAllowed)
void OnVK_RIGHT(bool bShift)
void OnVK_END(bool bShift, bool bCtrl)
void SetFontSize(float fFontSize)
void SetAlignmentH(int32_t nFormat)
void RefreshWordRange(const CPVT_WordRange &wr)
void EnableRefresh(bool bRefresh)
bool InsertWord(uint16_t word, FX_Charset charset)
ByteString GetPDFWordString(int32_t nFontIndex, uint16_t Word, uint16_t SubWord)
void OnVK_HOME(bool bShift, bool bCtrl)
void OnVK_UP(bool bShift)
IPVT_FontMap * GetFontMap()
void SetLimitChar(int32_t nLimitChar)
void SetSelection(int32_t nStartChar, int32_t nEndChar)
void SetCharArray(int32_t nCharArray)
void SetAlignmentV(int32_t nFormat)
CPVT_WordPlace WordIndexToWordPlace(int32_t index) const
CPVT_WordRange GetWholeWordRange() const
CPVT_WordPlace SearchWordPlace(const CFX_PointF &point) const
WideString GetSelectedText() const
void SetNotify(CPWL_Edit *pNotify)
CPVT_WordRange GetVisibleWordRange() const
void ReplaceSelection(const WideString &text)
bool InsertText(const WideString &sText, FX_Charset charset)
float GetFontSize() const
void SetScrollPos(const CFX_PointF &point)
void ReplaceAndKeepSelection(const WideString &text)
void SetMultiLine(bool bMultiLine)
void OnVK_LEFT(bool bShift)
CFX_PointF GetScrollPos() const
void SetAutoFontSize(bool bAuto)
void SetPlateRect(const CFX_FloatRect &rect)
void SetPasswordChar(uint16_t wSubWord)
static float GetCharArrayAutoFontSize(const CPDF_Font *pFont, const CFX_FloatRect &rcPlate, int32_t nCharArray)
void SetScrollInfo(const PWL_SCROLL_INFO &info) override
void SetFontSize(float fFontSize) override
bool SetCaret(bool bVisible, const CFX_PointF &ptHead, const CFX_PointF &ptFoot)
bool SelectAllText() override
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlag) override
CPWL_Edit(const CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)
CFX_FloatRect GetFocusRect() const override
bool RepositionChildWnd() override
void SetScrollPosition(float pos) override
void SetAlignFormatVerticalCenter()
void SetCursor() override
WideString GetText() override
void SetCharSet(FX_Charset nCharSet)
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void OnSetFocus() override
void ReplaceAndKeepSelection(const WideString &text) override
void ScrollWindowVertically(float pos) override
void SetCharArray(int32_t nCharArray)
void SetSelection(int32_t nStartChar, int32_t nEndChar)
std::pair< int32_t, int32_t > GetSelection() const
void OnKillFocus() override
void SetScrollPos(const CFX_PointF &point)
void SetText(const WideString &csText)
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void ReplaceSelection(const WideString &text) override
CFX_FloatRect GetClientRect() const override
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point, const CFX_Vector &delta) override
void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
bool OnChar(uint16_t nChar, Mask< FWL_EVENTFLAG > nFlag) override
void OnCreated() override
WideString GetSelectedText() override
float GetFontSize() const override
void SetLimitChar(int32_t nLimitChar)
FX_Charset GetCharSet() const
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
CFX_PointF GetScrollPos() const
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void CreateChildWnd(const CreateParams &cp) override
void OnDestroy() override
bool CanSelectAll() const
CreateParams(CFX_Timer::HandlerIface *timer_handler, IPWL_FillerNotify *filler_notify, ProviderIface *provider)
virtual ByteString GetPDFFontAlias(int32_t nFontIndex)=0
ByteString & operator+=(const ByteString &str)
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
WideString & operator=(WideString &&that) noexcept
CharType operator[](const size_t index) const
WideString & operator=(const WideString &that)
#define FXSYS_IsFloatBigger(fa, fb)
#define FXSYS_IsFloatZero(f)
ByteString operator+(const ByteString &str1, const ByteString &str2)
CFX_Color operator/(float fColorDivide) const
CFX_Color operator-(float fColorSub) const
CFX_Color & operator=(const CFX_Color &that)=default
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
int32_t LineCmp(const CPVT_WordPlace &wp) const
CPWL_Dash(int32_t dash, int32_t gap, int32_t phase)