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()
......
......@@ -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){}
......
......@@ -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