File indexing completed on 2024-12-22 04:28:07

0001 /*
0002   SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "importabstractautocorrection.h"
0010 #include "textautocorrectioncore_export.h"
0011 class QTemporaryDir;
0012 class KZip;
0013 class QDomDocument;
0014 class QFile;
0015 class KArchiveDirectory;
0016 
0017 namespace TextAutoCorrectionCore
0018 {
0019 class TEXTAUTOCORRECTIONCORE_EXPORT ImportLibreOfficeAutocorrection : public ImportAbstractAutocorrection
0020 {
0021 public:
0022     ImportLibreOfficeAutocorrection();
0023     ~ImportLibreOfficeAutocorrection() override;
0024 
0025     [[nodiscard]] bool import(const QString &fileName, QString &errorMessage, ImportAbstractAutocorrection::LoadAttribute loadAttribute = All) override;
0026 
0027 private:
0028     enum Type {
0029         DOCUMENT,
0030         SENTENCE,
0031         WORD,
0032     };
0033 
0034     TEXTAUTOCORRECTIONCORE_NO_EXPORT void importAutoCorrectionFile();
0035     TEXTAUTOCORRECTIONCORE_NO_EXPORT void closeArchive();
0036     [[nodiscard]] TEXTAUTOCORRECTIONCORE_NO_EXPORT bool loadDomElement(QDomDocument &doc, QFile *file);
0037     [[nodiscard]] TEXTAUTOCORRECTIONCORE_NO_EXPORT bool importFile(Type type, const KArchiveDirectory *archiveDirectory);
0038     KZip *mArchive = nullptr;
0039     QTemporaryDir *mTempDir = nullptr;
0040 };
0041 }