Commit b8b8e97e authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

docx->odt разметка страниц, свойства страниц, поравлены разрывы в колонках, секциях

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57342 954022d7-b5bf-4e40-9824-e11837661b57
parent dbf9b4a9
......@@ -564,18 +564,17 @@ void common_horizontal_pos_attlist::serialize(CP_ATTR_NODE)
void common_num_format_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:num-format", style_num_format_, std::wstring(L""));
CP_APPLY_ATTR(L"style:num-format", style_num_format_);
CP_APPLY_ATTR(L"style:num-letter-sync", style_num_letter_sync_);
}
void common_num_format_attlist::apply_from(const common_num_format_attlist & Other)
{
if (!Other.style_num_format_.empty())
style_num_format_ = Other.style_num_format_;
_CP_APPLY_PROP2(style_num_format_);
_CP_APPLY_PROP2(style_num_letter_sync_);
}
void common_num_format_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR(L"style:num-format", style_num_format_);
CP_XML_ATTR_OPT(L"style:num-format", style_num_format_);
CP_XML_ATTR_OPT(L"style:num-letter-sync", style_num_letter_sync_);
}
......
......@@ -325,7 +325,7 @@ public:
void serialize(CP_ATTR_NODE);
public:
std::wstring style_num_format_;
_CP_OPT(std::wstring) style_num_format_;
_CP_OPT(Bool) style_num_letter_sync_;
};
......
#pragma once
typedef void (*OnProgressCallback)( void* lpParam, long nID, long nPercent );
typedef void (*OnProgressExCallback)( void* lpParam, long nID, long nPercent, short* Cancel );
struct ProgressCallback
{
OnProgressCallback OnProgress;
OnProgressExCallback OnProgressEx;
void* caller;
};
......@@ -258,10 +258,6 @@
RelativePath=".\OfficeOdfFileW.h"
>
</File>
<File
RelativePath=".\source\progressCallback.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
......
......@@ -79,7 +79,7 @@ void odf_page_layout_context::create_layout_page()
std::wstring odf_name = style_context_->find_free_name(style_family::PageLayout);
if (!elm) return;
style_context_->add_style(elm, true, true);
style_context_->add_style(elm, true, true, style_family::PageLayout);
layout_state_list_.push_back( odf_layout_state(elm) );
///////////////////////////////////////
......@@ -89,15 +89,7 @@ void odf_page_layout_context::create_layout_page()
void odf_page_layout_context::set_page_margin(_CP_OPT(double) top, _CP_OPT(double) left, _CP_OPT(double) bottom, _CP_OPT(double) right, _CP_OPT(double) header, _CP_OPT(double) footer)
{
if (layout_state_list_.size() < 1) return;
style_page_layout_properties * props = layout_state_list_.back().get_properties();
if (props == NULL)
{
office_element_ptr elm;
create_element(L"style", L"page-layout-properties", elm, odf_context_);
layout_state_list_.back().add_child(elm, office_element_ptr(),L"");
props = layout_state_list_.back().get_properties();
}
style_page_layout_properties * props = get_properties();
if (!props)return;
if (top)
......@@ -113,10 +105,46 @@ void odf_page_layout_context::set_page_margin(_CP_OPT(double) top, _CP_OPT(doubl
props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
length(length(*right,length::inch).get_value_unit(length::cm),length::cm);
}
void odf_page_layout_context::set_page_margin(_CP_OPT(length) top, _CP_OPT(length) left, _CP_OPT(length) bottom, _CP_OPT(length) right)
{
style_page_layout_properties * props = get_properties();
if (!props)return;
void odf_page_layout_context::set_page_orientation(int type)
if (top)
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_ =
length(top->get_value_unit(length::cm),length::cm);
if (bottom)
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_=
length(bottom->get_value_unit(length::cm),length::cm);
if (left)
props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_left_ =
length(left->get_value_unit(length::cm),length::cm);
if (right)
props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
length(right->get_value_unit(length::cm),length::cm);
//if (header)
// props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
// length(header->get_value_unit(length::cm),length::cm);
//if (footer)
// props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
// length(footer->get_value_unit(length::cm),length::cm);
}
void odf_page_layout_context::set_page_size(_CP_OPT(length) width, _CP_OPT(length) height)
{
style_page_layout_properties * props = get_properties();
if (!props)return;
if (width)
props->style_page_layout_properties_attlist_.fo_page_width_ =
length(width->get_value_unit(length::cm),length::cm);
if (height)
props->style_page_layout_properties_attlist_.fo_page_height_ =
length(height->get_value_unit(length::cm),length::cm);
}
style_page_layout_properties * odf_page_layout_context::get_properties()
{
if (layout_state_list_.size() < 1) return;
if (layout_state_list_.size() < 1) return NULL;
style_page_layout_properties * props = layout_state_list_.back().get_properties();
if (props == NULL)
{
......@@ -125,9 +153,14 @@ void odf_page_layout_context::set_page_orientation(int type)
layout_state_list_.back().add_child(elm, office_element_ptr(),L"");
props = layout_state_list_.back().get_properties();
}
return props;
}
void odf_page_layout_context::set_page_orientation(int type)
{
style_page_layout_properties * props = get_properties();
if (!props)return;
if (type == 2)
if (type == 0)
props->style_page_layout_properties_attlist_.style_print_orientation_ = L"landscape";
else
props->style_page_layout_properties_attlist_.style_print_orientation_ = L"portrait";
......
......@@ -3,7 +3,7 @@
#include <string>
#include "odf_page_layout_state.h"
#include "length.h"
namespace cpdoccore {
namespace odf {
......@@ -30,10 +30,14 @@ public:
odf_master_state & last_master();
void set_page_margin(_CP_OPT(double) top, _CP_OPT(double) left, _CP_OPT(double) bottom, _CP_OPT(double) right, _CP_OPT(double) header, _CP_OPT(double) footer);
void set_page_margin(_CP_OPT(length) top, _CP_OPT(length) left, _CP_OPT(length) bottom, _CP_OPT(length) right);
void set_page_orientation(int type);
void set_page_size(_CP_OPT(length) width, _CP_OPT(length) height);
private:
style_page_layout_properties *get_properties();
odf_conversion_context * odf_context_;
odf_style_context * style_context_;
......
......@@ -62,7 +62,7 @@ odf_layout_state::odf_layout_state(office_element_ptr & layout_elm )
odf_element_state state = {layout_elm,L"",office_element_ptr(),level};
elements_.push_back(state);
current_level_.push_back(layout_elm);
}
void odf_layout_state::add_child(office_element_ptr & child_elm, office_element_ptr style_elm, std::wstring style_name )
......
......@@ -78,7 +78,7 @@ void odf_style_state::set_parent_style_name(std::wstring & name)
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return;
if (name == style_->style_name_)
if (name == style_->style_name_ || name.length() <1)
return;
style_->style_parent_style_name_ = name;
}
......
......@@ -28,8 +28,6 @@ odf_text_context::odf_text_context(odf_conversion_context *odf_context)
paragraph_properties_ = NULL;
text_properties_ = NULL;
last_paragraph_ = NULL;
current_outline_ = 0;
}
odf_text_context::~odf_text_context()
......@@ -45,6 +43,13 @@ void odf_text_context::set_single_object(bool val, style_paragraph_properties *p
single_paragraph_ = val;
paragraph_properties_ = para_props;
text_properties_ = text_props;
//if (paragraph_properties_)//??? - ???
//{
// paragraph_properties_->content().fo_break_before_ = need_break_;
// need_break_ = boost::none;
//}
}
void odf_text_context::add_text_content(const std::wstring & text)
......@@ -54,13 +59,13 @@ void odf_text_context::add_text_content(const std::wstring & text)
// office_element_ptr elm;
// create_element(L"text", L"s", elm, odf_context_);
// current_level_.back()->add_child_element(elm);
// current_level_.back().elm->add_child_element(elm);
//}
//else
{
if (current_level_.size() > 0 )
current_level_.back()->add_text(text);
current_level_.back().elm->add_text(text);
}
}
......@@ -118,7 +123,7 @@ void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
{
if (parent_paragraph_style_.length() >0)style_->style_parent_style_name_ = parent_paragraph_style_;
paragraph_properties_ = style_->style_content_.get_style_paragraph_properties();//
paragraph_properties_ = style_->style_content_.get_style_paragraph_properties();
}
}
else if (parent_paragraph_style_.length() >0)
......@@ -129,13 +134,15 @@ void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
text_h* h = dynamic_cast<text_h*>(elm.get());
if (h)p->paragraph_.paragraph_attrs_.text_style_name_ = style_ref(parent_paragraph_style_);
}
if (paragraph_properties_)paragraph_properties_->content().fo_break_before_ = need_break_;
need_break_ = boost::none;
odf_text_state state={elm, style_name, style_elm,level};
odf_element_state state={elm, style_name, style_elm,level};
text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
current_level_.back().elm->add_child_element(elm);
current_level_.push_back(elm);
current_level_.push_back(state);
}
......@@ -148,17 +155,17 @@ void odf_text_context::end_paragraph()
paragraph_properties_ = NULL;
}
void odf_text_context::start_element(office_element_ptr & elm)
void odf_text_context::start_element(office_element_ptr & elm, office_element_ptr style_elm ,std::wstring style_name)
{
int level = current_level_.size();
odf_text_state state={elm, L"", office_element_ptr(), level};
odf_element_state state={elm, style_name, style_elm, level};
text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
current_level_.back().elm->add_child_element(elm);
current_level_.push_back(elm);
current_level_.push_back(state);
}
void odf_text_context::end_element()
{
......@@ -204,14 +211,14 @@ void odf_text_context::start_span(bool styled)
}
}
odf_text_state state={ span_elm, style_name, style_elm, level};
odf_element_state state={ span_elm, style_name, style_elm, level};
text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back()->add_child_element(span_elm);
current_level_.back().elm->add_child_element(span_elm);
current_level_.push_back(span_elm);
current_level_.push_back(state);
}
void odf_text_context::end_span()
......@@ -223,14 +230,6 @@ void odf_text_context::end_span()
text_properties_ = NULL;
}
void odf_text_context::add_textline_break()
{
office_element_ptr elm;
create_element(L"text", L"line-break", elm, odf_context_);
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
}
void odf_text_context::set_outline_level(int level)
{
......@@ -243,17 +242,17 @@ void odf_text_context::add_text_style(office_element_ptr & style_elm, std::wstri
if (current_level_.size() < 1 )return;
if (text_span* span = dynamic_cast<text_span*>(current_level_.back().get()))
if (text_span* span = dynamic_cast<text_span*>(current_level_.back().elm.get()))
{
span->text_style_name_ = style_ref(style_name);
}
if (text_p* p = dynamic_cast<text_p*>(current_level_.back().get()))
if (text_p* p = dynamic_cast<text_p*>(current_level_.back().elm.get()))
{
p->paragraph_.paragraph_attrs_.text_style_name_ = style_ref(style_name);
}
if (text_h* h = dynamic_cast<text_h*>(current_level_.back().get()))
if (text_h* h = dynamic_cast<text_h*>(current_level_.back().elm.get()))
{
h->paragraph_.paragraph_attrs_.text_style_name_ = style_ref(style_name);
}
......@@ -264,47 +263,61 @@ void odf_text_context::add_tab()
create_element(L"text", L"tab", elm, odf_context_);
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
current_level_.back().elm->add_child_element(elm);
}
void odf_text_context::add_page_break()
{
// office_element_ptr elm;
//office_element_ptr elm;
//create_element(L"text", L"soft-page-break", elm, odf_context_);
//bool in_span = false;
//if (text_span* span = dynamic_cast<text_span*>(current_level_.back().get()))
//
//if (current_level_.size()>0)
//{
// in_span = true;
// end_span(); // todoo -
// text_p* para = NULL;
// //http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415190_253892949
// // !! span, ... !!
// if (para = dynamic_cast<text_p*>(current_level_.back().elm.get()))
// {
// end_paragraph();
// }
// current_level_.back().elm->add_child_element(elm);
// if (para)
// {
// bool styled = para->paragraph_.paragraph_attrs_.text_style_name_ ? true : false;
// start_paragraph(styled);
// }
//}
}
void odf_text_context::add_break(int type, int clear)
{
//brclearAll = 0,
//brclearLeft = 1,
//brclearNone = 2,
//brclearRight = 3
//bool in_paragraph = false;
//if (text_p* p = dynamic_cast<text_p*>(current_level_.back().get()))
//{
// in_paragraph = true;
////fo:break-before
//brtypeColumn = 0,
//brtypePage = 1,
//brtypeTextWrapping = 2
if (paragraph_properties_) paragraph_properties_->content().fo_break_before_ = fo_break(fo_break::Page);
if (type == 0)
{
need_break_= fo_break(fo_break::Column);
}
else if (type == 1)
{
need_break_ = fo_break(fo_break::Page);
}
else
{
office_element_ptr elm;
create_element(L"text", L"line-break", elm, odf_context_);
//if (current_level_.size()>0)
// current_level_.back()->add_child_element(elm);
// end_paragraph(); // todoo -
//}
if (current_level_.size()>0)
current_level_.back().elm->add_child_element(elm);
}
////end paragraph + style add after-break = page
////start paragraph - continues style
//if (in_paragraph)
//{
//// start_paragraph(false);
//
// //if (current_level_.size()>0)
// // current_level_.back()->add_child_element(elm);
//}
//if (in_span)
//{
// start_span(false);
//}
}
void odf_text_context::set_parent_paragraph_style(std::wstring & style_name)
{
parent_paragraph_style_ = style_name;
......
......@@ -2,7 +2,8 @@
#include <string>
#include <vector>
//
#include "odf_page_layout_state.h"
//#include "ods_drawing_context.h"
//#include "ods_comments_context.h"
//#include "ods_hyperlinks.h"
......@@ -10,6 +11,7 @@
#include "office_elements.h"
#include "office_elements_create.h"
#include "fobreak.h"
namespace cpdoccore {
namespace odf
......@@ -21,16 +23,6 @@ class paragraph;
class style_paragraph_properties;
class style_text_properties;
struct odf_text_state
{
office_element_ptr elm;
std::wstring style_name;
office_element_ptr style_elm;
int level;
};
class odf_text_context: boost::noncopyable
{
public:
......@@ -48,21 +40,20 @@ public:
void start_paragraph(office_element_ptr & elm, bool styled = false);
void end_paragraph();
void start_element(office_element_ptr & elm);
void start_element(office_element_ptr & elm, office_element_ptr style_elm = office_element_ptr(),std::wstring style_name = L"");
void end_element();
void start_span(bool styled = false);
void end_span();
void add_textline_break();
void add_break(int type, int clear);
void add_page_break();
void add_tab();
int current_outline_;
std::vector<office_element_ptr> current_level_;//
std::vector<odf_text_state> text_elements_list_;//, , ...
std::vector<odf_element_state> current_level_;//
std::vector<odf_element_state> text_elements_list_;//, , ...
void set_parent_paragraph_style (std::wstring & style_name);
void set_parent_span_style (std::wstring & style_name);
......@@ -72,11 +63,12 @@ public:
void set_outline_level(int level);
private:
_CP_OPT(fo_break) need_break_;
bool single_paragraph_;
style_paragraph_properties *paragraph_properties_;//- , ,
style_text_properties *text_properties_;//- , ,
paragraph * last_paragraph_;
odf_style_context * styles_context_;
odf_conversion_context *odf_context_;
......
......@@ -58,6 +58,8 @@ void odt_conversion_context::start_document()
root_text_ = dynamic_cast<office_text*>(root_document_.get());
main_text_context_ = new odf_text_context(this);
page_layout_context()->set_styles_context(styles_context());
//current_level_.push_back(get_current_object_element());
/////////////////
......@@ -77,7 +79,7 @@ void odt_conversion_context::end_document()
//add last elements to root
for (long i=0; i< current_root_elements_.size(); i++)
{
root_document_->add_child_element(current_root_elements_[i]);
root_document_->add_child_element(current_root_elements_[i].elm);
}
current_root_elements_.clear();
......@@ -156,8 +158,8 @@ void odt_conversion_context::add_to_root()
if (text_context()->current_level_.size() > 1) return;
office_element_ptr & elm = text_context()->current_level_.back();
current_root_elements_.push_back(elm);
odf_element_state & state = text_context()->current_level_.back();
current_root_elements_.push_back(state);
}
void odt_conversion_context::start_drawings()
{
......@@ -175,12 +177,9 @@ void odt_conversion_context::end_drawings()
office_element_ptr & elm = drawing_context()->get_root_element();
if (elm )
{
//if (current_root_elements_.size() >0)
// current_root_elements_.back()->add_child_element(elm);
text_context()->current_level_.back()->add_child_element(elm);
text_context()->current_level_.back().elm->add_child_element(elm);
}
//current_level_.back()->add_child_element(elm);
drawing_context()->clear();
drawing_context_.pop_back();
......@@ -190,10 +189,35 @@ void odt_conversion_context::start_paragraph(bool styled)
text_context()->start_paragraph(styled);
add_to_root();
}
void odt_conversion_context::add_page_break()
{
office_element_ptr elm;
create_element(L"text", L"soft-page-break", elm, this);
if (current_root_elements_.size()>0)
{
text_p* para = NULL;
//http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415190_253892949
// !! span, ... !!
if (para = dynamic_cast<text_p*>(current_root_elements_.back().elm.get()))
{
end_paragraph();
}
text_context()->start_element(elm);
add_to_root();
text_context()->end_element();
if (para)
{
std::wstring parent_style_name = para->paragraph_.paragraph_attrs_.text_style_name_.get_value_or(style_ref(L"")).style_name();
styles_context()->create_style(L"",odf::style_family::Paragraph, true, false, -1);
styles_context()->last_state().set_parent_style_name(parent_style_name);
start_paragraph(true);
}
}
}
void odt_conversion_context::start_hyperlink(std::wstring ref)
{
office_element_ptr hyperlink_elm;
......@@ -254,6 +278,15 @@ void odt_conversion_context::start_field()
current_field_.type = 0;
}
void odt_conversion_context::set_master_page_name(std::wstring master_name)
{
if (current_root_elements_.size() < 1) return;
style *style_ = dynamic_cast<style*>(current_root_elements_[0].style_elm.get());
if (style_)style_->style_master_page_name_ = master_name;
}
void odt_conversion_context::add_section()
{
odt_section_state state;
......@@ -307,9 +340,12 @@ void odt_conversion_context::add_section_column(std::vector<std::pair<double,dou
if (!style_)return;
style_section_properties * section_properties = style_->style_content_.get_style_section_properties();
section_properties->text_dont_balance_text_columns_ = true;
style_columns* columns = dynamic_cast<style_columns*>(section_properties->style_columns_.get());
if (!columns)return;
//office_element_ptr col_elm;
//
//create_element(L"style", L"column",col_elm,this);
......@@ -328,13 +364,16 @@ void odt_conversion_context::end_field()
void odt_conversion_context::end_paragraph()
{
text_context()->end_paragraph();
///////////////////
flush_section();
}
void odt_conversion_context::flush_section()
{
if (sections_.size() > 0 && sections_.back().empty)
{
for (long i=0; i< current_root_elements_.size(); i++)
{
sections_.back().elm->add_child_element(current_root_elements_[i]);
sections_.back().elm->add_child_element(current_root_elements_[i].elm);
}
current_root_elements_.clear();
......@@ -370,8 +409,10 @@ bool odt_conversion_context::start_comment(int oox_comm_id)
comment_context_.start_comment(comm_elm, oox_comm_id);
text_context()->current_level_.back()->add_child_element(comm_elm);
text_context()->current_level_.push_back(comm_elm);
text_context()->current_level_.back().elm->add_child_element(comm_elm);
odf_element_state state={comm_elm, L"", office_element_ptr(),text_context()->current_level_.size()};
text_context()->current_level_.push_back(state);
//current_level_.back()->add_child_element(comm_elm);
//current_level_.push_back(comm_elm);
}
......@@ -401,7 +442,8 @@ void odt_conversion_context::end_comment(int oox_comm_id)
comment_context_.end_comment(comm_elm, oox_comm_id);
//current_level_.back()->add_child_element(comm_elm);
text_context()->current_level_.back()->add_child_element(comm_elm);
odf_element_state state={comm_elm, L"", office_element_ptr(),text_context()->current_level_.size()};
text_context()->current_level_.push_back(state);
}
}
void odt_conversion_context::start_image(std::wstring & image_file_name)
......@@ -477,7 +519,19 @@ void odt_conversion_context::start_table(bool styled)
create_element(L"table", L"table",elm,this);
table_context()->start_table(elm, styled);
text_context()->start_element(elm);
office_element_ptr style_elm;
std::wstring style_name;
if (styled)
{
odf_style_state * style_state = styles_context()->last_state(style_family::Table);
if (style_state)
{
style_elm = style_state->get_office_element();
style_name = style_state->get_name();
}
}
text_context()->start_element(elm,style_elm,style_name);
add_to_root();
}
......
......@@ -51,6 +51,8 @@ public:
void start_paragraph(bool styled = false);
void end_paragraph();
void add_page_break();
void start_hyperlink(std::wstring ref);
void end_hyperlink();
......@@ -64,6 +66,9 @@ public:
void add_section();
void add_section_columns(int count, double space_pt, bool separator );
void add_section_column(std::vector<std::pair<double,double>> width_space);
void flush_section();
void set_master_page_name(std::wstring master_name);
void start_drop_cap(style_paragraph_properties * paragraph_properties);
void set_drop_cap_lines(int lines);
......@@ -102,7 +107,7 @@ private:
std::vector<odf_drawing_context_ptr> drawing_context_;
std::vector<odf_text_context_ptr> text_context_;//for embedded
std::vector<office_element_ptr> current_root_elements_; // for section, if needed
std::vector<odf_element_state> current_root_elements_; // for section, if needed
std::vector<odt_section_state> sections_;
void add_to_root();
......
......@@ -32,25 +32,10 @@ public:
class paragraph
{
public:
paragraph() : next_par_(NULL), next_section_(false), next_end_section_(false) {}
paragraph() {}
public:
//void afterCreate(odf_text_context * ctx);
paragraph * get_next() { return next_par_; }
void set_next(paragraph * next) {next_par_ = next;}
void set_prev(paragraph * prev) {prev_par_ = prev;}
void set_next_section(bool Val)
{
next_section_ = Val;
}
void set_next_end_section(bool Val)
{
next_end_section_ = Val;
}
void add_text(const std::wstring & Text);
void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name,odf_conversion_context * context);
......@@ -63,10 +48,6 @@ public:
office_element_ptr_array paragraph_content_;
paragraph * prev_par_;
paragraph * next_par_;
bool next_section_;
bool next_end_section_;
};
// text:h
......
......@@ -137,10 +137,13 @@ void DocxConverter::convert_document()
const OOX::CDocument* document = docx_document->GetDocument();
if (!document)return;
convert(document->m_oBackground.GetPointer());//
for ( int nIndex = 0; nIndex < document->m_arrItems.GetSize(); nIndex++ )
{
convert(document->m_arrItems[nIndex]);
}
convert(document->m_oSectPr.GetPointer(),true);
}
void DocxConverter::convert(OOX::WritingElement *oox_unknown)
{
......@@ -208,11 +211,6 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CCommentReference* pCommRef = static_cast<OOX::Logic::CCommentReference*>(oox_unknown);
convert(pCommRef); // Start - Run
}break;
case OOX::et_w_sectPr:
{
OOX::Logic::CSectionProperty *pSectionPr = static_cast<OOX::Logic::CSectionProperty*>(oox_unknown);
convert(pSectionPr, true);
}break;
case OOX::et_w_tbl:
{
OOX::Logic::CTbl* pTable= static_cast<OOX::Logic::CTbl*>(oox_unknown);
......@@ -303,7 +301,14 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
convert(oox_run->m_oRunProperty, text_properties);
}
//test for break - 2 first element !!!
for(int i = 0; i < min (2,oox_run->m_arrItems.GetSize()); ++i)
{
if (oox_run->m_arrItems[i]->getType() == OOX::et_w_lastRenderedPageBreak)
{
odt_context->add_page_break();
}
}
odt_context->start_run(styled);
for(int i = 0; i < oox_run->m_arrItems.GetSize(); ++i)
......@@ -327,11 +332,12 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
}break;
case OOX::et_w_lastRenderedPageBreak:
{
odt_context->text_context()->add_page_break();
//odt_context->text_context()->add_page_break();
}break;
case OOX::et_w_br:
{
odt_context->text_context()->add_textline_break();
OOX::Logic::CBr* pBr= static_cast<OOX::Logic::CBr*>(oox_run->m_arrItems[i]);
if (pBr)odt_context->text_context()->add_break(pBr->m_oType.GetValue(), pBr->m_oClear.GetValue());
}break;
case OOX::et_w_t:
{
......@@ -557,8 +563,58 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root)
{
if (oox_section_pr == NULL) return;
if (root) return;
bool needGenerateSection = true; //
odt_context->page_layout_context()->create_master_page(L"");
odt_context->set_master_page_name(odt_context->page_layout_context()->last_master().get_name());
if (oox_section_pr->m_oPgMar.IsInit())
{
_CP_OPT(odf::length) top, left, right, bottom;
convert(oox_section_pr->m_oPgMar->m_oBottom.GetPointer(), bottom);
convert(oox_section_pr->m_oPgMar->m_oLeft.GetPointer() , left);
convert(oox_section_pr->m_oPgMar->m_oRight.GetPointer() , right);
convert(oox_section_pr->m_oPgMar->m_oTop.GetPointer() , top);
odt_context->page_layout_context()->set_page_margin(top,left,bottom, right);
//nullable<SimpleTypes::CTwipsMeasure > m_oFooter;
//nullable<SimpleTypes::CTwipsMeasure > m_oGutter;
//nullable<SimpleTypes::CTwipsMeasure > m_oHeader;
}
if (oox_section_pr->m_oPgSz.IsInit())
{
if (oox_section_pr->m_oPgSz->m_oOrient.IsInit())
odt_context->page_layout_context()->set_page_orientation(oox_section_pr->m_oPgSz->m_oOrient->GetValue());
_CP_OPT(odf::length) width, height;
convert(oox_section_pr->m_oPgSz->m_oW.GetPointer(), width);
convert(oox_section_pr->m_oPgSz->m_oH.GetPointer(), height);
odt_context->page_layout_context()->set_page_size(width, height);
//nullable<SimpleTypes::CDecimalNumber<> > m_oCode;
}
//nullable<ComplexTypes::Word::CTextDirection > m_oTextDirection;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oRtlGutter;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
// +
//CSimpleArray<ComplexTypes::Word::CHdrFtrRef > m_arrFooterReference;
//CSimpleArray<ComplexTypes::Word::CHdrFtrRef > m_arrHeaderReference;
//nullable<ComplexTypes::Word::CPageMar > m_oPgMar;
//nullable<ComplexTypes::Word::CPageNumber > m_oPgNumType;
//nullable<ComplexTypes::Word::CPageSz > m_oPgSz;
//nullable<OOX::Logic::CPageBorders > m_oPgBorders;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oTitlePg;
//master page create
// add colontitul
// style name master page -> 0-
//--------------------------------------------------------------------------------------------------------------------------------------------
//
if (oox_section_pr->m_oType.IsInit() && oox_section_pr->m_oType->m_oVal.IsInit())
{
switch(oox_section_pr->m_oType->m_oVal->GetValue())
......@@ -568,34 +624,31 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
case SimpleTypes::sectionmarkEvenPage :
case SimpleTypes::sectionmarkNextPage :
case SimpleTypes::sectionmarkOddPage :
odt_context->add_section();
needGenerateSection = false; //???
break;
}
}
odt_context->add_section();
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oBidi;
//nullable<ComplexTypes::Word::CDocGrid > m_oDocGrid;
//nullable<OOX::Logic::CEdnProps > m_oEndnotePr;
//CSimpleArray<ComplexTypes::Word::CHdrFtrRef > m_arrFooterReference;
//nullable<OOX::Logic::CFtnProps > m_oFootnotePr;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oFormProt;
//CSimpleArray<ComplexTypes::Word::CHdrFtrRef > m_arrHeaderReference;
//nullable<ComplexTypes::Word::CLineNumber > m_oLnNumType;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oNoEndnote;
//nullable<ComplexTypes::Word::CPaperSource > m_oPaperSrc;
//nullable<OOX::Logic::CPageBorders > m_oPgBorders;
//nullable<ComplexTypes::Word::CPageMar > m_oPgMar;
//nullable<ComplexTypes::Word::CPageNumber > m_oPgNumType;
//nullable<ComplexTypes::Word::CPageSz > m_oPgSz;
//nullable<ComplexTypes::Word::CRel > m_oPrinterSettings;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oRtlGutter;
//nullable<OOX::Logic::CSectPrChange > m_oSectPrChange;
//nullable<ComplexTypes::Word::CTextDirection > m_oTextDirection;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oTitlePg;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
//--------------------------------------------------------------------------------------------------------------------------------------------
if (oox_section_pr->m_oCols.IsInit() && oox_section_pr->m_oCols->m_oNum.IsInit())
if (oox_section_pr->m_oCols.IsInit() && oox_section_pr->m_oCols->m_oNum.IsInit())//
{
if (needGenerateSection) odt_context->add_section(); // /???
int count = oox_section_pr->m_oCols->m_oNum->GetValue();
double default_space_pt = -1;
......@@ -624,6 +677,8 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
width_space.push_back(std::pair<double,double>(-1, default_space_pt));
}
odt_context->add_section_column(width_space);
if (root) odt_context->flush_section();
}
}
void DocxConverter::convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf::style_paragraph_properties * paragraph_properties)
......@@ -1692,7 +1747,6 @@ void DocxConverter::convert(OOX::Logic::CTblGrid *oox_table_grid)
}
odt_context->end_table_columns();
}
void DocxConverter::convert(OOX::Logic::CTr *oox_table_row)
{
if (oox_table_row == NULL) return;
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//92
#define INTVER 1,2,0,92
#define STRVER "1,2,0,92\0"
//93
#define INTVER 1,2,0,93
#define STRVER "1,2,0,93\0"
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