Text highlight tools basics

This commit is contained in:
Jakub Melka
2020-12-11 18:59:39 +01:00
parent 11ad8f2821
commit dc55950050
13 changed files with 856 additions and 18 deletions

View File

@ -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