Commit 1e04770e authored by Alexey.Musinov's avatar Alexey.Musinov

Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop

* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  DocFormatReader - fix users file
  Revert "DocFormatReader - users file fix"
  DocFormatReader - users file fix OdfFormatReader - fix alphabetic text index
  DocFormatReaer - users file fix OdfFormatReader - fix alphabetic text index
  Removed version number
parents 6666ba02 6d75b03c
...@@ -87,19 +87,19 @@ namespace DocFileFormat ...@@ -87,19 +87,19 @@ namespace DocFileFormat
case sprmOldTDefTable: case sprmOldTDefTable:
case sprmTDefTable: case sprmTDefTable:
{ //table definition {
//table definition
SprmTDefTable tDef( iter->Arguments, iter->argumentsSize ); SprmTDefTable tDef( iter->Arguments, iter->argumentsSize );
//Workaround for retrieving the indent of the table: //Workaround for retrieving the indent of the table:
//In some files there is a indent but no sprmTWidthIndent is set. //In some files there is a indent but no sprmTWidthIndent is set.
//For this cases we can calculate the indent of the table by getting the //For this cases we can calculate the indent of the table by getting the
//first boundary of the TDef and adding the padding of the cells //first boundary of the TDef and adding the padding of the cells
tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ); tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
//add the gabHalf
tblIndent += gabHalf; tblIndent += gabHalf;
//If there follows a real sprmTWidthIndent, this value will be overwritten //If there follows a real sprmTWidthIndent, this value will be overwritten
tblIndent = (std::max)((int)tblIndent,0); //tblIndent = (std::max)((int)tblIndent,0); //cerere.doc
} }
break; break;
......
...@@ -845,6 +845,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str ...@@ -845,6 +845,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_) if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
&& !get_table_context().in_table() && !in_drawing) && !get_table_context().in_table() && !in_drawing)
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!! {//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
......
...@@ -866,11 +866,15 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio ...@@ -866,11 +866,15 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
if (attlists_.rel_size_.style_rel_width_) if (attlists_.rel_size_.style_rel_width_)
{ {
int type = attlists_.rel_size_.style_rel_width_->get_type(); int type = attlists_.rel_size_.style_rel_width_->get_type();
if (type == odf_types::percent_or_scale::Percent)
drawing.pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value(); drawing.pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value();
} }
if (attlists_.rel_size_.style_rel_height_ ) if (attlists_.rel_size_.style_rel_height_ )
{ {
int type = attlists_.rel_size_.style_rel_height_->get_type(); int type = attlists_.rel_size_.style_rel_height_->get_type();
if (type == odf_types::percent_or_scale::Percent)
drawing.pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value(); drawing.pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
} }
......
...@@ -115,13 +115,13 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex ...@@ -115,13 +115,13 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (style_rel_width_) if (style_rel_width_)
{ {
int w_w = (int)(0.5 + 50.0 * style_rel_width_->get_value()); int w_w = (int)(0.5 + 50.0 * style_rel_width_->get_value());
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"" << w_w << "\" />"; _tblPr << L"<w:tblW w:type=\"pct\" w:w=\"" << w_w << "\"/>";
} }
else if (style_width_) else if (style_width_)
{ {
int w_w = (int)(0.5 + 20.0 * style_width_->get_value_unit(length::pt)); int w_w = (int)(0.5 + 20.0 * style_width_->get_value_unit(length::pt));
if (w_w > 31680)w_w = 31680; if (w_w > 31680)w_w = 31680;
_tblPr << L"<w:tblW w:type=\"dxa\" w:w=\"" << w_w << "\" />"; _tblPr << L"<w:tblW w:type=\"dxa\" w:w=\"" << w_w << "\"/>";
} }
else else
{ {
...@@ -137,7 +137,7 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex ...@@ -137,7 +137,7 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (table_align_) if (table_align_)
{ {
std::wstring w_val = L"left"; std::wstring w_val = L"left";
if (table_align_->get_type() == table_align::Margins) if (table_align_->get_type() == table_align::Margins || table_align_->get_type() == table_align::Left)
{ {
if (common_horizontal_margin_attlist_.fo_margin_left_ && common_horizontal_margin_attlist_.fo_margin_right_) if (common_horizontal_margin_attlist_.fo_margin_left_ && common_horizontal_margin_attlist_.fo_margin_right_)
{ {
...@@ -147,19 +147,15 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex ...@@ -147,19 +147,15 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (w_val != L"center" && common_horizontal_margin_attlist_.fo_margin_left_ ) if (w_val != L"center" && common_horizontal_margin_attlist_.fo_margin_left_ )
{ {
odf_types::length indent = common_horizontal_margin_attlist_.fo_margin_left_->get_length(); odf_types::length indent = common_horizontal_margin_attlist_.fo_margin_left_->get_length();
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20<< "\" w:type=\"dxa\" />"; _tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\" />";
} }
} }
else else //if (table_align_->get_type() == table_align::Center)
w_val = boost::lexical_cast<std::wstring>(*table_align_); w_val = boost::lexical_cast<std::wstring>(*table_align_);
_tblPr << L"<w:jc w:val=\"" << w_val << "\" />"; _tblPr << L"<w:jc w:val=\"" << w_val << "\" />";
} }
if (table_align_ && table_align_->get_type() == table_align::Center)
{
// TODO ()
}
_tblPr << "<w:tblLayout w:type=\"fixed\" />"; _tblPr << "<w:tblLayout w:type=\"fixed\" />";
if (common_background_color_attlist_.fo_background_color_) if (common_background_color_attlist_.fo_background_color_)
......
...@@ -975,8 +975,38 @@ void text_table_index::add_child_element( xml::sax * Reader, const std::wstring ...@@ -975,8 +975,38 @@ void text_table_index::add_child_element( xml::sax * Reader, const std::wstring
const wchar_t * text_illustration_index::ns = L"text"; const wchar_t * text_illustration_index::ns = L"text";
const wchar_t * text_illustration_index::name = L"illustration-index"; const wchar_t * text_illustration_index::name = L"illustration-index";
void text_illustration_index::afterCreate()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_section(true);
}
}
}
void text_illustration_index::afterReadContent()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_end_section(true);
}
}
}
void text_illustration_index::docx_convert(oox::docx_conversion_context & Context) void text_illustration_index::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wstring current_page_properties = Context.get_page_properties();
Context.get_section_context().add_section(
text_section_attr_.text_name_,
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
current_page_properties
);
Context.add_page_properties(current_page_properties);
if (text_index_body_) if (text_index_body_)
text_index_body_->docx_convert(Context); text_index_body_->docx_convert(Context);
} }
...@@ -1005,8 +1035,77 @@ void text_illustration_index::add_child_element( xml::sax * Reader, const std::w ...@@ -1005,8 +1035,77 @@ void text_illustration_index::add_child_element( xml::sax * Reader, const std::w
{ {
CP_CREATE_ELEMENT(text_index_body_); CP_CREATE_ELEMENT(text_index_body_);
} }
// TODO text-illustration-index-source // todooo text-illustration-index-source
}
// text:alphabetical-index
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * text_alphabetical_index::ns = L"text";
const wchar_t * text_alphabetical_index::name = L"alphabetical-index";
void text_alphabetical_index::afterCreate()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_section(true);
}
}
}
void text_alphabetical_index::afterReadContent()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_end_section(true);
}
}
}
void text_alphabetical_index::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring current_page_properties = Context.get_page_properties();
Context.get_section_context().add_section(
text_section_attr_.text_name_,
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
current_page_properties
);
Context.add_page_properties(current_page_properties);
if (text_index_body_)
text_index_body_->docx_convert(Context);
}
void text_alphabetical_index::pptx_convert(oox::pptx_conversion_context & Context)
{
if (text_index_body_)
text_index_body_->pptx_convert(Context);
}
std::wostream & text_alphabetical_index::text_to_stream(std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(text_index_body_);
return _Wostream;
}
void text_alphabetical_index::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
text_section_attr_.add_attributes( Attributes );
}
void text_alphabetical_index::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"index-body")
{
CP_CREATE_ELEMENT(text_index_body_);
}
// todooo text-alphabetical-index-source
} }
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
// text:tracked-changes // text:tracked-changes
const wchar_t * text_tracked_changes::ns = L"text"; const wchar_t * text_tracked_changes::ns = L"text";
......
...@@ -361,6 +361,9 @@ public: ...@@ -361,6 +361,9 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
virtual void afterCreate();
virtual void afterReadContent();
void docx_convert(oox::docx_conversion_context & Context); void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ; void pptx_convert(oox::pptx_conversion_context & Context) ;
...@@ -377,6 +380,36 @@ public: ...@@ -377,6 +380,36 @@ public:
}; };
CP_REGISTER_OFFICE_ELEMENT2(text_illustration_index); CP_REGISTER_OFFICE_ELEMENT2(text_illustration_index);
//---------------------------------------------------------------------------------------------------
class text_alphabetical_index : public text_content_impl<text_alphabetical_index>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextAlphabeticalIndex;
CPDOCCORE_DEFINE_VISITABLE();
virtual void afterCreate();
virtual void afterReadContent();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
text_section_attr text_section_attr_;
office_element_ptr text_alphabetical_index_source_;
office_element_ptr text_index_body_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_alphabetical_index);
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
class text_index_body : public text_content_impl<text_index_body> class text_index_body : public text_content_impl<text_index_body>
......
[![License](https://img.shields.io/badge/License-GNU%20AGPL%20V3-green.svg?style=flat)](http://www.gnu.org/licenses/agpl-3.0.ru.html) ![Release](https://img.shields.io/badge/Release-v4.1.2-blue.svg?style=flat) ![x2tconverter](https://img.shields.io/badge/x2tconverter-v2.0.2.376-blue.svg?style=flat) ![Platforms Windows | OS X | Linux](https://img.shields.io/badge/Platforms-Windows%20%7C%20OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat) [![License](https://img.shields.io/badge/License-GNU%20AGPL%20V3-green.svg?style=flat)](http://www.gnu.org/licenses/agpl-3.0.ru.html) ![x2tconverter](https://img.shields.io/badge/x2tconverter-v2.0.2.376-blue.svg?style=flat) ![Platforms Windows | OS X | Linux](https://img.shields.io/badge/Platforms-Windows%20%7C%20OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat)
## Core ## Core
Server core components which are a part of [ONLYOFFICE Document Server][2]. Enable the conversion between the most popular office document formats: DOC, DOCX, ODT, RTF, TXT, PDF, HTML, EPUB, XPS, DjVu, XLS, XLSX, ODS, CSV, PPT, PPTX, ODP. Server core components which are a part of [ONLYOFFICE Document Server][2]. Enable the conversion between the most popular office document formats: DOC, DOCX, ODT, RTF, TXT, PDF, HTML, EPUB, XPS, DjVu, XLS, XLSX, ODS, CSV, PPT, PPTX, ODP.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment