exportdata.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef EXPORTDATA_H
  2. #define EXPORTDATA_H
  3. #include <QSharedPointer>
  4. class QPageLayout;
  5. namespace vnotex
  6. {
  7. enum class ExportSource
  8. {
  9. CurrentBuffer = 0,
  10. CurrentFolder,
  11. CurrentNotebook
  12. };
  13. enum class ExportFormat
  14. {
  15. Markdown = 0,
  16. HTML,
  17. PDF,
  18. Custom
  19. };
  20. struct ExportHtmlOption
  21. {
  22. QJsonObject toJson() const;
  23. void fromJson(const QJsonObject &p_obj);
  24. bool operator==(const ExportHtmlOption &p_other) const;
  25. bool m_embedStyles = true;
  26. bool m_completePage = true;
  27. bool m_embedImages = true;
  28. bool m_useMimeHtmlFormat = false;
  29. // Whether add outline panel.
  30. bool m_addOutlinePanel = true;
  31. };
  32. struct ExportPdfOption
  33. {
  34. ExportPdfOption();
  35. QJsonObject toJson() const;
  36. void fromJson(const QJsonObject &p_obj);
  37. bool operator==(const ExportPdfOption &p_other) const;
  38. QSharedPointer<QPageLayout> m_layout;
  39. // Add TOC at the front to complement the missing of outline.
  40. bool m_addTableOfContents = false;
  41. bool m_useWkhtmltopdf = false;
  42. QString m_wkhtmltopdfExePath;
  43. QString m_wkhtmltopdfArgs;
  44. };
  45. struct ExportOption
  46. {
  47. QJsonObject toJson() const;
  48. void fromJson(const QJsonObject &p_obj);
  49. bool operator==(const ExportOption &p_other) const;
  50. ExportSource m_source = ExportSource::CurrentBuffer;
  51. ExportFormat m_targetFormat = ExportFormat::HTML;
  52. bool m_useTransparentBg = true;
  53. QString m_renderingStyleFile;
  54. QString m_syntaxHighlightStyleFile;
  55. QString m_outputDir;
  56. bool m_recursive = true;
  57. bool m_exportAttachments = true;
  58. ExportHtmlOption m_htmlOption;
  59. ExportPdfOption m_pdfOption;
  60. };
  61. inline QString exportFormatString(ExportFormat p_format)
  62. {
  63. switch (p_format)
  64. {
  65. case ExportFormat::Markdown:
  66. return QStringLiteral("Markdown");
  67. case ExportFormat::HTML:
  68. return QStringLiteral("HTML");
  69. case ExportFormat::PDF:
  70. return QStringLiteral("PDF");
  71. case ExportFormat::Custom:
  72. return QStringLiteral("Custom");
  73. }
  74. return QStringLiteral("Unknown");
  75. }
  76. }
  77. #endif // EXPORTDATA_H