/**
 * Copyright (C) 2003-2026, Foxit Software Inc..
 * All Rights Reserved.
 *
 * http://www.foxitsoftware.com
 *
 * The following code is copyrighted and is the proprietary of Foxit Software Inc.. It is not allowed to
 * distribute any parts of Foxit PDF SDK to third party or public without permission unless an agreement
 * is signed between Foxit Software Inc. and customers to explicitly grant customers permissions.
 *
 * @file fs_office2pdf.h
 * @brief Header file for PDF conversion related definitions and classes.
 *
 * @details This file is part of Foxit PDF SDK, and it is the initial release of the office2pdf module.
 * It provides definitions and classes for converting office documents to PDF format.
 *
 * @note This is the first version, and we are committed to ongoing improvements and enhancements
 * to ensure better performance and additional features in future releases.
 */

#ifndef FS_OFFICE2PDF_H_
#define FS_OFFICE2PDF_H_
#if defined(_WIN32) || defined(_WIN64) || (defined(__linux__) && (defined(__i386__) || defined(__x86_64__)))

#include "common/fs_common.h"

/**
* @brief Foxit namespace.
*
* @details All the definitions and classes of Foxit PDF SDK are defined within this namespace.
*/
namespace foxit {
  using namespace common;

namespace conversion {
/**
 * @brief Conversion namespace.
 */
namespace office2pdf {
/** This class represents setting data used for converting Word format files to PDF format files. */
class Word2PDFSettingData FS_FINAL : public Object{
 public:
  /** @brief Constructor. */
  Word2PDFSettingData()
    : is_generate_bookmark(false) {}

  /**
   * @brief Constructor, with parameters.
   * 
   * @param[in] is_generate_bookmark  A boolean value which indicates whether to export bookmarks to converted PDF file.
   */
  Word2PDFSettingData(bool is_generate_bookmark) {
    this->is_generate_bookmark = is_generate_bookmark;
  }

  /**
   * @brief Assign operator.
   *
   * @param[in] data  Another Word-to-PDF setting data object, whose value would be assigned to current object.
   *
   * @return Reference to current object itself.
   */
  Word2PDFSettingData& operator = (const Word2PDFSettingData& data) {
    is_generate_bookmark = data.is_generate_bookmark;
    return (*this);
  }
  /**
   * @brief Set value.
   *
   * @param[in] is_generate_bookmark  A boolean value which indicates whether to export bookmarks to converted PDF file.
   *
   * @return None.
   */
  void Set(bool is_generate_bookmark) {
    this->is_generate_bookmark = is_generate_bookmark;
  }

  /**
   * @brief A boolean value which indicates whether to export bookmarks to converted PDF file.
   * 
   * @details <b>true</b> means to export bookmarks to converted PDF file, while <b>false</b> means not.
   *          Default value: <b>false</b>.
   */
  bool is_generate_bookmark;
};

/** This class represents setting data used for converting Excel format files to PDF format files. */
class Excel2PDFSettingData FS_FINAL : public Object{
 public:
  /** @brief Constructor. */
  Excel2PDFSettingData()
    : is_separate_workbook(false)
    , is_output_hidden_worksheets(false) {}

  /**
   * @brief Constructor, with parameters.
   *
   * @param[in] is_separate_workbook         A boolean value which indicates whether to export worksheets to separate PDF files.
   * @param[in] is_output_hidden_worksheets  A boolean value which indicates whether to output the hidden worksheets.
   * @param[in] worksheet_names              An array of specific worksheet names to be converted to PDF files.
   */
  Excel2PDFSettingData(bool is_separate_workbook, bool is_output_hidden_worksheets, foxit::WStringArray worksheet_names) {
    this->is_separate_workbook = is_separate_workbook;
    this->is_output_hidden_worksheets = is_output_hidden_worksheets;
    this->worksheet_names = worksheet_names;
  }

  /**
   * @brief Assign operator.
   *
   * @param[in] data  Another Excel-to-PDF setting data object, whose value would be assigned to current object.
   *
   * @return Reference to current object itself.
   */
  Excel2PDFSettingData & operator = (const Excel2PDFSettingData & data) {
    is_separate_workbook = data.is_separate_workbook;
    is_output_hidden_worksheets = data.is_output_hidden_worksheets;
    worksheet_names = data.worksheet_names;
    return (*this);
  }

