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

разметка страниц в таблицах

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56533 954022d7-b5bf-4e40-9824-e11837661b57
parent a8efbe21
......@@ -33,7 +33,11 @@ public:
Opacity,
FillImage,
Marker,
StokeDash
StokeDash,
PageLayout,
MasterPage,
HandoutMaster,
LayerSet
};
style_family() : type_(Default) {}
......
......@@ -1098,6 +1098,22 @@
RelativePath=".\OdfFormat\odf_number_styles_context.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_page_layout_context.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_page_layout_context.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_page_layout_state.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_page_layout_state.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_style_context.cpp"
>
......
......@@ -7,12 +7,26 @@
namespace cpdoccore {
namespace odf {
void style_header_footer_properties_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"svg:height", svg_height_);
CP_XML_ATTR_OPT(L"fo:min-height", fo_min_height_);
common_horizontal_margin_attlist_.serialize(CP_GET_XML_NODE());
common_vertical_margin_attlist_.serialize(CP_GET_XML_NODE());
common_margin_attlist_.serialize(CP_GET_XML_NODE());
common_border_attlist_.serialize(CP_GET_XML_NODE());
common_border_line_width_attlist_.serialize(CP_GET_XML_NODE());
common_padding_attlist_.serialize(CP_GET_XML_NODE());
common_background_color_attlist_.serialize(CP_GET_XML_NODE());
common_shadow_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"style:dynamic-spacing", style_dynamic_spacing_);
}
/// style-header-footer-properties
const wchar_t * style_header_footer_properties::ns = L"style";
const wchar_t * style_header_footer_properties::name = L"header-footer-properties";
void style_header_footer_properties::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
{
if (L"style" == Ns && L"background-image" == Name)
......@@ -24,7 +38,18 @@ void style_header_footer_properties::create_child_element( const ::std::wstring
not_applicable_element(L"style-header-footer-properties", Ns, Name);
}
}
void style_header_footer_properties::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE_SIMPLE()
{
style_header_footer_properties_attlist_.serialize(CP_GET_XML_NODE());
if (style_background_image_) style_background_image_->serialize(CP_XML_STREAM());
}
}
}
//////////////////////////////////////////
void header_footer_content::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context)
{
CP_CREATE_ELEMENT_SIMPLE(content_);
......@@ -33,5 +58,12 @@ void header_footer_content::add_child_element(office_element_ptr & child)
{
content_.push_back(child);
}
void header_footer_content::serialize(std::wostream & strm)
{
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->serialize(strm);
}
}
}
}
......@@ -19,6 +19,7 @@ namespace odf {
class style_header_footer_properties_attlist
{
public:
void serialize(CP_ATTR_NODE);
_CP_OPT(length) svg_height_;
_CP_OPT(length) fo_min_height_;
......@@ -47,7 +48,7 @@ public:
virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
virtual void serialize(std::wostream & strm);
style_header_footer_properties_attlist style_header_footer_properties_attlist_;
office_element_ptr style_background_image_;
......@@ -72,6 +73,8 @@ public:
void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context);
void add_child_element(office_element_ptr & child);
void serialize(std::wostream & strm);
office_element_ptr_array content_;
};
......
......@@ -32,15 +32,7 @@ namespace odf
{
L"#355a86", L"#883533", L"#6e963c", L"#594573", L"#327a8d", L"#3d679a", L"#9d3e3b", L"#7e9945", L"#674f84", L"#398ba2", L"#cb7934"
};
struct odf_element_state
{
office_element_ptr elm;
std::wstring style_name;
office_element_ptr style_elm;
int level;
};
struct odf_axis_state
{
unsigned int oox_id;
......
......@@ -3,6 +3,8 @@
#include "object_package.h"
#include "odf_style_context.h"
#include "odf_page_layout_context.h"
#include "odf_drawing_context.h"
#include "odf_chart_context.h"
......
......@@ -29,15 +29,6 @@ namespace cpdoccore
namespace odf
{
struct odf_element_state
{
office_element_ptr elm;
std::wstring style_name;
office_element_ptr style_elm;
int level;
};
struct odf_group_state
{
office_element_ptr elm;
......
#include "precompiled_cpodf.h"
#include "odf_page_layout_context.h"
#include "odf_style_context.h"
#include "ods_conversion_context.h"
#include "logging.h"
#include "styles.h"
#include <boost/foreach.hpp>
#include <iostream>
namespace cpdoccore {
namespace odf {
odf_page_layout_context::odf_page_layout_context()
{
}
void odf_page_layout_context::set_odf_context(odf_conversion_context * Context)
{
odf_context_ = Context;
style_context_ = Context->styles_context();
}
odf_layout_state & odf_page_layout_context::last_layout()
{
if (layout_state_list_.size() >0)
return layout_state_list_.back();
else
throw;
}
odf_master_state & odf_page_layout_context::last_master()
{
if (master_state_list_.size() >0)
return master_state_list_.back();
else
throw;
}
void odf_page_layout_context::create_master_page(std::wstring oox_name)
{
std::wstring odf_name = oox_name;
office_element_ptr elm;
style_family family = style_family::MasterPage;
create_element(L"style", L"master-page", elm, odf_context_);
if (odf_name.length() <1)odf_name = style_context_->find_free_name(style_family::MasterPage);
if (!elm) return;
style_context_->add_master_style(elm);
master_state_list_.push_back( odf_master_state(elm) );
///////////////////////////////////////
master_state_list_.back().set_name(odf_name);
}
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);
if (!elm) return;
style_context_->add_style(elm, true, true);
layout_state_list_.push_back( odf_layout_state(elm) );
///////////////////////////////////////
layout_state_list_.back().set_name(odf_name);
}
}
}
\ No newline at end of file
#pragma once
#include <string>
#include "odf_page_layout_state.h"
namespace cpdoccore {
namespace odf {
class odf_style_context;
class odf_conversion_context;
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
class odf_page_layout_context;
typedef shared_ptr<odf_page_layout_context>::Type odf_page_layout_context_ptr;
class odf_page_layout_context
{
public:
odf_page_layout_context();
void set_odf_context (odf_conversion_context * Context);
void set_style_context (odf_style_context * Context);
void create_master_page(std::wstring oox_name);
void create_layout_page();
odf_layout_state & last_layout();
odf_master_state & last_master();
private:
odf_conversion_context * odf_context_;
odf_style_context * style_context_;
std::vector<odf_layout_state> layout_state_list_;
std::vector<odf_master_state> master_state_list_;
};
}
}
#include "precompiled_cpodf.h"
#include "logging.h"
#include "odf_page_layout_state.h"
#include "odf_conversion_context.h"
#include "styles.h"
namespace cpdoccore {
namespace odf {
odf_master_state::odf_master_state(office_element_ptr & master_elm )
{
int level =0;
odf_element_state state = {master_elm,L"",office_element_ptr(),level};
elements_.push_back(state);
current_level_.push_back(master_elm);
}
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();
odf_element_state state = {child_elm, style_name, style_elm,level};
elements_.push_back(state);
current_level_.back()->add_child_element(child_elm);
}
void odf_master_state::set_name(std::wstring & name)
{
style_master_page* style_ = dynamic_cast<style_master_page*>(elements_[0].elm.get());
if (!style_)return;
style_->style_master_page_attlist_.style_name_ = name;
}
void odf_master_state::set_layout_name(std::wstring & name)
{
style_master_page* style_ = dynamic_cast<style_master_page*>(elements_[0].elm.get());
if (!style_)return;
style_->style_master_page_attlist_.style_page_layout_name_ = name;
}
std::wstring odf_master_state::get_name()
{
style_master_page* style_ = dynamic_cast<style_master_page*>(elements_[0].elm.get());
if (!style_)return L"";
if (style_->style_master_page_attlist_.style_name_)
return style_->style_master_page_attlist_.style_name_->style_name();
else return L"";
}
///////////////////////////////////////////////////////////////////////////////
odf_layout_state::odf_layout_state(office_element_ptr & layout_elm )
{
int level =0;
odf_element_state state = {layout_elm,L"",office_element_ptr(),level};
elements_.push_back(state);
}
void odf_layout_state::add_child(office_element_ptr & child_elm, office_element_ptr style_elm, std::wstring style_name )
{
int level =current_level_.size();
odf_element_state state = {child_elm, style_name, style_elm,level};
elements_.push_back(state);
current_level_.back()->add_child_element(child_elm);
}
void odf_layout_state::set_name(std::wstring & name)
{
style_page_layout* style_ = dynamic_cast<style_page_layout*>(elements_[0].elm.get());//0 - root
if (!style_)return;
style_->style_page_layout_attlist_.style_name_ = name;
}
std::wstring odf_layout_state::get_name()
{
style_page_layout *style_ = dynamic_cast<style_page_layout*>(elements_[0].elm.get());
if (!style_)return L"";
return style_->style_page_layout_attlist_.style_name_.get_value_or(L"");
}
}
}
\ No newline at end of file
#pragma once
#include <string>
#include <vector>
#include "office_elements.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf {
class odf_conversion_context;
class odf_style_context;
class odf_page_layout_context;
struct odf_element_state
{
office_element_ptr elm;
std::wstring style_name;
office_element_ptr style_elm;
int level;
};
class odf_master_state
{
public:
odf_master_state(office_element_ptr & master);
void add_child(office_element_ptr & child_elm, office_element_ptr style_elm, std::wstring style_name );
void set_name(std::wstring & name);
std::wstring get_name();
void set_layout_name(std::wstring & name);
private:
std::wstring style_oox_name_;
std::vector<office_element_ptr> current_level_;
std::vector<odf_element_state> elements_;
friend class odf_page_layout_context;
};
class odf_layout_state
{
public:
odf_layout_state(office_element_ptr & elm);
void add_child(office_element_ptr & child_elm, office_element_ptr style_elm, std::wstring style_name );
void set_name(std::wstring & name);
std::wstring get_name();
private:
std::wstring style_oox_name_;
std::vector<office_element_ptr> current_level_;
std::vector<odf_element_state> elements_;
friend class odf_page_layout_context;
};
}
}
......@@ -30,6 +30,7 @@ odf_style_state & odf_style_context::last_state()
else
throw;
}
void odf_style_context::create_style(std::wstring oox_name,const style_family family, bool automatic,bool root,int oox_id)
{
std::wstring odf_name = oox_name;
......@@ -39,7 +40,7 @@ void odf_style_context::create_style(std::wstring oox_name,const style_family fa
office_element_ptr elm;
create_element(L"style", L"style", elm, odf_context_);
style_state_list_.push_back( odf_style_state(/*context_, */elm, family) );
style_state_list_.push_back( odf_style_state(elm, family) );
///////////////////////////////////////
last_state().set_name(odf_name);
......@@ -57,8 +58,15 @@ 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::create_default(const style_family family)
void odf_style_context::create_default_style(const style_family family)
{
office_element_ptr elm;
create_element(L"style", L"default-style", elm, odf_context_);
......@@ -80,7 +88,7 @@ void odf_style_context::create_default(const style_family family)
}
void odf_style_context::reset_defaults()
{
default_styles_.clear();
current_default_styles_.clear();
}
void odf_style_context::process_automatic_styles(office_element_ptr root )
......@@ -101,9 +109,9 @@ void odf_style_context::process_automatic(office_element_ptr root )
}
void odf_style_context::process_master(office_element_ptr root )
{
for (long i =0; i < master_state_list_.size(); i++)
for (long i =0; i < master_style_list_.size(); i++)
{
root->add_child_element(master_state_list_[i].odf_style_);
root->add_child_element(master_style_list_[i]);
}
}
void odf_style_context::process_office(office_element_ptr root )
......@@ -171,22 +179,22 @@ bool odf_style_context::find_odf_style_state(int oox_id_style, const style_famil
}
office_element_ptr odf_style_context::find_odf_style_default(const style_family family)
{
for (int i=0;i<default_styles_.size(); i++)
for (int i=0;i<current_default_styles_.size(); i++)
{
if (default_styles_[i].odf_style_)
if (current_default_styles_[i].odf_style_)
{
if (default_styles_[i].style_family_ == family)return default_styles_[i].get_office_element();
if (current_default_styles_[i].style_family_ == family)return current_default_styles_[i].get_office_element();
}
}
return office_element_ptr();
}
std::wstring odf_style_context::find_odf_style_name_default(const style_family family)
{
for (int i=0;i<default_styles_.size(); i++)
for (int i=0;i<current_default_styles_.size(); i++)
{
if (default_styles_[i].odf_style_)
if (current_default_styles_[i].odf_style_)
{
if (default_styles_[i].style_family_ == family)return default_styles_[i].get_name();
if (current_default_styles_[i].style_family_ == family)return current_default_styles_[i].get_name();
}
}
return L"";
......@@ -218,6 +226,12 @@ std::wstring odf_style_context::get_name_family(const style_family & family)
case style_family::FillImage: return L"FillImage";
case style_family::Marker: return L"Marker";
case style_family::StokeDash: return L"StokeDash";
case style_family::PageLayout: return L"Mpm";
case style_family::MasterPage: return L"MasterPage";
case style_family::HandoutMaster:return L"Handout";
case style_family::LayerSet: return L"";//
}
return L"UnknownStyle";
}
......
......@@ -26,9 +26,11 @@ public:
void set_odf_context(odf_conversion_context * Context);
void create_style(std::wstring name, const style_family style_family, bool automatic = false, bool root = false, int oox_id = -1);
void create_default(const style_family style_family);
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);
office_element_ptr & add_or_find(std::wstring name, const style_family family, bool automatic = false, bool root = false, int id = -1);
......@@ -38,7 +40,7 @@ public:
void process_office(office_element_ptr root );
void reset_defaults();
void add_default(odf_style_state & state) {default_styles_.push_back(state);}
void add_default(odf_style_state & state) {current_default_styles_.push_back(state);}
std::wstring find_odf_style_name (int oox_id_style, const style_family family, bool root = false);
office_element_ptr find_odf_style (int oox_id_style, const style_family family, bool root = false);
......@@ -60,10 +62,10 @@ private:
odf_conversion_context * odf_context_;
std::vector<odf_style_state> style_state_list_;
std::vector<odf_style_state> default_styles_;// ..
std::vector<office_element_ptr> master_style_list_;
std::vector<odf_style_state> current_default_styles_;// ..
std::vector<odf_style_state> master_state_list_;
std::wstring get_name_family(const style_family & family);
......
......@@ -2,13 +2,6 @@
#include <string>
#include <vector>
//
//#include "ods_row_spanned.h"
//#include "ods_merge_cells.h"
//#include "ods_table_metrics.h"
//#include "ods_drawing_context.h"
//#include "ods_comments_context.h"
//#include "ods_hyperlinks.h"
#include "office_elements.h"
#include "office_elements_create.h"
......
......@@ -86,6 +86,7 @@ public:
private:
_font_metrix font_metrix_;
ods_table_context table_context_;
odf_page_layout_context page_layout_context_;
odf_text_context* current_text_context_;
office_spreadsheet* root_spreadsheet_;
......
This diff is collapsed.
......@@ -798,7 +798,7 @@ void XlsxConverter::convert_styles()
if (!ods_context) return;
// add default styles
ods_context->styles_context()->create_default(odf::style_family::TableCell);
ods_context->styles_context()->create_default_style(odf::style_family::TableCell);
///////////////////////////////////////////////////////////////////////////////////////////////////
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
......
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