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

(1.2.0.104): ASCOfficeOdfFileW

колонтитулы

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57526 954022d7-b5bf-4e40-9824-e11837661b57
parent 8616e524
......@@ -181,10 +181,11 @@ void odf_conversion_context::process_styles(_object & object, bool isRoot)
create_element(L"office", L"font-face-decls", object.styles, this,true);
create_element(L"office", L"automatic-styles", object.styles, this,true);
object.style_context->process_automatic_styles(object.styles.back());
object.style_context->process_automatic_for_styles(object.styles.back());
page_layout_context()->process_automatic_for_styles(object.styles.back());
create_element(L"office", L"master-styles", object.styles, this,true);
object.style_context->process_master(object.styles.back());
page_layout_context()->process_master_styles(object.styles.back());
create_element(L"office", L"font-face-decls", object.content_styles, this,true);
}
......
......@@ -49,9 +49,10 @@ public:
virtual void end_text_context() = 0;
virtual void start_image(std::wstring & image_file_name) = 0;
virtual odf_style_context * styles_context();
odf_chart_context * chart_context();
odf_style_context * styles_context();
odf_page_layout_context * page_layout_context();
odf_number_styles_context * numbers_styles_context();
......
......@@ -19,7 +19,15 @@ namespace odf {
odf_page_layout_context::odf_page_layout_context(odf_conversion_context * Context)
{
odf_context_ = Context;
style_context_ = Context->styles_context();
style_context_ = Context->styles_context();
local_style_context_ = new odf_style_context();
local_style_context_->set_odf_context(odf_context_);
}
odf_page_layout_context::~odf_page_layout_context()
{
delete local_style_context_;
}
......@@ -38,22 +46,17 @@ odf_master_state & odf_page_layout_context::last_master()
throw;
}
void odf_page_layout_context::create_master_page(std::wstring oox_name)
void odf_page_layout_context::create_master_page(std::wstring page_name)
{
std::wstring odf_name = oox_name;
style_family family = style_family::MasterPage;
office_element_ptr elm;
create_element(L"style", L"master-page", elm, odf_context_);
if (!elm) return;
style_context_->add_master_style(elm);
master_state_list_.push_back( odf_master_state(elm) );
///////////////////////////////////////
if (odf_name.length() <1)odf_name =L"MasterPage" + boost::lexical_cast<std::wstring>(master_state_list_.size());
master_state_list_.back().set_name(odf_name);
if (page_name.length() <1)page_name =L"MasterPage" + boost::lexical_cast<std::wstring>(master_state_list_.size());
master_state_list_.back().set_name(page_name);
/////////////////////////
//default layout
......@@ -61,9 +64,30 @@ void odf_page_layout_context::create_master_page(std::wstring oox_name)
master_state_list_.back().set_layout_name(layout_state_list_.back().get_name());
}
void odf_page_layout_context::process_master_styles(office_element_ptr root )
{
for (long i =0; i < master_state_list_.size(); i++)
{
try
{
root->add_child_element(master_state_list_[i].get_root());
}
catch(...)
{
//
}
}
}
void odf_page_layout_context::process_automatic_for_styles(office_element_ptr root )
{
local_style_context_->process_automatic(root);
}
void odf_page_layout_context::set_current_master_page_base()
{
style_context_->set_current_master_page_base();
master_state_list_.insert(master_state_list_.begin(), master_state_list_.back());
master_state_list_.pop_back();
}
void odf_page_layout_context::set_styles_context(odf_style_context * Context)
......@@ -74,15 +98,12 @@ void odf_page_layout_context::set_styles_context(odf_style_context * Context)
void odf_page_layout_context::create_layout_page()
{
office_element_ptr elm;
style_family family;
family = style_family::MasterPage;
create_element(L"style", L"page-layout", elm, odf_context_);
std::wstring odf_name = style_context_->find_free_name(style_family::PageLayout);
std::wstring odf_name = local_style_context_->find_free_name(style_family::PageLayout);
if (!elm) return;
style_context_->add_style(elm, true, true, style_family::PageLayout);
local_style_context_->add_style(elm, true, false, style_family::PageLayout);
layout_state_list_.push_back( odf_layout_state(elm) );
///////////////////////////////////////
......@@ -145,12 +166,23 @@ void odf_page_layout_context::set_page_footer(_CP_OPT(length) length_)
}
else
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_= length(length_->get_value_unit(length::cm),length::cm);
}
///////////////////////////////////////////////////////////////
void odf_page_layout_context::add_footer(int type)
{
office_element_ptr elm;
create_element(L"style", L"footer", elm, odf_context_);
master_state_list_.back().add_footer(elm);
}
void odf_page_layout_context::add_header(int type)
{
office_element_ptr elm;
create_element(L"style", L"header", elm, odf_context_);
master_state_list_.back().add_header(elm);
}
void odf_page_layout_context::set_page_header(_CP_OPT(length) length_)
{
if (!length_) return;
......@@ -164,11 +196,6 @@ void odf_page_layout_context::set_page_header(_CP_OPT(length) length_)
}
else
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_= length(length_->get_value_unit(length::cm),length::cm);
office_element_ptr elm;
create_element(L"style", L"header", elm, odf_context_);
master_state_list_.back().add_header(elm);
}
void odf_page_layout_context::set_page_border_shadow(bool val)
{
......
......@@ -21,14 +21,24 @@ class odf_page_layout_context
{
public:
odf_page_layout_context(odf_conversion_context * Context);
~odf_page_layout_context();
void set_styles_context (odf_style_context * Context);
void create_master_page(std::wstring oox_name);
void create_layout_page();
void set_current_master_page_base();
void process_master_styles (office_element_ptr root );
void process_automatic_for_styles (office_element_ptr root );
odf_layout_state & last_layout();
odf_master_state & last_master();
odf_style_context *get_local_styles_context() //
{return local_style_context_;}
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_gutter(_CP_OPT(length) length_);
......@@ -40,7 +50,8 @@ public:
void set_page_orientation(int type);
void set_page_size(_CP_OPT(length) width, _CP_OPT(length) height);
void set_current_master_page_base();
void add_footer(int type);
void add_header(int type);
private:
......@@ -48,7 +59,8 @@ private:
odf_conversion_context * odf_context_;
odf_style_context * style_context_;
odf_style_context * local_style_context_;
std::vector<odf_layout_state> layout_state_list_;
std::vector<odf_master_state> master_state_list_;
......
......@@ -21,6 +21,20 @@ odf_master_state::odf_master_state(office_element_ptr & master_elm )
}
office_element_ptr & odf_master_state::get_root()
{
if (elements_.size() >0)
return elements_[0].elm;
else
throw;
}
office_element_ptr & odf_master_state::get_last_element()
{
if (elements_.size() >0)
return elements_.back().elm;
else
throw;
}
void odf_master_state::add_child(office_element_ptr & child_elm, office_element_ptr style_elm, std::wstring style_name )
{
int level =current_level_.size();
......
......@@ -38,7 +38,10 @@ public:
void add_footer(office_element_ptr & elm);
void add_header(office_element_ptr & elm);
void set_layout_name(std::wstring & name);
void set_layout_name(std::wstring & name);
office_element_ptr & get_root();
office_element_ptr & get_last_element();
private:
std::wstring style_oox_name_;
......
......@@ -82,19 +82,6 @@ void odf_style_context::add_style(office_element_ptr elm, bool automatic, bool r
last_state().set_automatic(automatic);
last_state().set_root(root);
}
void odf_style_context::add_master_style(office_element_ptr & elm)
{
if (!elm) return;
master_style_list_.push_back( elm);
}
void odf_style_context::set_current_master_page_base()
{
master_style_list_.insert(master_style_list_.begin(), master_style_list_.back());
master_style_list_.pop_back();
}
void odf_style_context::create_default_style(const style_family family)
{
......@@ -113,8 +100,8 @@ void odf_style_context::reset_defaults()
current_default_styles_.clear();
}
void odf_style_context::process_automatic_styles(office_element_ptr root )
{//
void odf_style_context::process_automatic_for_styles(office_element_ptr root )
{//
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].writable_ == false) continue;
......@@ -133,15 +120,7 @@ void odf_style_context::process_automatic(office_element_ptr root )
root->add_child_element(style_state_list_[i].odf_style_);
}
}
void odf_style_context::process_master(office_element_ptr root )
{
for (long i =0; i < master_style_list_.size(); i++)
{
if (style_state_list_[i].writable_ == false) continue;
root->add_child_element(master_style_list_[i]);
}
}
void odf_style_context::process_office(office_element_ptr root )
{
number_styles_context_.process_styles(root );
......
......@@ -29,17 +29,13 @@ public:
void create_style(std::wstring name, const style_family style_family, bool automatic = false, bool root = false, int oox_id = -1);
void create_default_style(const style_family style_family);
void create_master_style(std::wstring oox_name, int type = 1);
void add_style(office_element_ptr elm, bool automatic = false, bool root = false, style_family style_family=style_family::None);
void add_master_style(office_element_ptr & elm);
void set_current_master_page_base();
office_element_ptr & add_or_find(std::wstring name, const style_family family, bool automatic = false, bool root = false, int id = -1);
void process_automatic_styles(office_element_ptr root );
void process_automatic_for_styles(office_element_ptr root );
void process_automatic(office_element_ptr root );
void process_master(office_element_ptr root );
void process_office(office_element_ptr root );
void reset_defaults();
......@@ -75,7 +71,6 @@ private:
odf_conversion_context * odf_context_;
std::vector<odf_style_state> style_state_list_;
std::vector<office_element_ptr> master_style_list_;
std::vector<odf_style_state> current_default_styles_;// ..
......
......@@ -37,7 +37,10 @@ void odf_text_context::set_styles_context(odf_style_context* styles_context)
{
styles_context_ = styles_context;
}
odf_style_context* odf_text_context::get_styles_context()
{
return styles_context_;
}
void odf_text_context::set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props)
{
single_paragraph_ = val;
......
......@@ -29,8 +29,9 @@ public:
odf_text_context(odf_conversion_context *odf_context);
~odf_text_context();
public:
void set_styles_context(odf_style_context* styles_context);// embedded
void set_styles_context(odf_style_context* styles_context);// embedded
odf_style_context* get_styles_context();// embedded
void add_text_style(office_element_ptr & style_elm, std::wstring style_name);
void set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props);
......
......@@ -99,6 +99,19 @@ odf_comment_context* odt_conversion_context::comment_context()
{
return &comment_context_;
}
odf_style_context* odt_conversion_context::styles_context()
{
if (text_context_.size() > 0)
{
return text_context_.back()->get_styles_context();
}
else
{
return odf_conversion_context::styles_context();
}
}
odf_table_context* odt_conversion_context::table_context()
{
return &table_context_;
......@@ -656,5 +669,32 @@ void odt_conversion_context::end_table()
table_context()->end_table();
text_context()->end_element();
}
void odt_conversion_context::start_header(int type)
{
page_layout_context()->add_header(type);
start_text_context();
text_context()->set_styles_context(page_layout_context()->get_local_styles_context());
text_context()->start_element(page_layout_context()->last_master().get_last_element());
}
void odt_conversion_context::end_header_footer()
{
text_context()->end_element();
end_text_context();
}
void odt_conversion_context::start_footer(int type)
{
page_layout_context()->add_footer(type);
start_text_context();
text_context()->set_styles_context(page_layout_context()->get_local_styles_context());
text_context()->start_element(page_layout_context()->last_master().get_last_element());
}
}
}
......@@ -38,6 +38,8 @@ public:
virtual odf_drawing_context * drawing_context();
virtual odf_text_context * text_context();
virtual odf_style_context * styles_context();
odf_comment_context * comment_context();
odf_table_context * table_context();
......@@ -96,6 +98,10 @@ public:
bool is_empty_section(){return current_root_elements_.size() > 0 ? false : true; }
void start_header(int type);
void start_footer(int type);
void end_header_footer();
private:
office_text* root_text_;
office_element_ptr root_document_;
......
......@@ -624,7 +624,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
convert(oox_section_pr->m_oPgMar->m_oFooter.GetPointer(), other);
odt_context->page_layout_context()->set_page_footer(other);
convert(oox_section_pr->m_oPgMar->m_oFooter.GetPointer(), other);
convert(oox_section_pr->m_oPgMar->m_oHeader.GetPointer(), other);
odt_context->page_layout_context()->set_page_header(other);
}
if (oox_section_pr->m_oPgBorders.IsInit())
......@@ -675,15 +675,30 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//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;
for (long i=0; i< oox_section_pr->m_arrHeaderReference.GetSize(); i++)
{
int type =oox_section_pr->m_arrHeaderReference[i].m_oType.IsInit() ? oox_section_pr->m_arrHeaderReference[i].m_oType->GetValue() :0 ;
odt_context->start_header(type);
if (oox_section_pr->m_arrHeaderReference[i].m_oId.IsInit())
convert_hdr_ftr(oox_section_pr->m_arrHeaderReference[i].m_oId->GetValue());
odt_context->end_header_footer();
}
for (long i=0; i< oox_section_pr->m_arrFooterReference.GetSize(); i++)
{
int type =oox_section_pr->m_arrFooterReference[i].m_oType.IsInit() ? oox_section_pr->m_arrFooterReference[i].m_oType->GetValue() :0 ;
odt_context->start_footer(type);
if (oox_section_pr->m_arrFooterReference[i].m_oId.IsInit())
convert_hdr_ftr(oox_section_pr->m_arrFooterReference[i].m_oId->GetValue());
odt_context->end_header_footer();
}
//master page create
// add colontitul
// style name master page -> 0-
......@@ -978,6 +993,8 @@ void DocxConverter::convert(ComplexTypes::Word::CBorder *borderProp, std::wstrin
odf_border_prop == L"none";
return;
break;
default:
border_style << L" solid";
}
}else border_style << L" solid";
///////////////////////////////////////////////////////////////////
......@@ -2057,6 +2074,16 @@ void DocxConverter::convert_comment(int oox_comm_id)
}
}
}
void DocxConverter::convert_hdr_ftr (CString sId)
{
OOX::CHdrFtr * oox_hdr_ftr = docx_document->GetHeaderOrFooter(sId);
if (oox_hdr_ftr == NULL ) return;
for ( int nIndex = 0; nIndex < oox_hdr_ftr->m_arrItems.GetSize(); nIndex++ )
{
convert(oox_hdr_ftr->m_arrItems[nIndex]);
}
}
void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
{
if (oox_table == NULL) return;
......
......@@ -105,7 +105,9 @@ namespace Oox2Odf
void convert_document();
void convert_styles();
void convert_settings();
void convert_comment(int oox_comm_id);
void convert_comment (int oox_comm_id);
void convert_hdr_ftr (CString sId);
void convert(OOX::Logic::CSdt *oox_sdt);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root = false);
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//103
#define INTVER 1,2,0,103
#define STRVER "1,2,0,103\0"
//104
#define INTVER 1,2,0,104
#define STRVER "1,2,0,104\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