mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
Fix links being "lost" on save
Summary: We need to regenerate the links when switching the file since we won't re-render the pages since we already have them and link generation is on page render BUG: 397373 Reviewers: tobiasdeiminger Reviewed By: tobiasdeiminger Subscribers: tobiasdeiminger, sander, okular-devel Tags: #okular Differential Revision: https://phabricator.kde.org/D14752
This commit is contained in:
parent
0d3e4a5853
commit
0a8d2f7f85
|
@ -643,11 +643,30 @@ Okular::Document::OpenResult PDFGenerator::init(QVector<Okular::Page*> & pagesVe
|
|||
|
||||
PDFGenerator::SwapBackingFileResult PDFGenerator::swapBackingFile( QString const &newFileName, QVector<Okular::Page*> & newPagesVector )
|
||||
{
|
||||
const QBitArray oldRectsGenerated = rectsGenerated;
|
||||
|
||||
doCloseDocument();
|
||||
auto openResult = loadDocumentWithPassword(newFileName, newPagesVector, QString());
|
||||
if (openResult != Okular::Document::OpenSuccess)
|
||||
return SwapBackingFileError;
|
||||
|
||||
// Recreate links if needed since they are done on image() and image() is not called when swapping the file
|
||||
// since the page is already rendered
|
||||
if (oldRectsGenerated.count() == rectsGenerated.count()) {
|
||||
for (int i = 0; i < oldRectsGenerated.count(); ++i) {
|
||||
if (oldRectsGenerated[i]) {
|
||||
Okular::Page *page = newPagesVector[i];
|
||||
Poppler::Page *pp = pdfdoc->page( i );
|
||||
if (pp) {
|
||||
page->setObjectRects(generateLinks(pp->links()));
|
||||
rectsGenerated[i] = true;
|
||||
resolveMediaLinkReferences(page);
|
||||
delete pp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SwapBackingFileReloadInternalData;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue