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

конвертация docx->odt pre-stable version

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57237 954022d7-b5bf-4e40-9824-e11837661b57
parent 241194b7
......@@ -17,21 +17,27 @@ namespace odf
{
namespace fs = boost::filesystem;
simple_element::simple_element(const std::wstring & FileName, const std::wstring & Content) : file_name_(FileName)
simple_element::simple_element(const std::wstring & FileName, const std::wstring & Content, bool utf8) : file_name_(FileName), utf8_(utf8)
{
utf8::utf16to8(Content.begin(), Content.end(), std::back_inserter(content_utf8_));
if (utf8_)
{
utf8::utf16to8(Content.begin(), Content.end(), std::back_inserter(content_utf8_));
}else
content_utf8_ = std::string( Content.begin(), Content.end());
}
void simple_element::write(const std::wstring & RootPath)
{
fs::ofstream file( fs::wpath(RootPath) / file_name_, std::ios_base::out | std::ios_base::binary );
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
if (utf8_)
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
file << content_utf8_;
}
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content, bool utf8)
{
return boost::make_shared<simple_element>(FileName, Content);
return boost::make_shared<simple_element>(FileName, Content, utf8);
}
////////////
......@@ -62,11 +68,11 @@ namespace odf
void mimetype_file::write(const std::wstring & RootPath)
{
std::wstringstream resStream;
resStream << L"application/vnd.oasis.opendocument.";
resStream << type_;
simple_element elm(L"mimetype", resStream.str());
simple_element elm(L"mimetype", resStream.str(),false);
elm.write(RootPath);
}
void manifect_file::write(const std::wstring & RootPath)
......
......@@ -71,14 +71,15 @@ namespace odf
class simple_element : public element
{
public:
simple_element(const std::wstring & FileName, const std::wstring & Content);
static element_ptr create(const std::wstring & FileName, const std::wstring & Content);
simple_element(const std::wstring & FileName, const std::wstring & Content, bool utf8 = true);
static element_ptr create(const std::wstring & FileName, const std::wstring & Content, bool utf8 = true);
virtual void write(const std::wstring & RootPath);
private:
std::wstring file_name_;
std::string content_utf8_;
bool utf8_;
};
......
......@@ -34,6 +34,7 @@ void odf_style_context::set_odf_context(odf_conversion_context * Context)
{
odf_context_ = Context;
number_styles_context_.set_odf_context(Context);
table_styles_context_.set_odf_context(Context);
}
odf_style_state & odf_style_context::last_state()
......
......@@ -3,14 +3,271 @@
#include "logging.h"
#include "odf_table_styles_context.h"
#include "ods_conversion_context.h"
#include "styles.h"
#include "odf_conversion_context.h"
#include "style_table_properties.h"
#include "style_text_properties.h"
#include "style_paragraph_properties.h"
namespace cpdoccore {
namespace odf {
style_table_cell_properties *odf_table_styles_context::get_table_cell_properties()
{
if (current == NULL)return NULL;
if (!current->table_cell_props)
create_element(L"style", L"table-cell-properties",current->table_cell_props, context_);
return dynamic_cast<style_table_cell_properties *>(current->table_cell_props.get());
}
style_paragraph_properties *odf_table_styles_context::get_paragraph_properties()
{
if (current == NULL)return NULL;
if (!current->paragraph_props)
create_element(L"style", L"paragraph-properties",current->paragraph_props, context_);
return dynamic_cast<style_paragraph_properties *>(current->paragraph_props.get());
}
style_text_properties *odf_table_styles_context::get_text_properties()
{
if (current == NULL)return NULL;
if (!current->text_props)
create_element(L"style", L"text-properties",current->text_props, context_);
return dynamic_cast<style_text_properties *>(current->text_props.get());
}
void odf_table_styles_context::start_style(std::wstring style_name)
{
table_format_state state;
state.style_name = style_name;
table_format_array_.push_back(state);
current = &table_format_array_.back().table_;
}
void odf_table_styles_context::end_style()
{
current = NULL;
}
void odf_table_styles_context::add_band1Horz()
{
current = &table_format_array_.back().band1Horz_;
}
void odf_table_styles_context::add_band1Vert()
{
current = &table_format_array_.back().band1Vert_;
}
void odf_table_styles_context::add_band2Horz()
{
current = &table_format_array_.back().band2Horz_;
}
void odf_table_styles_context::add_band2Vert()
{
current = &table_format_array_.back().band2Vert_;
}
void odf_table_styles_context::add_firstCol()
{
current = &table_format_array_.back().firstCol_;
}
void odf_table_styles_context::add_firstRow()
{
current = &table_format_array_.back().firstRow_;
}
void odf_table_styles_context::add_lastCol()
{
current = &table_format_array_.back().band1Horz_;
}
void odf_table_styles_context::add_lastRow()
{
current = &table_format_array_.back().lastRow_;
}
void odf_table_styles_context::add_neCell()
{
current = &table_format_array_.back().neCell_;
}
void odf_table_styles_context::add_nwCell()
{
current = &table_format_array_.back().nwCell_;
}
void odf_table_styles_context::add_seCell()
{
current = &table_format_array_.back().seCell_;
}
void odf_table_styles_context::add_swCell()
{
current = &table_format_array_.back().swCell_;
}
void odf_table_styles_context::add_wholeTable()
{
current = &table_format_array_.back().wholeTable_;
}
bool odf_table_styles_context::set_current_style(std::wstring name)
{
for (long i=0; i < table_format_array_.size(); i++)
{
if (table_format_array_[i].style_name == name)
{
current_table_style_ = i;
return true;
}
}
return false;
}
void odf_table_styles_context::set_current_dimension(int col, int row)
{
current_table_col_count_ = col;
current_table_row_count_ = row;
}
void odf_table_styles_context::get_table_cell_properties (int col, int row, style_table_cell_properties* cell_props)
{
if (current_table_style_ < 0) return;
if (cell_props == NULL) return;
//------------------------------------------------------------------------------
bool first_row = (row == 1)? true: false;
bool first_col = (col == 1)? true: false;
bool odd_row = (row%2 != 0) ? true : false;//
bool odd_col = (col%2 != 0) ? true : false;
bool even_row = (row%2 != 0) ? true : false;//
bool even_col = (col%2 != 0) ? true : false;
bool last_row = (row == current_table_row_count_) ? true: false;
bool last_col = (col == current_table_col_count_) ? true: false;
bool ne = (row == 1 && col == current_table_col_count_) ? true: false; //top right cell
bool nw = (row == 1 && col == 1) ? true: false; //top left cell.
bool se = (row == current_table_row_count_ && col == current_table_col_count_) ? true: false; //bottom right cell
bool sw = (row == current_table_row_count_ && col == 1) ? true: false; //bottom left cell.
//----------------------------------------------------------------------------------------------------------------------------------
// - main, odd, even first, last, ne, .... col, row
table_format_state & state = table_format_array_[current_table_style_];
cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.table_.table_cell_props.get()));
if (odd_col) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.band1Vert_.table_cell_props.get()));
if (even_col) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.band2Vert_.table_cell_props.get()));
if (odd_row) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.band1Horz_.table_cell_props.get()));
if (even_row) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.band2Horz_.table_cell_props.get()));
if (first_col) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.firstCol_.table_cell_props.get()));
if (last_col) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.lastCol_.table_cell_props.get()));
if (first_row) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.firstRow_.table_cell_props.get()));
if (last_row) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.lastRow_.table_cell_props.get()));
if (ne) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.neCell_.table_cell_props.get()));
if (nw) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.nwCell_.table_cell_props.get()));
if (se) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.seCell_.table_cell_props.get()));
if (sw) cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.swCell_.table_cell_props.get()));
}
void odf_table_styles_context::get_text_properties (int col, int row, style_text_properties* text_props)
{
if (current_table_style_ < 0) return;
if (text_props == NULL) return;
//------------------------------------------------------------------------------
bool first_row = (row == 1)? true: false;
bool first_col = (col == 1)? true: false;
bool odd_row = (row%2 != 0) ? true : false;//
bool odd_col = (col%2 != 0) ? true : false;
bool even_row = (row%2 != 0) ? true : false;//
bool even_col = (col%2 != 0) ? true : false;
bool last_row = (row == current_table_row_count_) ? true: false;
bool last_col = (col == current_table_col_count_) ? true: false;
bool ne = (row == 1 && col == current_table_col_count_) ? true: false; //top right cell
bool nw = (row == 1 && col == 1) ? true: false; //top left cell.
bool se = (row == current_table_row_count_ && col == current_table_col_count_) ? true: false; //bottom right cell
bool sw = (row == current_table_row_count_ && col == 1) ? true: false; //bottom left cell.
//----------------------------------------------------------------------------------------------------------------------------------
// - main, odd, even first, last, ne, ....
table_format_state & state = table_format_array_[current_table_style_];
text_props->apply_from(dynamic_cast<style_text_properties *>(state.table_.text_props.get()));
if (odd_col) text_props->apply_from(dynamic_cast<style_text_properties *>(state.band1Vert_.text_props.get()));
if (even_col) text_props->apply_from(dynamic_cast<style_text_properties *>(state.band2Vert_.text_props.get()));
if (odd_row) text_props->apply_from(dynamic_cast<style_text_properties *>(state.band1Horz_.text_props.get()));
if (even_row) text_props->apply_from(dynamic_cast<style_text_properties *>(state.band2Horz_.text_props.get()));
if (first_col) text_props->apply_from(dynamic_cast<style_text_properties *>(state.firstCol_.text_props.get()));
if (last_col) text_props->apply_from(dynamic_cast<style_text_properties *>(state.lastCol_.text_props.get()));
if (first_row) text_props->apply_from(dynamic_cast<style_text_properties *>(state.firstRow_.text_props.get()));
if (last_row) text_props->apply_from(dynamic_cast<style_text_properties *>(state.lastRow_.text_props.get()));
if (ne) text_props->apply_from(dynamic_cast<style_text_properties *>(state.neCell_.text_props.get()));
if (nw) text_props->apply_from(dynamic_cast<style_text_properties *>(state.nwCell_.text_props.get()));
if (se) text_props->apply_from(dynamic_cast<style_text_properties *>(state.seCell_.text_props.get()));
if (sw) text_props->apply_from(dynamic_cast<style_text_properties *>(state.swCell_.text_props.get()));
}
void odf_table_styles_context::get_paragraph_properties (int col, int row, style_paragraph_properties* para_props)
{
if (current_table_style_ < 0) return;
if (para_props == NULL) return;
//------------------------------------------------------------------------------
bool first_row = (row == 1)? true: false;
bool first_col = (col == 1)? true: false;
bool odd_row = (row%2 != 0) ? true : false;//
bool odd_col = (col%2 != 0) ? true : false;
bool even_row = (row%2 != 0) ? true : false;//
bool even_col = (col%2 != 0) ? true : false;
bool last_row = (row == current_table_row_count_) ? true: false;
bool last_col = (col == current_table_col_count_) ? true: false;
bool ne = (row == 1 && col == current_table_col_count_) ? true: false; //top right cell
bool nw = (row == 1 && col == 1) ? true: false; //top left cell.
bool se = (row == current_table_row_count_ && col == current_table_col_count_) ? true: false; //bottom right cell
bool sw = (row == current_table_row_count_ && col == 1) ? true: false; //bottom left cell.
//----------------------------------------------------------------------------------------------------------------------------------
// - main, odd, even first, last, ne, ....
table_format_state & state = table_format_array_[current_table_style_];
para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.table_.paragraph_props.get()));
if (odd_col) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.band1Vert_.paragraph_props.get()));
if (even_col) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.band2Vert_.paragraph_props.get()));
if (odd_row) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.band1Horz_.paragraph_props.get()));
if (even_row) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.band2Horz_.paragraph_props.get()));
if (first_col) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.firstCol_.paragraph_props.get()));
if (last_col) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.lastCol_.paragraph_props.get()));
if (first_row) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.firstRow_.paragraph_props.get()));
if (last_row) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.lastRow_.paragraph_props.get()));
if (ne) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.neCell_.paragraph_props.get()));
if (nw) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.nwCell_.paragraph_props.get()));
if (se) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.seCell_.paragraph_props.get()));
if (sw) para_props->apply_from(dynamic_cast<style_paragraph_properties *>(state.swCell_.paragraph_props.get()));
}
}
}
\ No newline at end of file
......@@ -11,26 +11,98 @@ namespace cpdoccore {
namespace odf {
class style_table_cell_properties;
class style_text_properties;
class style_paragraph_properties;
//typedef shared_ptr<style_text_properties>::Type style_text_properties_ptr;
//typedef shared_ptr<style_paragraph_properties>::Type style_paragraph_properties_ptr;
//typedef shared_ptr<style_table_cell_properties>::Type style_table_cell_properties_ptr;
//row, column ???
struct _style_properties
{
office_element_ptr text_props;
office_element_ptr paragraph_props;
office_element_ptr table_cell_props;
};
struct table_format_state
{
std::wstring style_name;
_style_properties table_;
_style_properties band1Horz_;
_style_properties band1Vert_;
_style_properties band2Horz_;
_style_properties band2Vert_;
_style_properties firstCol_;
_style_properties firstRow_;
_style_properties lastCol_;
_style_properties lastRow_;
_style_properties neCell_;
_style_properties nwCell_;
_style_properties seCell_;
_style_properties swCell_;
_style_properties wholeTable_; //???
};
class odf_table_styles_context
{
public:
odf_table_styles_context(){}
odf_table_styles_context(){current = NULL; context_ = NULL; current_table_style_ = -1;}
void set_odf_context(odf_conversion_context * Context)
{
context_ = Context;
}
//-----------------------------------------------
// input
//-----------------------------------------------
void start_style(std::wstring styale_name);
void end_style();
style_table_cell_properties * get_table_cell_properties(int col, int row){return NULL;}
void add_band1Horz();
void add_band1Vert();
void add_band2Horz();
void add_band2Vert();
void add_firstCol();
void add_firstRow();
void add_lastCol();
void add_lastRow();
void add_neCell();
void add_nwCell();
void add_seCell();
void add_swCell();
void add_wholeTable();
bool set_current_style(std::wstring name) {return false;}
style_table_cell_properties *get_table_cell_properties();
style_paragraph_properties *get_paragraph_properties();
style_text_properties *get_text_properties();
//-----------------------------------------------
// output
//-----------------------------------------------
bool set_current_style(std::wstring name);
void set_current_dimension(int col, int row);
void get_table_cell_properties (int col, int row, style_table_cell_properties *props);
void get_text_properties (int col, int row, style_text_properties *props);
void get_paragraph_properties (int col, int row, style_paragraph_properties *props);
private:
std::vector<table_format_state> table_format_array_;
_style_properties *current;
odf_conversion_context *context_;
int current_table_style_;
int current_table_col_count_;
int current_table_row_count_;
//////////////////
......
......@@ -212,6 +212,13 @@ void style_paragraph_properties::serialize(std::wostream & strm)
{
style_paragraph_properties_content_.serialize(strm,ns,name);
}
void style_paragraph_properties::apply_from(style_paragraph_properties * Other)
{
if (Other == NULL)return;
style_paragraph_properties_content_.apply_from(Other->content());
}
void paragraph_format_properties::apply_from(paragraph_format_properties & Other)
{
apply_line_width(fo_line_height_, Other.fo_line_height_);
......
......@@ -345,6 +345,8 @@ public:
virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child){}
void apply_from(style_paragraph_properties * Other);
virtual void serialize(std::wostream & strm);
paragraph_format_properties & content(){ return style_paragraph_properties_content_; }
......
......@@ -319,6 +319,12 @@ void style_text_properties::serialize(std::wostream & strm)
text_format_properties_content_.serialize(strm,ns,name);
}
void style_text_properties::apply_from(const style_text_properties * Other)
{
if (Other == NULL) return;
text_format_properties_content_.apply_from(Other->content());
}
}
}
......@@ -279,6 +279,8 @@ public:
static const ElementType type = typeStyleTextProperties;
CPDOCCORE_DEFINE_VISITABLE();
void apply_from(const style_text_properties * Other);
virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child){}
......
......@@ -1411,6 +1411,70 @@ void DocxConverter::convert(OOX::CDocDefaults *def_style)
}
void DocxConverter::convert_table_style(OOX::CStyle *oox_style)
{
if (oox_style == NULL)return;
std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? string2std_string(*oox_style->m_sStyleId) : L"";
odt_context->styles_context()->table_styles().start_style(oox_name);
//
if (oox_style->m_oTblPr.IsInit())
{
//odf::style_table_properties * table_properties = odt_context->styles_context()->table_styles().get_table_properties();
//convert(oox_style->m_oTblPr.GetPointer(), table_properties);
// base_on
if (oox_style->m_oTblPr->m_oTblBorders.IsInit())
{
odf::style_table_cell_properties * table_cell_properties = odt_context->styles_context()->table_styles().get_table_cell_properties();
convert(oox_style->m_oTblPr->m_oTblBorders.GetPointer(), table_cell_properties);
}
}
if (oox_style->m_oTcPr.IsInit())
{
odf::style_table_cell_properties * table_cell_properties = odt_context->styles_context()->table_styles().get_table_cell_properties();
convert(oox_style->m_oTcPr.GetPointer(), table_cell_properties);
} //if (oox_style->m_oTrPr.IsInit())
//{
// odf::style_table_row_properties * table_row_properties = odt_context->styles_context()->table_styles().get_table_row_properties();
// convert(oox_style->m_oTrPr.GetPointer(), table_row_properties);
//}
//
for (long i = 0 ; i <oox_style->m_arrTblStylePr.GetSize() ; i++)
{
if (oox_style->m_arrTblStylePr[i].m_oType.IsInit() == false) continue;
switch (oox_style->m_arrTblStylePr[i].m_oType->GetValue())
{
case SimpleTypes::tblstyleoverridetypeBand1Horz : odt_context->styles_context()->table_styles().add_band1Horz(); break;
case SimpleTypes::tblstyleoverridetypeBand1Vert : odt_context->styles_context()->table_styles().add_band1Vert(); break;
case SimpleTypes::tblstyleoverridetypeBand2Horz : odt_context->styles_context()->table_styles().add_band2Horz(); break;
case SimpleTypes::tblstyleoverridetypeBand2Vert : odt_context->styles_context()->table_styles().add_band2Vert(); break;
case SimpleTypes::tblstyleoverridetypeFirstCol : odt_context->styles_context()->table_styles().add_firstCol(); break;
case SimpleTypes::tblstyleoverridetypeFirstRow : odt_context->styles_context()->table_styles().add_firstRow(); break;
case SimpleTypes::tblstyleoverridetypeLastCol : odt_context->styles_context()->table_styles().add_lastCol(); break;
case SimpleTypes::tblstyleoverridetypeLastRow : odt_context->styles_context()->table_styles().add_lastRow(); break;
case SimpleTypes::tblstyleoverridetypeNeCell : odt_context->styles_context()->table_styles().add_neCell(); break;
case SimpleTypes::tblstyleoverridetypeNwCell : odt_context->styles_context()->table_styles().add_nwCell(); break;
case SimpleTypes::tblstyleoverridetypeSeCell : odt_context->styles_context()->table_styles().add_seCell(); break;
case SimpleTypes::tblstyleoverridetypeSwCell : odt_context->styles_context()->table_styles().add_swCell(); break;
case SimpleTypes::tblstyleoverridetypeWholeTable : odt_context->styles_context()->table_styles().add_wholeTable(); break;
}
// ???
convert(oox_style->m_arrTblStylePr[i].m_oTcPr.GetPointer(), odt_context->styles_context()->table_styles().get_table_cell_properties());
convert(oox_style->m_arrTblStylePr[i].m_oRunPr.GetPointer(),odt_context->styles_context()->table_styles().get_text_properties());
convert(oox_style->m_arrTblStylePr[i].m_oParPr.GetPointer(),odt_context->styles_context()->table_styles().get_paragraph_properties());
//nullable<OOX::Logic::CTableProperty > m_oTblPr;
//nullable<OOX::Logic::CTableRowProperties > m_oTrPr;
}
odt_context->styles_context()->table_styles().end_style();
}
void DocxConverter::convert(OOX::CStyle *oox_style)
{
if (oox_style == NULL)return;
......@@ -1420,18 +1484,25 @@ void DocxConverter::convert(OOX::CStyle *oox_style)
if ( SimpleTypes::styletypeNumbering == oox_style->m_oType->GetValue())
{
//????
return;
}
if ( SimpleTypes::styletypeTable == oox_style->m_oType->GetValue())
{
convert_table_style(oox_style);
return;
}
switch(oox_style->m_oType->GetValue())
{
case SimpleTypes::styletypeCharacter : family = odf::style_family::Text; break;
case SimpleTypes::styletypeParagraph : family = odf::style_family::Paragraph; break;
case SimpleTypes::styletypeTable : family = odf::style_family::Table; break;
default:
return;
}
if (family == odf::style_family::None) return;
std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? string2std_string(*oox_style->m_sStyleId) : L"";
odt_context->styles_context()->create_style(oox_name,family, false, true, -1);
......@@ -1452,41 +1523,8 @@ void DocxConverter::convert(OOX::CStyle *oox_style)
if (oox_style->m_oBasedOn.IsInit() && oox_style->m_oBasedOn->m_sVal.IsInit())
odt_context->styles_context()->last_state().set_parent_style_name(string2std_string(*oox_style->m_oBasedOn->m_sVal));
if (oox_style->m_oTcPr.IsInit())
{
odf::style_table_cell_properties * table_cell_properties = odt_context->styles_context()->last_state().get_table_cell_properties();
convert(oox_style->m_oTcPr.GetPointer(), table_cell_properties);
}
if (oox_style->m_oTblPr.IsInit())
{
odf::style_table_properties * table_properties = odt_context->styles_context()->last_state().get_table_properties();
convert(oox_style->m_oTblPr.GetPointer(), table_properties);
if (oox_style->m_oTblPr->m_oTblBorders.IsInit())
{
odf::style_table_cell_properties * table_cell_properties = odt_context->styles_context()->last_state().get_table_cell_properties();
convert(oox_style->m_oTblPr->m_oTblBorders.GetPointer(), table_cell_properties);
}
}
if (oox_style->m_oTrPr.IsInit())
{
odf::style_table_row_properties * table_row_properties = odt_context->styles_context()->last_state().get_table_row_properties();
convert(oox_style->m_oTrPr.GetPointer(), table_row_properties);
}
//nullable<SimpleTypes::COnOff<> > m_oCustomStyle;
//nullable<SimpleTypes::COnOff<> > m_oDefault;
//nullable<ComplexTypes::Word::CString_ > m_oAliases;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oAutoRedefine;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oHidden;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oLocked;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oPersonal;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oPersonalCompose;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oPersonalReply;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oQFormat;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oSemiHidden;
//CSimpleArray<OOX::Logic::CTableStyleProperties > m_arrTblStylePr;
//nullable<ComplexTypes::Word::CDecimalNumber > m_oUiPriority;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oUnhideWhenUsed;
//nullable<ComplexTypes::Word::CString_ > m_oAliases;
}
......@@ -1562,11 +1600,28 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
{
if (oox_table == NULL) return;
convert(oox_table->m_oTableProperties);
convert(oox_table->m_oTableProperties);
odt_context->start_table(true);
convert(oox_table->m_oTblGrid.GetPointer());
if (oox_table->m_oTableProperties && (oox_table->m_oTableProperties->m_oTblStyle.IsInit() && oox_table->m_oTableProperties->m_oTblStyle->m_sVal.IsInit()))
{
std::wstring base_style_name = string2std_string(*oox_table->m_oTableProperties->m_oTblStyle->m_sVal);
bool res = odt_context->styles_context()->table_styles().set_current_style(base_style_name);
if (res) odt_context->table_context()->set_table_base_style(base_style_name );
}
int count_rows = oox_table->m_arrItems.GetSize();
int count_columns = 0;
if (oox_table->m_oTblGrid.IsInit())count_columns = oox_table->m_oTblGrid->m_arrGridCol.GetSize();
odt_context->styles_context()->table_styles().set_current_dimension(count_columns, count_rows);
//------
convert(oox_table->m_oTblGrid.GetPointer());
//------
for (int i =0 ; i < oox_table->m_arrItems.GetSize(); i++)
{
switch(oox_table->m_arrItems[i]->getType())
......@@ -1714,14 +1769,6 @@ bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr)
odf::style_table_properties * table_properties = odt_context->styles_context()->last_state().get_table_properties();
if (oox_table_pr->m_oTblStyle.IsInit() && oox_table_pr->m_oTblStyle->m_sVal.IsInit())
{
std::wstring base_style_name = string2std_string(*oox_table_pr->m_oTblStyle->m_sVal);
bool res = odt_context->styles_context()->table_styles().set_current_style(base_style_name);
if (res) odt_context->table_context()->set_table_base_style(base_style_name );
}
convert(oox_table_pr, table_properties);
if (oox_table_pr->m_oTblBorders.IsInit())
......@@ -1843,19 +1890,19 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr)
if (is_base_styled)
{
int col=odt_context->table_context()->current_column();
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
odf::style_paragraph_properties * paragraph_properties = odt_context->styles_context()->last_state().get_paragraph_properties();
int col=odt_context->table_context()->current_column()+1;
int row=odt_context->table_context()->current_row();
odf::style_table_cell_properties *base_style = odt_context->styles_context()->table_styles().get_table_cell_properties(col, row);
cell_properties->apply_from(base_style);
odt_context->styles_context()->table_styles().get_table_cell_properties (col, row, cell_properties);
odt_context->styles_context()->table_styles().get_text_properties (col, row, text_properties);
odt_context->styles_context()->table_styles().get_paragraph_properties (col, row, paragraph_properties);
}
cell_properties->apply_from(parent_cell_properties);
bool res = convert(oox_table_cell_pr, cell_properties);
return true;
}
......
......@@ -138,6 +138,7 @@ namespace Oox2Odf
SimpleTypes::CUcharHexNumber<>* theme_shade, _CP_OPT(odf::color) & odf_color);
void convert(OOX::CDocDefaults *def_style);
void convert(OOX::CStyle *style);
void convert_table_style(OOX::CStyle *oox_style);
void convert(OOX::Logic::CCommentRangeStart *oox_comm_start);
void convert(OOX::Logic::CCommentRangeEnd *oox_comm_end);
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//86
#define INTVER 1,2,0,86
#define STRVER "1,2,0,86\0"
//88
#define INTVER 1,2,0,88
#define STRVER "1,2,0,88\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