  /**
   * @brief Set value.
   *
   * @param[in] is_separate_workbook         A boolean value which indicates whether to export worksheets to separate PDF files.
   * @param[in] is_output_hidden_worksheets  A boolean value which indicates whether to output the hidden worksheets.
   * @param[in] worksheet_names              An array of specific worksheet names to be converted to PDF files.
   *
   * @return None.
   */
  void Set(bool is_separate_workbook, bool is_output_hidden_worksheets, foxit::WStringArray worksheet_names) {
    this->is_separate_workbook = is_separate_workbook;
    this->is_output_hidden_worksheets = is_output_hidden_worksheets;
    this->worksheet_names = worksheet_names;
  }

  /**
   * @brief A boolean value which indicates whether to export worksheets to separate PDF files.
   *
   * @details <b>true</b> means to export each worksheet to separate PDF files, while <b>false</b> means not.
   */
  bool is_separate_workbook;

  /**
   * @brief A boolean value which indicates whether to output the hidden worksheets.
   *
   * @details <b>true</b> means to output the hidden worksheets, while <b>false</b> means not.
   */
  bool is_output_hidden_worksheets;

  /**
   * @brief An array of specific worksheet names to be converted to PDF files.
   *
   * @details If this array is empty, all worksheets will be converted to PDF files.
   */
  foxit::WStringArray worksheet_names;
};

/** This class represents setting data used for converting Office(Word, Excel or PowerPoint) to PDF format file. */
class Office2PDFSettingData FS_FINAL : public Object{
 public:
  /** @brief Constructor. */
  Office2PDFSettingData()
    : is_embed_font(false){}

  /**
   * @brief Constructor, with parameters.
   *
   * @param[in] resource_folder_path  A valid path of a folder which contains resource data files. This should not be an empty string.
   *                                  These resource data files are used to simulate the pdf format document typesetting process during conversion.
   *                                  They are offered in the "res/office2pdf" folder of the Foxit PDF Conversion SDK package.
   * @param[in] is_embed_font         <b>true</b> means to embed font in the converted file, while <b>false</b> means not.
   * @param[in] word_setting_data     A setting data object that used for converting Word format documents to PDF format documents.
   * @param[in] excel_setting_data    A setting data object that used for converting Excel format documents to PDF format documents.
   */
  Office2PDFSettingData(const wchar_t* resource_folder_path, bool is_embed_font, Word2PDFSettingData word_setting_data, Excel2PDFSettingData excel_setting_data) {
    this->resource_folder_path = resource_folder_path;
    this->is_embed_font = is_embed_font;
    this->word_setting_data = word_setting_data;
    this->excel_setting_data = excel_setting_data;
  }

  /**
   * @brief Assign operator.
   *
   * @param[in] data  Another Office-to-PDF setting data object, whose value would be assigned to current object.
   *
   * @return Reference to current object itself.
   */
  Office2PDFSettingData &operator = (const Office2PDFSettingData& data) {
    resource_folder_path = data.resource_folder_path;
    is_embed_font = data.is_embed_font;
    word_setting_data = data.word_setting_data;
    excel_setting_data = data.excel_setting_data;
    return (*this);
  }

  /**
   * @brief Set value.
   *
   * @param[in] resource_folder_path  A valid path of a folder which contains resource data files. This should not be an empty string.
   *                                      These resource data files are used to simulate the pdf format document typesetting process during conversion.
   *                                      They are offered in the "res/office2pdf" folder of the Foxit PDF Conversion SDK package.
   * @param[in] is_embed_font        <b>true</b> means to embed font in the converted file, while <b>false</b> means not.
   * @param[in] word_setting_data    A setting data object that used for converting Word format documents to PDF format documents.
   * @param[in] excel_setting_data   A setting data object that used for converting Excel format documents to PDF format documents.
   *
   * @return None.
   */
  void Set(const wchar_t* resource_folder_path, bool is_embed_font, Word2PDFSettingData word_setting_data, Excel2PDFSettingData excel_setting_data) {
    this->resource_folder_path = resource_folder_path;
    this->is_embed_font = is_embed_font;
    this->word_setting_data = word_setting_data;
    this->excel_setting_data = excel_setting_data;
  }

  /**
   * @brief A valid path of a folder which contains resource data files. This should not be an empty string.
   *
   * @details These resource data files are used to simulate the pdf format document typesetting process during conversion.
   *          They are offered in the "res/office2pdf" folder of the Foxit PDF Conversion SDK package.
   */
  WString resource_folder_path;

  /**
   * @brief A boolean value which indicates whether to embed font in the converted file,Default value: <b>false</b>.
   *
   * @details <b>true</b> means to embed font in the converted file, while <b>false</b> means not. 
   *
   */
  bool is_embed_font;

