mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
fix bug #62155
This commit is contained in:
@ -77,7 +77,7 @@ using namespace cpdoccore;
|
||||
|
||||
namespace Oox2Odf
|
||||
{
|
||||
Converter::Converter(const std::wstring & path, const std::wstring & type, const std::wstring & fontsPath, bool bTemplate)
|
||||
Converter::Converter(const std::wstring & path, const std::wstring & type, const std::wstring & fontsPath, bool bTemplate, const std::wstring & tempPath)
|
||||
{
|
||||
impl_ = NULL;
|
||||
|
||||
@ -85,8 +85,11 @@ namespace Oox2Odf
|
||||
if (type == _T("spreadsheet")) impl_ = new XlsxConverter(path, bTemplate);
|
||||
if (type == _T("presentation")) impl_ = new PptxConverter(path, bTemplate);
|
||||
|
||||
if (impl_)
|
||||
impl_->set_fonts_directory(fontsPath);
|
||||
if (impl_)
|
||||
{
|
||||
impl_->set_fonts_directory(fontsPath);
|
||||
impl_->set_temp_directory(tempPath);
|
||||
}
|
||||
}
|
||||
|
||||
Converter::~Converter()
|
||||
@ -320,7 +323,12 @@ bool OoxConverter::encrypt_file (const std::wstring &password, const std::wstrin
|
||||
|
||||
return true;
|
||||
}
|
||||
void OoxConverter::set_temp_directory(const std::wstring & tempPath)
|
||||
{
|
||||
if (odf_context() == NULL) return;
|
||||
|
||||
odf_context()->set_temp_directory(tempPath);
|
||||
}
|
||||
void OoxConverter::set_fonts_directory(const std::wstring &fontsPath)
|
||||
{
|
||||
if (odf_context() == NULL) return;
|
||||
|
||||
@ -478,6 +478,7 @@ public:
|
||||
}
|
||||
|
||||
void set_fonts_directory (const std::wstring & fontsPath);
|
||||
void set_temp_directory (const std::wstring & tempPath);
|
||||
|
||||
bool encrypt_document (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath);
|
||||
bool encrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, std::wstring &encrypt_info, int &size);
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
|
||||
#include "Converter.h"
|
||||
|
||||
#include "../../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#include "../../../OOXML/XlsxFormat/Chart/ChartSerializeEx.h"
|
||||
|
||||
#include "../../Common/utils.h"
|
||||
@ -114,8 +116,6 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart)
|
||||
{
|
||||
if (!oox_chart)return;
|
||||
|
||||
convert(oox_chart->m_externalData);
|
||||
|
||||
convert(oox_chart->m_spPr.GetPointer());
|
||||
convert_chart_text(oox_chart->m_txPr.GetPointer(), true);
|
||||
|
||||
@ -137,6 +137,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart)
|
||||
//convert(oox_chart->m_chart->m_sizeWall, 3, chart3D);
|
||||
}
|
||||
odf_context()->chart_context()->end_plot_area();
|
||||
|
||||
convert(oox_chart->m_externalData);
|
||||
}
|
||||
void OoxConverter::convert(OOX::Spreadsheet::CT_View3D *oox_view3D)
|
||||
{
|
||||
@ -1330,17 +1332,33 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ExternalData *external_data)
|
||||
|
||||
if (false == external_data->m_id.IsInit()) return;
|
||||
|
||||
//CString pathEmbeddings = GetEmbeddings(*external_data->m_id);
|
||||
//oO
|
||||
//unpack
|
||||
smart_ptr<OOX::File> file = find_file_by_id(*external_data->m_id);
|
||||
smart_ptr<OOX::Media> media = file.smart_dynamic_cast<OOX::Media>();
|
||||
|
||||
//get/check Format - xlsx
|
||||
//конверт sheets -> table:table
|
||||
|
||||
//или
|
||||
//convert xlsx -> ods & read tables???
|
||||
|
||||
odf_context()->chart_context()->set_local_table(true);//пока пользуем кэш ....
|
||||
bool bConvertLocal = false;
|
||||
if (media.IsInit() && NSFile::CFileBinary::Exists(media->filename().GetPath()))
|
||||
{
|
||||
std::wstring sTempUnpackedXLSX = odf_context()->temp_path_ + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
|
||||
NSDirectory::CreateDirectory(sTempUnpackedXLSX);
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK == oCOfficeUtils.ExtractToDirectory(media->filename().GetPath(), sTempUnpackedXLSX, NULL, 0))
|
||||
{
|
||||
XlsxConverter converter(sTempUnpackedXLSX, false);
|
||||
odf_writer::office_element_ptr local_table = converter.convert_sheet(0, L"local-table");
|
||||
if (local_table)
|
||||
{
|
||||
odf_context()->chart_context()->set_local_table(local_table);
|
||||
bConvertLocal = true;
|
||||
}
|
||||
}
|
||||
NSDirectory::DeleteDirectory(sTempUnpackedXLSX);
|
||||
}
|
||||
|
||||
if (!bConvertLocal)
|
||||
{
|
||||
odf_context()->chart_context()->set_local_table(true);//пока пользуем кэш ....
|
||||
}
|
||||
}
|
||||
void OoxConverter::convert(OOX::Spreadsheet::CT_NumData *num_data, bool categories, bool label)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Oox2Odf
|
||||
class Converter
|
||||
{
|
||||
public:
|
||||
Converter(const std::wstring & path, const std::wstring & type, const std::wstring & fontsPath, bool bTemplate);
|
||||
Converter(const std::wstring & path, const std::wstring & type, const std::wstring & fontsPath, bool bTemplate, const std::wstring & tempPath);
|
||||
virtual ~Converter();
|
||||
|
||||
bool convert();
|
||||
|
||||
@ -179,6 +179,21 @@ bool XlsxConverter::convertDocument()
|
||||
|
||||
return true;
|
||||
}
|
||||
odf_writer::office_element_ptr XlsxConverter::convert_sheet(int id, const std::wstring &table_name)
|
||||
{
|
||||
if (!xlsx_document) return odf_writer::office_element_ptr();
|
||||
if (id < 0 && id > (int)xlsx_document->m_arWorksheets.size()) return odf_writer::office_element_ptr();
|
||||
|
||||
ods_context->create_object();
|
||||
ods_context->start_sheet();
|
||||
ods_context->current_table()->set_table_name(table_name);
|
||||
|
||||
convert(xlsx_document->m_arWorksheets[id]);
|
||||
ods_context->end_sheet();
|
||||
ods_context->end_object();
|
||||
|
||||
return ods_context->get_current_object_element();
|
||||
}
|
||||
|
||||
void XlsxConverter::convert_sheets()
|
||||
{
|
||||
|
||||
@ -168,6 +168,8 @@ namespace Oox2Odf
|
||||
void convert_styles();
|
||||
void convert();
|
||||
|
||||
odf_writer::office_element_ptr convert_sheet(int id, const std::wstring &table_name);
|
||||
|
||||
void convert(OOX::Spreadsheet::CWorksheet *oox_sheet);
|
||||
void convert(OOX::Spreadsheet::CDefinedName *oox_defined);
|
||||
void convert(OOX::Spreadsheet::CTable *oox_table_part);
|
||||
|
||||
@ -1824,11 +1824,23 @@ void odf_chart_context::set_cash(std::wstring format_code, std::vector<std::wstr
|
||||
}
|
||||
}
|
||||
}
|
||||
void odf_chart_context::set_local_table(office_element_ptr & table_elm)
|
||||
{
|
||||
if (!table_elm) return;
|
||||
|
||||
impl_->current_level_[0].elm->add_child_element(table_elm);
|
||||
size_t level = impl_->current_level_.size();
|
||||
|
||||
odf_element_state state(table_elm, L"", office_element_ptr(), level + 1);
|
||||
impl_->current_chart_state_.elements_.push_back(state);
|
||||
|
||||
impl_->local_table_enabled_ = false;
|
||||
impl_->local_table_reset_ref_ = false;
|
||||
}
|
||||
void odf_chart_context::set_local_table (bool Val, bool use_cash_only)
|
||||
{
|
||||
impl_->local_table_enabled_ = Val;
|
||||
impl_->local_table_reset_ref_ = use_cash_only;
|
||||
impl_->local_table_enabled_ = Val;
|
||||
impl_->local_table_reset_ref_ = use_cash_only;
|
||||
}
|
||||
|
||||
struct _sort_cells
|
||||
@ -2012,7 +2024,7 @@ void odf_chart_context::Impl::create_local_table()
|
||||
//create tables
|
||||
|
||||
office_element_ptr table_elm;
|
||||
create_element(L"table", L"table",table_elm, odf_context_);
|
||||
create_element(L"table", L"table", table_elm, odf_context_);
|
||||
ods_table_state * table_state = new ods_table_state(odf_context_, table_elm);
|
||||
|
||||
if (table_state)
|
||||
|
||||
@ -156,6 +156,8 @@ public:
|
||||
void set_layout_w(double val,int mode);
|
||||
void set_layout_h(double val,int mode);
|
||||
|
||||
void set_local_table(office_element_ptr & table);
|
||||
|
||||
void set_local_table(bool Val, bool use_cash_only = false);
|
||||
void set_cash(std::wstring format, std::vector<std::wstring> &data, bool categories, bool label);
|
||||
|
||||
|
||||
@ -101,10 +101,14 @@ odf_conversion_context::~odf_conversion_context()
|
||||
}
|
||||
objects_.clear();
|
||||
}
|
||||
void odf_conversion_context::set_fonts_directory(std::wstring pathFonts)
|
||||
void odf_conversion_context::set_temp_directory(const std::wstring & tempPath)
|
||||
{
|
||||
temp_path_ = tempPath;
|
||||
}
|
||||
void odf_conversion_context::set_fonts_directory(const std::wstring & fontsPath)
|
||||
{
|
||||
if (applicationFonts_)
|
||||
applicationFonts_->InitializeFromFolder(pathFonts);
|
||||
applicationFonts_->InitializeFromFolder(fontsPath);
|
||||
}
|
||||
void odf_conversion_context::calculate_font_metrix(std::wstring name, double size, bool italic, bool bold)
|
||||
{
|
||||
@ -296,9 +300,9 @@ void odf_conversion_context::create_object(bool bAddContentExt)
|
||||
obj->style_context->set_odf_context(this);
|
||||
obj->settings_context->set_odf_context(this);
|
||||
|
||||
objects_.push_back(obj);
|
||||
objects_.push_back(obj);
|
||||
|
||||
current_object_ = objects_.size() - 1;
|
||||
current_object_ = objects_.size() - 1;
|
||||
}
|
||||
}
|
||||
void odf_conversion_context::end_chart()
|
||||
|
||||
@ -99,11 +99,14 @@ class odf_conversion_context : boost::noncopyable
|
||||
|
||||
public:
|
||||
const _office_type_document type;
|
||||
std::wstring temp_path_;
|
||||
|
||||
odf_conversion_context(_office_type_document type, package::odf_document * outputDocument);
|
||||
virtual ~odf_conversion_context();
|
||||
|
||||
void set_fonts_directory(std::wstring pathFonts);
|
||||
void set_fonts_directory(const std::wstring & fontsPath);
|
||||
void set_temp_directory(const std::wstring & tempPath);
|
||||
|
||||
void add_font(const std::wstring & font_name);
|
||||
|
||||
virtual void start_document() = 0 ;
|
||||
@ -184,23 +187,6 @@ private:
|
||||
void process_settings (_object & object, bool isRoot);
|
||||
|
||||
int current_object_;
|
||||
|
||||
//page_layout_container & pageLayoutContainer() { return page_layout_container_; }
|
||||
//fonts_container & fontContainer() { return fonts_container_; }
|
||||
//list_style_container & listStyleContainer() { return list_style_container_; }
|
||||
|
||||
//notes_configuration & noteConfiguration() { return notes_configuration_; }
|
||||
|
||||
//styles_lite_container & Templates() { return template_container_; }
|
||||
|
||||
|
||||
//styles_container major_style_container_;
|
||||
//page_layout_container page_layout_container_;
|
||||
//fonts_container fonts_container_;
|
||||
//list_style_container list_style_container_;
|
||||
//notes_configuration notes_configuration_;
|
||||
|
||||
//styles_lite_container template_container_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
ods_conversion_context::ods_conversion_context(package::odf_document* outputDocument)
|
||||
: odf_conversion_context(SpreadsheetDocument, outputDocument), table_context_(*this)
|
||||
: odf_conversion_context(SpreadsheetDocument, outputDocument), table_context_(*this), root_spreadsheet_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -120,11 +120,19 @@ void ods_conversion_context::add_header_footer_image(const std::wstring & name,
|
||||
}
|
||||
void ods_conversion_context::start_sheet()
|
||||
{
|
||||
create_element(L"table", L"table", root_spreadsheet_->getContent(), this);
|
||||
table_context_.start_table(root_spreadsheet_->getContent().back());
|
||||
if (root_spreadsheet_)
|
||||
{
|
||||
create_element(L"table", L"table", root_spreadsheet_->getContent(), this);
|
||||
table_context_.start_table(root_spreadsheet_->getContent().back());
|
||||
}
|
||||
else
|
||||
{
|
||||
create_element(L"table", L"table", get_current_object_element(), this);
|
||||
table_context_.start_table(get_current_object_element());
|
||||
}
|
||||
|
||||
drawing_context()->set_styles_context(styles_context());
|
||||
page_layout_context()->set_styles_context(styles_context());
|
||||
drawing_context()->set_styles_context(styles_context());
|
||||
page_layout_context()->set_styles_context(styles_context());
|
||||
|
||||
page_layout_context()->add_master_page(L"");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user