// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+/**
+ * \file exporter.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ====================================================== */
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
#ifndef EXPORTER_H
#define EXPORTER_H
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include "support/filename.h"
+#include <map>
+#include <string>
#include <vector>
-#include "LString.h"
+
+
+namespace lyx {
+
class Buffer;
+class Format;
-///
class Exporter {
public:
///
static
- bool Export(Buffer * buffer, string const & format,
- bool put_in_tempdir);
+ bool Export(Buffer * buffer, std::string const & format,
+ bool put_in_tempdir, std::string & result_file);
///
static
- bool Preview(Buffer * buffer, string const & format);
+ bool Export(Buffer * buffer, std::string const & format,
+ bool put_in_tempdir);
///
static
- std::vector<std::pair<string, string> > const
- GetExportableFormats(Buffer const * buffer);
+ bool preview(Buffer * buffer, std::string const & format);
///
static
- std::vector<std::pair<string, string> > const
- GetViewableFormats(Buffer const * buffer);
+ bool isExportable(Buffer const & buffer, std::string const & format);
///
static
- string const BufferExtension(Buffer const * buffer);
+ std::vector<Format const *> const
+ getExportableFormats(Buffer const & buffer, bool only_viewable);
+ ///
};
-//#define NEW_EXPORT 1
+
+class ExportedFile {
+public:
+ ExportedFile(support::FileName const &, std::string const &);
+ /// absolute name of the source file
+ support::FileName sourceName;
+ /// final name that the exported file should get (absolute name or
+ /// relative to the directory of the master document)
+ std::string exportName;
+};
+
+
+bool operator==(ExportedFile const &, ExportedFile const &);
+
+
+class ExportData {
+public:
+ /** add a referenced file for one format.
+ * No inset should ever write any file outside the tempdir.
+ * Instead, files that need to be exported have to be registered
+ * with this method.
+ * Then the exporter mechanism copies them to the right place, asks
+ * for confirmation before overwriting existing files etc.
+ * \param format format that references the given file
+ * \param sourceName source file name. Needs to be absolute
+ * \param exportName resulting file name. Can be either absolute
+ * or relative to the exported document.
+ */
+ void addExternalFile(std::string const & format,
+ support::FileName const & sourceName,
+ std::string const & exportName);
+ /** add a referenced file for one format.
+ * The final name is the source file name without path.
+ * \param format format that references the given file
+ * \param sourceName source file name. Needs to be absolute
+ */
+ void addExternalFile(std::string const & format,
+ support::FileName const & sourceName);
+ /// get referenced files for \p format
+ std::vector<ExportedFile> const
+ externalFiles(std::string const & format) const;
+private:
+ typedef std::map<std::string, std::vector<ExportedFile> > FileMap;
+ /** Files that are referenced by the export result in the
+ * different formats.
+ */
+ FileMap externalfiles;
+};
+
+
+} // namespace lyx
#endif