  /**
   * @brief A setting data object that used for converting Word format documents to PDF format documents.
   *
   * @details This setting is only vaild for the conversion of Word documents to PDF format documents.
   *          For more details, please refer to class @link Word2PDFSettingData @endlink.
   */
  Word2PDFSettingData word_setting_data;

  /**
   * @brief A setting data object that used for converting Excel format documents to PDF format documents.
   *
   * @details This setting is only vaild for the conversion of Excel documents to PDF format documents.
   *          For more details, please refer to class @link Excel2PDFSettingData @endlink.
   */
  Excel2PDFSettingData excel_setting_data;
};

/**
 * This class can be used to convert Office(Word, Excel or PowerPoint) format files to PDF files.
 * Before using methods in this module, please ensure Foxit PDF Conversion SDK has been initialized successfully
 * by function @link common::Library::Initialize @endlink with a key including "Office2PDF" module.
 *
 * @see @link common::Library @endlink
 */
class Office2PDF FS_FINAL : public Base{
 public:
  /**
   * @brief Convert a Word format file to a PDF file.
   *
   * @details Currently,this function is only available for Windows and Linux Desktop (32-bit and 64-bit), and it supports conversion only from DOC and DOCX format files. 
   *
   * @param[in] src_word_file_path  Path of a Word format file. This should not be an empty string.
   * @param[in] src_file_password   (Reserved,encrypted files are unsupported yet)Password for the input Word format file. If no password is needed for the file,
   *                                please pass an empty string.
   * @param[in] saved_pdf_path      Path of the saved PDF file as conversion result. This should not be an empty string.
   * @param[in] setting_data          A @link conversion::office2pdf::Office2PDFSettingData @endlink object which is used for converting.
   *
   * @return <b>true</b> means success, while <b>false</b> means failure.
   *
   * @note If module "Office2PDF" is not defined in the license information which is used in function
   * @link common::Library::Initialize @endlink, that means user has no right in using this function and
   *   this function will throw exception @link foxit::e_ErrNoOffice2PDFModuleRight @endlink.
   */
  static bool ConvertFromWord(const wchar_t* src_word_file_path, const wchar_t* src_file_password, const wchar_t* saved_pdf_path, const Office2PDFSettingData& setting_data);

  /**
   * @brief Convert a Word format file to a PDF file.
   *
   * @details Currently,this function is only available for Windows and Linux Desktop (32-bit and 64-bit), and it supports conversion only from DOC and DOCX format files. 
   *                 The file is read all at once, rather than progressively.
   *
   * @param[in] src_word_reader     A @link ReaderCallback @endlink object which is implemented by user to
   *                                load a word document. It should not be <b>NULL</b>.
   *
   * @param[in] src_file_password   (Reserved,encrypted files are unsupported yet)Password for the input Word format file. If no password is needed for the file,
   *                                please pass an empty string.
   * @param[in] saved_pdf_file_stream  A @link foxit::common::file::StreamCallback @endlink object which is implemented by user 
   *                                   to read the contents of the converted PDF file. It should not be <b>NULL</b>.
   * @param[in] setting_data          A @link conversion::office2pdf::Office2PDFSettingData @endlink object which is used for converting.
   *
   * @return <b>true</b> means success, while <b>false</b> means failure.
   *
   * @note If module "Office2PDF" is not defined in the license information which is used in function
   * @link common::Library::Initialize @endlink, that means user has no right in using this function and
   *   this function will throw exception @link foxit::e_ErrNoOffice2PDFModuleRight @endlink.
   */
  static bool ConvertFromWord(file::ReaderCallback* src_word_reader, const wchar_t* src_file_password, file::StreamCallback* saved_pdf_file_stream, const Office2PDFSettingData& setting_data);

  /**
   * @brief Convert an Excel format file to a PDF file.
   *
   * @details Currently,this function is only available for Windows and Linux Desktop (32-bit and 64-bit), and it supports conversion only from XLSX format files. 
   *
   * @param[in] src_excel_file_path  Path of an Excel format file. This should not be an empty string.
   * @param[in] src_file_password    (Reserved,encrypted files are unsupported yet)Password for the input Excel format file. If no password is needed for the file,
   *                                 please pass an empty string.
   * @param[in] saved_pdf_path       Path of the saved PDF file as conversion result. This should not be an empty string.
   * @param[in] setting_data          A @link conversion::office2pdf::Office2PDFSettingData @endlink object which is used for converting.
   *
   * @return <b>true</b> means success, while <b>false</b> means failure.
   *
   * @note If module "Office2PDF" is not defined in the license information which is used in function
   * @link common::Library::Initialize @endlink, that means user has no right in using this function and
   *   this function will throw exception @link foxit::e_ErrNoOffice2PDFModuleRight @endlink.
   */
  static bool ConvertFromExcel(const wchar_t* src_excel_file_path, const wchar_t* src_file_password, const wchar_t* saved_pdf_path, const Office2PDFSettingData& setting_data);

