mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Text highlight tools basics
This commit is contained in:
@ -1306,7 +1306,7 @@ bool PDFFindResult::operator<(const PDFFindResult& other) const
|
||||
return textSelectionItems.front() < other.textSelectionItems.front();
|
||||
}
|
||||
|
||||
PDFTextLayout PDFTextLayoutGetter::getTextLayoutImpl() const
|
||||
PDFTextLayout PDFTextLayoutStorageGetter::getTextLayoutImpl() const
|
||||
{
|
||||
return m_storage ? m_storage->getTextLayout(m_pageIndex) : PDFTextLayout();
|
||||
}
|
||||
@ -1423,4 +1423,29 @@ void PDFTextSelectionPainter::draw(QPainter* painter, PDFInteger pageIndex, PDFT
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
PDFTextLayoutCache::PDFTextLayoutCache(std::function<PDFTextLayout (PDFInteger)> textLayoutGetter) :
|
||||
m_textLayoutGetter(qMove(textLayoutGetter)),
|
||||
m_pageIndex(-1),
|
||||
m_layout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PDFTextLayoutCache::clear()
|
||||
{
|
||||
m_pageIndex = -1;
|
||||
m_layout = PDFTextLayout();
|
||||
}
|
||||
|
||||
const PDFTextLayout& PDFTextLayoutCache::getTextLayout(PDFInteger pageIndex)
|
||||
{
|
||||
if (m_pageIndex != pageIndex)
|
||||
{
|
||||
m_pageIndex = pageIndex;
|
||||
m_layout = m_textLayoutGetter(pageIndex);
|
||||
}
|
||||
|
||||
return m_layout;
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
Reference in New Issue
Block a user