Text selection tool - finishing (without copying text)

This commit is contained in:
Jakub Melka
2020-01-26 17:06:50 +01:00
parent 95f6135482
commit 12b2f44619
9 changed files with 286 additions and 20 deletions

View File

@ -180,7 +180,7 @@ struct PDFCharacterPointer
/// Returns true, if character belongs to same line
bool hasSameLine(const PDFCharacterPointer& other) const;
int pageIndex = -1;
PDFInteger pageIndex = -1;
size_t blockIndex = 0;
size_t lineIndex = 0;
size_t characterIndex = 0;
@ -324,7 +324,7 @@ public:
/// Adds character to the layout
void addCharacter(const PDFTextCharacterInfo& info);
/// Perorms text layout algorithm
/// Performs text layout algorithm
void perform();
/// Optimizes layout memory allocation to contain less space
@ -339,6 +339,14 @@ public:
/// Returns true, if given point is pointing to some text block
bool isHoveringOverTextBlock(const QPointF& point) const;
/// Creates text selection. This function needs to modify the layout contents,
/// so do not use this function from multiple threads (it is not thread-safe).
/// Text selection is created from rectangle using two points.
/// \param pageIndex Page index
/// \param point1 First point
/// \param point2 Second point
PDFTextSelection createTextSelection(PDFInteger pageIndex, const QPointF& point1, const QPointF& point2);
friend QDataStream& operator<<(QDataStream& stream, const PDFTextLayout& layout);
friend QDataStream& operator>>(QDataStream& stream, PDFTextLayout& layout);
@ -354,7 +362,7 @@ private:
/// Applies transform to text characters (positions and bounding boxes)
/// \param characters Characters
/// \param matrix Transform matrix
void applyTransform(TextCharacters& characters, const QMatrix& matrix);
static void applyTransform(TextCharacters& characters, const QMatrix& matrix);
TextCharacters m_characters;
std::set<PDFReal> m_angles;
@ -458,6 +466,9 @@ public:
/// \param flowFlags Text flow flags
PDFFindResults find(const QRegularExpression& expression, PDFTextFlow::FlowFlags flowFlags) const;
/// Returns number of pages
size_t getCount() const { return m_offsets.size(); }
private:
std::vector<int> m_offsets;
QByteArray m_textLayouts;