| 1410 | } |
| 1411 | |
| 1412 | Document::OpenResult Part::doOpenFile(const QMimeType &mimeA, const QString &fileNameToOpenA, bool *isCompressedFile) |
| 1413 | { |
| 1414 | QMimeDatabase db; |
| 1415 | Document::OpenResult openResult = Document::OpenError; |
| 1416 | bool uncompressOk = true; |
| 1417 | QMimeType mime = mimeA; |
| 1418 | QString fileNameToOpen = fileNameToOpenA; |
| 1419 | KCompressionDevice::CompressionType compressionType = compressionTypeFor(mime.name()); |
| 1420 | if (compressionType != KCompressionDevice::None) { |
| 1421 | *isCompressedFile = true; |
| 1422 | uncompressOk = handleCompressed(fileNameToOpen, localFilePath(), compressionType); |
| 1423 | mime = db.mimeTypeForFile(fileNameToOpen); |
| 1424 | } else { |
| 1425 | *isCompressedFile = false; |
| 1426 | } |
| 1427 | |
| 1428 | if (m_swapInsteadOfOpening) { |
| 1429 | m_swapInsteadOfOpening = false; |
| 1430 | |
| 1431 | if (!uncompressOk) { |
| 1432 | return Document::OpenError; |
| 1433 | } |
| 1434 | |
| 1435 | if (mime.inherits(QStringLiteral("application/vnd.kde.okular-archive"))) { |
| 1436 | isDocumentArchive = true; |
| 1437 | if (!m_document->swapBackingFileArchive(fileNameToOpen, url())) { |
| 1438 | return Document::OpenError; |
| 1439 | } |
| 1440 | } else { |
| 1441 | isDocumentArchive = false; |
| 1442 | if (!m_document->swapBackingFile(fileNameToOpen, url())) { |
| 1443 | return Document::OpenError; |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | m_fileLastModified = QFileInfo(localFilePath()).lastModified(); |
| 1448 | return Document::OpenSuccess; |
| 1449 | } |
| 1450 | |
| 1451 | isDocumentArchive = false; |
| 1452 | if (uncompressOk) { |
| 1453 | if (mime.inherits(QStringLiteral("application/vnd.kde.okular-archive"))) { |
| 1454 | openResult = m_document->openDocumentArchive(fileNameToOpen, url()); |
| 1455 | isDocumentArchive = true; |
| 1456 | } else { |
| 1457 | openResult = m_document->openDocument(fileNameToOpen, url(), mime); |
| 1458 | } |
| 1459 | m_documentOpenWithPassword = false; |
| 1460 | |
| 1461 | // if the file didn't open correctly it might be encrypted, so ask for a pass |
| 1462 | #if HAVE_KWALLET |
| 1463 | QString walletName, walletFolder, walletKey; |
| 1464 | m_document->walletDataForFile(fileNameToOpen, &walletName, &walletFolder, &walletKey); |
| 1465 | bool triedWallet = false; |
| 1466 | KWallet::Wallet *wallet = nullptr; |
| 1467 | bool keep = true; |
| 1468 | #endif |
| 1469 | bool firstInput = true; |
nothing calls this directly
no test coverage detected