1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 /*************************************************************************** 8 * Copyright (C) 2004 by Riku Leino * 9 * tsoots@gmail.com * 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 * This program is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 19 * GNU General Public License for more details. * 20 * * 21 * You should have received a copy of the GNU General Public License * 22 * along with this program; if not, write to the * 23 * Free Software Foundation, Inc., * 24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 25 ***************************************************************************/ 26 27 #ifndef GTGETTEXT_H 28 #define GTGETTEXT_H 29 30 #include <iostream> 31 #include <vector> 32 33 #include <QDir> 34 #include <QMap> 35 #include <QObject> 36 #include <QString> 37 #include <QStringList> 38 39 #include "scconfig.h" 40 #include "scribusapi.h" 41 #include "scfonts.h" 42 43 class PageItem; 44 class ScribusDoc; 45 class gtDialogs; 46 47 // A struct for holding the Importer specific information. 48 struct ImporterData { 49 QString soFilePath; // Path to the Importer 50 QString fileFormatName; // Name of the Importer 51 QStringList fileEndings; // Array of filenames supported by the importer 52 }; 53 54 // A Struct for holding the results of the File selection Dialog 55 struct ImportSetup { 56 bool runDialog; // Did the dialog run correctly? 57 int importer; // Which importer was selected? 58 QString filename; // What filename is to be loaded? 59 bool textOnly; // Do we import as text only? 60 bool prefixNames; // Prefix Style names with item name; 61 QString encoding; // File encoding 62 }; 63 64 /* 65 GetText handles the open file dialog and importer plugins loading and launching. 66 */ 67 class SCRIBUS_API gtGetText 68 { 69 private: 70 std::vector<ImporterData> m_importers; // Vector of the loaded importers 71 QMap<QString, ImporterData*> m_importerMap; // QMap of the supported extensions to their relevant importers entry for easy access 72 void loadImporterPlugins(); // Find the available plugins based on the environment, validate they load, and 73 // create quick lookup mappings. 74 void CallDLL(const ImporterData& idata, const QString& filePath, 75 const QString& encoding, bool textOnly, bool append, bool prefix, PageItem* importItem); 76 // Loads, validates, and executes the Importer code. 77 bool DLLName(const QString& name, QString *ffName, QStringList *fileEndings); 78 // Loads the "DLL", validates the importer is good, populates the passed parameters with 79 // the plugin information. 80 void createMap(); // Create the importer Qmap. 81 gtDialogs* m_dias; // File Selection Dialog pointer. 82 QStringList m_ilist; // List of supported importers, used with dialogs 83 ScribusDoc* m_Doc; // Which document are we working with. 84 public: 85 gtGetText(ScribusDoc* doc); // Constructor 86 ~gtGetText(); // Destructor 87 QStringList getSupportedTypes(); // get all Fileextensions we support 88 ImportSetup run(); // Creates the dialog for the user to import a file based on the supported file formats. 89 void launchImporter(int importer, const QString& filename, bool textOnly, const QString& encoding, bool append, bool prefix, PageItem* target=nullptr); 90 // Look at the results of the file selection dialog and figure out if you need to use an importer. 91 // Prompt the user if the importer to use isn't obvious. 92 }; 93 94 #endif 95