Commit 16386f4b authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReaer - users file fix

OdfFormatReader - fix alphabetic text index
parent 149c0ae7
...@@ -94,12 +94,12 @@ namespace DocFileFormat ...@@ -94,12 +94,12 @@ namespace DocFileFormat
//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)
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!! {//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
......
...@@ -865,13 +865,15 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio ...@@ -865,13 +865,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();
drawing.pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value(); if (type == odf_types::percent_or_scale::Percent)
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();
drawing.pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value(); if (type == odf_types::percent_or_scale::Percent)
drawing.pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
} }
} }
......
...@@ -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_)
......
...@@ -187,7 +187,7 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co ...@@ -187,7 +187,7 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
Context.end_automatic_style(); Context.end_automatic_style();
Context.push_text_properties(styleContent->get_style_text_properties()); Context.push_text_properties(styleContent->get_style_text_properties());
return 1; return 1;
} }
} }
else else
...@@ -975,9 +975,39 @@ void text_table_index::add_child_element( xml::sax * Reader, const std::wstring ...@@ -975,9 +975,39 @@ 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)
{ {
if (text_index_body_) 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); 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";
......
...@@ -360,6 +360,9 @@ public: ...@@ -360,6 +360,9 @@ public:
static const ElementType type = typeTextIllustrationIndex; static const ElementType type = typeTextIllustrationIndex;
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>
......
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