Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfgas_txtbreak.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef XFA_FGAS_LAYOUT_CFGAS_TXTBREAK_H_
8#define XFA_FGAS_LAYOUT_CFGAS_TXTBREAK_H_
9
10#include <deque>
11#include <vector>
12
13#include "core/fxcrt/fx_coordinates.h"
14#include "core/fxcrt/retain_ptr.h"
15#include "core/fxcrt/unowned_ptr.h"
16#include "core/fxcrt/unowned_ptr_exclusion.h"
17#include "xfa/fgas/layout/cfgas_break.h"
18#include "xfa/fgas/layout/cfgas_char.h"
19
20class CFGAS_GEFont;
21class TextCharPos;
22
23#define FX_TXTCHARSTYLE_ArabicShadda 0x0020
24#define FX_TXTCHARSTYLE_OddBidiLevel 0x0040
25
32
37
38class CFGAS_TxtBreak final : public CFGAS_Break {
39 public:
40 class Engine {
41 public:
42 virtual ~Engine();
43 virtual wchar_t GetChar(size_t idx) const = 0;
44 // May return negative for combining characters. Non-const so we can force
45 // a layout if needed.
46 virtual int32_t GetWidthOfChar(size_t idx) = 0;
47 };
48
49 struct Run {
50 Run();
51 Run(const Run& other);
52 ~Run();
53
54 UnownedPtr<CFGAS_TxtBreak::Engine> pEdtEngine;
55 WideString wsStr;
56 UNOWNED_PTR_EXCLUSION int32_t* pWidths = nullptr;
57 // TODO(thestig): These 2 members probably should be size_t.
58 int32_t iStart = 0;
59 int32_t iLength = 0;
60 RetainPtr<CFGAS_GEFont> pFont;
61 float fFontSize = 12.0f;
63 int32_t iHorizontalScale = 100;
64 int32_t iVerticalScale = 100;
65 uint32_t dwCharStyles = 0;
67 bool bSkipSpace = true;
68 };
69
71 ~CFGAS_TxtBreak() override;
72
73 void SetLineWidth(float fLineWidth);
74 void SetAlignment(int32_t iAlignment);
75 void SetCombWidth(float fCombWidth);
77
78 size_t GetDisplayPos(const Run& run, TextCharPos* pCharPos) const;
79 std::vector<CFX_RectF> GetCharRects(const Run& run) const;
80 CFGAS_Char::BreakType AppendChar(wchar_t wch);
81
82 private:
83 void AppendChar_Combination(CFGAS_Char* pCurChar);
84 void AppendChar_Tab(CFGAS_Char* pCurChar);
85 CFGAS_Char::BreakType AppendChar_Control(CFGAS_Char* pCurChar);
86 CFGAS_Char::BreakType AppendChar_Arabic(CFGAS_Char* pCurChar);
87 CFGAS_Char::BreakType AppendChar_Others(CFGAS_Char* pCurChar);
88
89 void ResetContextCharStyles();
90 void EndBreakSplitLine(CFGAS_BreakLine* pNextLine, bool bAllChars);
91 std::deque<TPO> EndBreakBidiLine(CFGAS_Char::BreakType dwStatus);
92 void EndBreakAlignment(const std::deque<TPO>& tpos,
93 bool bAllChars,
94 CFGAS_Char::BreakType dwStatus);
95 int32_t GetBreakPos(std::vector<CFGAS_Char>* pChars,
96 bool bAllChars,
97 bool bOnlyBrk,
98 int32_t* pEndPos);
99 void SplitTextLine(CFGAS_BreakLine* pCurLine,
100 CFGAS_BreakLine* pNextLine,
101 bool bAllChars);
102
103 int32_t m_iAlignment = CFX_TxtLineAlignment_Left;
104 int32_t m_iCombWidth = 360000;
105};
106
107#endif // XFA_FGAS_LAYOUT_CFGAS_TXTBREAK_H_
WordBreakProperty FX_GetWordBreakProperty(wchar_t wcCodePoint)
bool FX_CheckStateChangeForWordBreak(WordBreakProperty from, WordBreakProperty to)
WordBreakProperty
CFX_TxtLineAlignment
@ CFX_TxtLineAlignment_Justified
@ CFX_TxtLineAlignment_Right
@ CFX_TxtLineAlignment_Center
@ CFX_TxtLineAlignment_Left
#define FX_TXTCHARSTYLE_OddBidiLevel
bool CFX_BreakTypeNoneOrPiece(CFGAS_Char::BreakType type)
virtual void OnCaretChanged()=0
virtual bool OnValidate(const WideString &wsText)=0
virtual ~Delegate()=default
virtual void OnSelChanged()=0
virtual void OnTextWillChange(TextChange *change)=0
virtual void SetScrollOffset(float fScrollOffset)=0
virtual void OnTextChanged()=0
virtual void NotifyTextFull()=0
Iterator(const CFDE_TextEditEngine *engine)
virtual void Undo() const =0
virtual void Redo() const =0
virtual ~Operation()=default
void SetAlignment(uint32_t alignment)
void SetCombText(bool enable)
size_t GetIndexAtStartOfLine(size_t pos) const
void Insert(size_t idx, const WideString &text, RecordOperation add_operation=RecordOperation::kInsertRecord)
std::pair< size_t, size_t > BoundsForWordAt(size_t idx) const
void SetAvailableWidth(size_t width)
void EnablePasswordMode(bool val)
WideString GetSelectedText() const
WideString GetText() const
size_t GetIndexAtEndOfLine(size_t pos) const
size_t GetIndexLeft(size_t pos) const
size_t GetIndexRight(size_t pos) const
void EnableValidation(bool val)
WideString Delete(size_t start_idx, size_t length, RecordOperation add_operation=RecordOperation::kInsertRecord)
~CFDE_TextEditEngine() override
void SetDelegate(Delegate *delegate)
std::pair< int32_t, CFX_RectF > GetCharacterInfo(int32_t start_idx)
void SetVisibleLineCount(size_t lines)
size_t GetIndexDown(size_t pos) const
void LimitHorizontalScroll(bool val)
size_t GetIndexForPoint(const CFX_PointF &point)
FX_ARGB GetFontColor() const
void SetSelection(size_t start_idx, size_t count)
void SetFont(RetainPtr< CFGAS_GEFont > font)
void LimitVerticalScroll(bool val)
void SetHasCharacterLimit(bool limit)
std::vector< CFX_RectF > GetCharacterRectsInRange(int32_t start_idx, int32_t count)
int32_t GetWidthOfChar(size_t idx) override
bool CanGenerateCharacterInfo() const
const std::vector< FDE_TEXTEDITPIECE > & GetTextPieces()
std::pair< size_t, size_t > GetSelection() const
std::vector< TextCharPos > GetDisplayPos(const FDE_TEXTEDITPIECE &info)
void SetCharacterLimit(size_t limit)
void SetAliasChar(wchar_t alias)
RetainPtr< CFGAS_GEFont > GetFont() const
wchar_t GetChar(size_t idx) const override
size_t GetIndexUp(size_t pos) const
void SetTabWidth(float width)
void SetMaxEditOperationsForTesting(size_t max)
void ReplaceSelectedText(const WideString &str)
WideString DeleteSelectedText(RecordOperation add_operation=RecordOperation::kInsertRecord)
void SetLineSpace(float space)
void SetFontColor(FX_ARGB color)
int32_t GetCharCount() const
int32_t GetStartPos() const
uint32_t GetCharStyles() const
int32_t GetBidiLevel() const
int32_t GetWidth() const
virtual wchar_t GetChar(size_t idx) const =0
virtual int32_t GetWidthOfChar(size_t idx)=0
std::vector< CFX_RectF > GetCharRects(const Run &run) const
size_t GetDisplayPos(const Run &run, TextCharPos *pCharPos) const
CFGAS_Char::BreakType EndBreak(CFGAS_Char::BreakType dwStatus)
~CFGAS_TxtBreak() override
void SetLineWidth(float fLineWidth)
CFGAS_Char::BreakType AppendChar(wchar_t wch)
void SetAlignment(int32_t iAlignment)
void SetCombWidth(float fCombWidth)
void Offset(float dx, float dy)
constexpr CFX_RectF()=default
CFX_RectF & operator=(const CFX_RectF &other)=default
void Union(const CFX_RectF &rt)
WideString & operator+=(const WideString &str)
WideString & operator=(WideString &&that) noexcept
bool IsEmpty() const
Definition widestring.h:118
#define FX_IsOdd(a)
#define CHECK(cvref)
UnownedPtr< const CFX_RectF > pRect
UNOWNED_PTR_EXCLUSION int32_t * pWidths
Run(const Run &other)
RetainPtr< CFGAS_GEFont > pFont
Mask< LayoutStyle > dwStyles
UnownedPtr< CFGAS_TxtBreak::Engine > pEdtEngine
FDE_TEXTEDITPIECE(const FDE_TEXTEDITPIECE &that)
bool single_line_
Definition cfde_data.h:29
bool line_wrap_
Definition cfde_data.h:30
#define UNOWNED_PTR_EXCLUSION