mirror of https://github.com/JakubMelka/PDF4QT.git
Bugfixing: optional content changed
This commit is contained in:
parent
e9481fc446
commit
78b56ab007
|
@ -254,12 +254,16 @@ bool PDFTextLayoutGenerator::isContentKindSuppressed(ContentKind kind) const
|
|||
|
||||
void PDFTextLayoutGenerator::performOutputCharacter(const PDFTextCharacterInfo& info)
|
||||
{
|
||||
m_textLayout.addCharacter(info);
|
||||
if (!isContentSuppressed())
|
||||
{
|
||||
m_textLayout.addCharacter(info);
|
||||
}
|
||||
}
|
||||
|
||||
PDFAsynchronousTextLayoutCompiler::PDFAsynchronousTextLayoutCompiler(PDFDrawWidgetProxy* proxy) :
|
||||
BaseClass(proxy),
|
||||
m_proxy(proxy)
|
||||
m_proxy(proxy),
|
||||
m_isRunning(false)
|
||||
{
|
||||
connect(&m_textLayoutCompileFutureWatcher, &QFutureWatcher<PDFTextLayoutStorage>::finished, this, &PDFAsynchronousTextLayoutCompiler::onTextLayoutCreated);
|
||||
}
|
||||
|
@ -348,15 +352,19 @@ void PDFAsynchronousTextLayoutCompiler::makeTextLayout()
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_textLayoutCompileFuture.isRunning())
|
||||
if (m_isRunning)
|
||||
{
|
||||
// Text layout is already being processed
|
||||
return;
|
||||
}
|
||||
|
||||
// Jakub Melka: Mark, that we are running (test for future is not enough,
|
||||
// because future can finish before this function exits, for example)
|
||||
m_isRunning = true;
|
||||
|
||||
ProgressStartupInfo info;
|
||||
info.showDialog = true;
|
||||
info.text = tr("Generating text layouts for pages...");
|
||||
info.text = tr("Indexing document contents...");
|
||||
|
||||
m_proxy->getFontCache()->setCacheShrinkEnabled(this, false);
|
||||
const PDFCatalog* catalog = m_proxy->getDocument()->getCatalog();
|
||||
|
@ -402,6 +410,7 @@ void PDFAsynchronousTextLayoutCompiler::onTextLayoutCreated()
|
|||
m_proxy->getProgress()->finish();
|
||||
|
||||
m_textLayouts = m_textLayoutCompileFuture.result();
|
||||
m_isRunning = false;
|
||||
emit textLayoutChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ private:
|
|||
|
||||
PDFDrawWidgetProxy* m_proxy;
|
||||
State m_state = State::Inactive;
|
||||
bool m_isRunning;
|
||||
std::optional<PDFTextLayoutStorage> m_textLayouts;
|
||||
QFuture<PDFTextLayoutStorage> m_textLayoutCompileFuture;
|
||||
QFutureWatcher<PDFTextLayoutStorage> m_textLayoutCompileFutureWatcher;
|
||||
|
|
|
@ -54,16 +54,10 @@ void PDFDrawSpaceController::setDocument(const PDFDocument* document, const PDFO
|
|||
m_document = document;
|
||||
m_fontCache.setDocument(document);
|
||||
m_optionalContentActivity = optionalContentActivity;
|
||||
connect(m_optionalContentActivity, &PDFOptionalContentActivity::optionalContentGroupStateChanged, this, &PDFDrawSpaceController::onOptionalContentGroupStateChanged);
|
||||
recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFDrawSpaceController::onOptionalContentGroupStateChanged()
|
||||
{
|
||||
emit pageImageChanged(true, { });
|
||||
}
|
||||
|
||||
void PDFDrawSpaceController::setPageLayout(PageLayout pageLayout)
|
||||
{
|
||||
if (m_pageLayoutMode != pageLayout)
|
||||
|
@ -423,6 +417,7 @@ void PDFDrawWidgetProxy::setDocument(const PDFDocument* document, const PDFOptio
|
|||
m_compiler->stop();
|
||||
m_textLayoutCompiler->stop();
|
||||
m_controller->setDocument(document, optionalContentActivity);
|
||||
connect(optionalContentActivity, &PDFOptionalContentActivity::optionalContentGroupStateChanged, this, &PDFDrawWidgetProxy::onOptionalContentGroupStateChanged);
|
||||
m_compiler->start();
|
||||
m_textLayoutCompiler->start();
|
||||
}
|
||||
|
@ -1196,4 +1191,11 @@ void PDFDrawWidgetProxy::onColorManagementSystemChanged()
|
|||
emit pageImageChanged(true, { });
|
||||
}
|
||||
|
||||
void PDFDrawWidgetProxy::onOptionalContentGroupStateChanged()
|
||||
{
|
||||
m_compiler->reset();
|
||||
m_textLayoutCompiler->reset();
|
||||
emit pageImageChanged(true, { });
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
|
|
@ -123,8 +123,6 @@ signals:
|
|||
void pageImageChanged(bool all, const std::vector<PDFInteger>& pages);
|
||||
|
||||
private:
|
||||
void onOptionalContentGroupStateChanged();
|
||||
|
||||
/// Recalculates the draw space. Preserves setted page rotation.
|
||||
void recalculate();
|
||||
|
||||
|
@ -331,6 +329,7 @@ private:
|
|||
QRectF fromDeviceSpace(const QRectF& rect) const;
|
||||
|
||||
void onTextLayoutChanged();
|
||||
void onOptionalContentGroupStateChanged();
|
||||
void onColorManagementSystemChanged();
|
||||
void onHorizontalScrollbarValueChanged(int value);
|
||||
void onVerticalScrollbarValueChanged(int value);
|
||||
|
|
Loading…
Reference in New Issue