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/span.h"
16#include "core/fxcrt/unowned_ptr.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;
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,
79 pdfium::span<TextCharPos> pCharPos) const;
80 std::vector<CFX_RectF> GetCharRects(const Run& run) const;
81 CFGAS_Char::BreakType AppendChar(wchar_t wch);
82
83 private:
84 void AppendChar_Combination(CFGAS_Char* pCurChar);
85 void AppendChar_Tab(CFGAS_Char* pCurChar);
86 CFGAS_Char::BreakType AppendChar_Control(CFGAS_Char* pCurChar);
87 CFGAS_Char::BreakType AppendChar_Arabic(CFGAS_Char* pCurChar);
88 CFGAS_Char::BreakType AppendChar_Others(CFGAS_Char* pCurChar);
89
90 void ResetContextCharStyles();
91 void EndBreakSplitLine(CFGAS_BreakLine* pNextLine, bool bAllChars);
92 std::deque<TPO> EndBreakBidiLine(CFGAS_Char::BreakType dwStatus);
93 void EndBreakAlignment(const std::deque<TPO>& tpos,
94 bool bAllChars,
95 CFGAS_Char::BreakType dwStatus);
96 int32_t GetBreakPos(std::vector<CFGAS_Char>* pChars,
97 bool bAllChars,
98 bool bOnlyBrk,
99 int32_t* pEndPos);
100 void SplitTextLine(CFGAS_BreakLine* pCurLine,
101 CFGAS_BreakLine* pNextLine,
102 bool bAllChars);
103
104 int32_t m_iAlignment = CFX_TxtLineAlignment_Left;
105 int32_t m_iCombWidth = 360000;
106};
107
108#endif // XFA_FGAS_LAYOUT_CFGAS_TXTBREAK_H_
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)
#define DCHECK
Definition check.h:33
#define CHECK_NE(x, y)
Definition check_op.h:11
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
CFGAS_Char::BreakType EndBreak(CFGAS_Char::BreakType dwStatus)
~CFGAS_TxtBreak() override
void SetLineWidth(float fLineWidth)
size_t GetDisplayPos(const Run &run, pdfium::span< TextCharPos > pCharPos) const
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
WideString()=default
virtual void SetScrollOffset(float fScrollOffset)=0
virtual void OnTextWillChange(TextChange *change)=0
virtual bool OnValidate(const WideString &wsText)=0
Iterator(const CFDE_TextEditEngine *engine)
wchar_t GetChar(size_t idx) const override
RetainPtr< CFGAS_GEFont > GetFont() const
size_t GetIndexLeft(size_t pos) const
std::pair< size_t, size_t > GetSelection() const
size_t GetIndexDown(size_t pos) const
size_t GetIndexForPoint(const CFX_PointF &point)
int32_t GetWidthOfChar(size_t idx) override
std::vector< TextCharPos > GetDisplayPos(const FDE_TEXTEDITPIECE &info)
void Insert(size_t idx, const WideString &text, RecordOperation add_operation=RecordOperation::kInsertRecord)
void SetSelection(size_t start_idx, size_t count)
std::pair< int32_t, CFX_RectF > GetCharacterInfo(int32_t start_idx)
void SetAlignment(uint32_t alignment)
std::pair< size_t, size_t > BoundsForWordAt(size_t idx) const
std::vector< CFX_RectF > GetCharacterRectsInRange(int32_t start_idx, int32_t count)
void ReplaceSelectedText(const WideString &str)
size_t GetIndexUp(size_t pos) const
size_t GetIndexAtStartOfLine(size_t pos) const
WideString DeleteSelectedText(RecordOperation add_operation=RecordOperation::kInsertRecord)
void SetFont(RetainPtr< CFGAS_GEFont > font)
void SetDelegate(Delegate *delegate)
size_t GetIndexRight(size_t pos) const
size_t GetIndexAtEndOfLine(size_t pos) const
void SetMaxEditOperationsForTesting(size_t max)
WideString Delete(size_t start_idx, size_t length, RecordOperation add_operation=RecordOperation::kInsertRecord)
const std::vector< FDE_TEXTEDITPIECE > & GetTextPieces()
#define UNSAFE_TODO(...)
CFX_PTemplate< float > CFX_PointF
uint32_t FX_ARGB
Definition fx_dib.h:36
#define FX_IsOdd(a)
WordBreakProperty FX_GetWordBreakProperty(wchar_t wcCodePoint)
bool FX_CheckStateChangeForWordBreak(WordBreakProperty from, WordBreakProperty to)
#define CHECK(cvref)
fxcrt::WideStringView WideStringView
UnownedPtr< const CFX_RectF > pRect
pdfium::span< 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)
fxcrt::WideString WideString
Definition widestring.h:207