 /**
  * @brief Convert an Excel format file to a PDF file.
  *
  * @details Currently,this function is only available for Windows and Linux Desktop (32-bit and 64-bit), and it supports conversion only from XLSX format files. 
  *                The file is read all at once, rather than progressively.
  *
  * @param[in] src_excel_reader     A @link ReaderCallback @endlink object which is implemented by user to
  *                                load an excel document. It should not be <b>NULL</b>.
  *
  * @param[in] src_file_password   (Reserved,encrypted files are unsupported yet)Password for the input Word format file. If no password is needed for the file,
  *                                please pass an empty string.
  * @param[in] saved_pdf_file_stream  A @link foxit::common::file::StreamCallback @endlink object which is implemented by user
  *                                   to read the contents of the converted PDF file. It should not be <b>NULL</b>.
  * @param[in] setting_data          A @link conversion::office2pdf::Office2PDFSettingData @endlink object which is used for converting.
  *
  * @return <b>true</b> means success, while <b>false</b> means failure.
  *
  * @note If module "Office2PDF" is not defined in the license information which is used in function
  * @link common::Library::Initialize @endlink, that means user has no right in using this function and
  *   this function will throw exception @link foxit::e_ErrNoOffice2PDFModuleRight @endlink.
  */
  static bool ConvertFromExcel(file::ReaderCallback* src_excel_reader, const wchar_t* src_file_password, file::StreamCallback* saved_pdf_file_stream, const Office2PDFSettingData& setting_data);

  /**
   * @brief Convert a PowerPoint format file to a PDF file.
   *
   * @details Currently,this function is only available for Windows and Linux Desktop (32-bit and 64-bit), and it supports conversion only from PPTX format files.
   *
   * @param[in] src_ppt_file_path  Path of a PowerPoint format file. This should not be an empty string.
   * @param[in] src_file_password  (Reserved,encrypted files are unsupported yet)Password for the input Excel format file. If no password is needed for the file,
   *                               please pass an empty string.
   * @param[in] saved_pdf_path     Path of the saved PDF file as conversion result. This should not be an empty string.
   * @param[in] setting_data          A @link conversion::office2pdf::Office2PDFSettingData @endlink object which is used for converting.
   *
   * @return <b>true</b> means success, while <b>false</b> means failure.
   *
   * @note If module "Office2PDF" is not defined in the license information which is used in function
   * @link common::Library::Initialize @endlink, that means user has no right in using this function and
   *   this function will throw exception @link foxit::e_ErrNoOffice2PDFModuleRight @endlink.
   */
  static bool ConvertFromPowerPoint(const wchar_t* src_ppt_file_path, const wchar_t* src_file_password, const wchar_t* saved_pdf_path, const Office2PDFSettingData& setting_data);

  /**
   * @brief Convert a PowerPoint format file to a PDF file.
   *
   * @details Currently,this function is only available for Windows and Linux Desktop (32-bit and 64-bit), and it supports conversion only from PPTX format files.
   *                The file is read all at once, rather than progressively. 
   *
   * @param[in] src_ppt_reader     A @link ReaderCallback @endlink object which is implemented by user to
   *                                load a ppt document. It should not be <b>NULL</b>.
   *
   * @param[in] src_file_password   (Reserved,encrypted files are unsupported yet)Password for the input Word format file. If no password is needed for the file,
   *                                please pass an empty string.
   * @param[in] saved_pdf_file_stream  A @link foxit::common::file::StreamCallback @endlink object which is implemented by user
   *                                   to read the contents of the converted PDF file. It should not be <b>NULL</b>.
   * @param[in] setting_data          A @link conversion::office2pdf::Office2PDFSettingData @endlink object which is used for converting.
   *
   * @return <b>true</b> means success, while <b>false</b> means failure.
   *
   * @note If module "Office2PDF" is not defined in the license information which is used in function
   * @link common::Library::Initialize @endlink, that means user has no right in using this function and
   *   this function will throw exception @link foxit::e_ErrNoOffice2PDFModuleRight @endlink.
   */
  static bool ConvertFromPowerPoint(file::ReaderCallback* src_ppt_reader, const wchar_t* src_file_password, file::StreamCallback* saved_pdf_file_stream, const Office2PDFSettingData& setting_data);
};
};
}
}
#endif // defined(_WIN32)
#endif
