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

(1.2.0.84): ASCOfficeOdfFileW

24896
конвертация документов - форматирование параграфов и текста. полностью
доделаны диаграммы, шейпы, картинки.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56846 954022d7-b5bf-4e40-9824-e11837661b57
parent 5f9c25a9
...@@ -307,6 +307,7 @@ void common_value_and_type_attlist::apply_from(const common_value_and_type_attli ...@@ -307,6 +307,7 @@ void common_value_and_type_attlist::apply_from(const common_value_and_type_attli
} }
void common_value_and_type_attlist::serialize(CP_ATTR_NODE) void common_value_and_type_attlist::serialize(CP_ATTR_NODE)
{ {
CP_XML_ATTR_OPT(L"office:value-type", office_value_type_);
CP_XML_ATTR_OPT(L"office:value", office_value_); CP_XML_ATTR_OPT(L"office:value", office_value_);
if (office_value_) if (office_value_)
{ {
...@@ -316,7 +317,6 @@ void common_value_and_type_attlist::serialize(CP_ATTR_NODE) ...@@ -316,7 +317,6 @@ void common_value_and_type_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"office:time-value", office_time_value_); CP_XML_ATTR_OPT(L"office:time-value", office_time_value_);
CP_XML_ATTR_OPT(L"office:boolean-value", office_boolean_value_); CP_XML_ATTR_OPT(L"office:boolean-value", office_boolean_value_);
CP_XML_ATTR_OPT(L"office:string-value", office_string_value_); CP_XML_ATTR_OPT(L"office:string-value", office_string_value_);
CP_XML_ATTR_OPT(L"office:value-type", office_value_type_);
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
void set_local_table(bool Val); void set_local_table(bool Val);
//void set_cash(std::wstring format, std::vector<double> &data); //void set_cash(std::wstring format, std::vector<double> &data);
void set_cash(std::wstring format, std::vector<std::wstring> &data); void set_cash(std::wstring format, std::vector<std::wstring> &data,bool label = false);
void end_chart(); void end_chart();
......
...@@ -182,7 +182,56 @@ void odf_text_context::end_span() ...@@ -182,7 +182,56 @@ void odf_text_context::end_span()
current_level_.pop_back(); current_level_.pop_back();
} }
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::add_text_style(office_element_ptr & style_elm, std::wstring style_name)
{
if (text_elements_list_.size() < 1 )return;
if (text_span* span = dynamic_cast<text_span*>(text_elements_list_.back().elm.get()))
{
span->text_style_name_ = style_ref(style_name);
text_elements_list_.back().style_elm = style_elm;
text_elements_list_.back().style_name = style_name;
}
if (text_p* p = dynamic_cast<text_p*>(text_elements_list_.back().elm.get()))
{
p->paragraph_.paragraph_attrs_.text_style_name_ = style_ref(style_name);
text_elements_list_.back().style_elm = style_elm;
text_elements_list_.back().style_name = style_name;
}
}
void odf_text_context::add_page_break()
{
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()))
{
in_span = true;
end_span(); // todoo -
}
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
//end paragraph + style add after-break = page
//start paragraph - continues style
if (in_span)
{
start_span(false);
}
}
void odf_text_context::set_parent_paragraph_style(std::wstring & style_name) void odf_text_context::set_parent_paragraph_style(std::wstring & style_name)
{ {
parent_paragraph_style_ = style_name; parent_paragraph_style_ = style_name;
......
...@@ -39,6 +39,8 @@ public: ...@@ -39,6 +39,8 @@ public:
public: public:
void set_styles_context(odf_style_context* styles_context);// embedded void set_styles_context(odf_style_context* 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); void set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props);
void add_text_content(const std::wstring & text); void add_text_content(const std::wstring & text);
...@@ -52,6 +54,9 @@ public: ...@@ -52,6 +54,9 @@ public:
void start_span(bool styled = false); void start_span(bool styled = false);
void end_span(); void end_span();
void add_textline_break();
void add_page_break();
std::vector<office_element_ptr> current_level_;// std::vector<office_element_ptr> current_level_;//
std::vector<odf_text_state> text_elements_list_;//, , ... std::vector<odf_text_state> text_elements_list_;//, , ...
......
...@@ -196,6 +196,17 @@ void ods_table_state::end_group() ...@@ -196,6 +196,17 @@ void ods_table_state::end_group()
current_level_.pop_back(); current_level_.pop_back();
} }
void ods_table_state::start_headers(office_element_ptr & elm)
{
current_level_.back()->add_child_element(elm);
current_level_.push_back(elm);
}
void ods_table_state::end_headers()
{
current_level_.pop_back();
}
void ods_table_state::add_column(office_element_ptr & elm, __int16 repeated,office_element_ptr & style_elm) void ods_table_state::add_column(office_element_ptr & elm, __int16 repeated,office_element_ptr & style_elm)
{ {
current_level_.back()->add_child_element(elm); current_level_.back()->add_child_element(elm);
...@@ -601,7 +612,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula) ...@@ -601,7 +612,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
//test external link //test external link
{ {
boost::wregex re(L"(\[\\d+\])"); boost::wregex re(L"([\[]\\d+\[\]])+");
boost::wsmatch result; boost::wsmatch result;
bool b = boost::regex_search(formula, result, re); bool b = boost::regex_search(formula, result, re);
......
...@@ -194,6 +194,9 @@ public: ...@@ -194,6 +194,9 @@ public:
__int32 current_level() {return current_level_.size()-1;} __int32 current_level() {return current_level_.size()-1;}
void start_headers(office_element_ptr & elm);
void end_headers();
void add_row(office_element_ptr & elm, __int16 repeated ,office_element_ptr & style);//const std::wstring & StyleName, const std::wstring & defaultCellStyleName); void add_row(office_element_ptr & elm, __int16 repeated ,office_element_ptr & style);//const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
void set_row_hidden(bool Val); void set_row_hidden(bool Val);
void set_row_optimal_height(bool val); void set_row_optimal_height(bool val);
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <cpdoccore/xml/serialize.h> #include <cpdoccore/xml/serialize.h>
#include <cpdoccore/xml/attributes.h> #include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
...@@ -59,7 +57,10 @@ bool is_text_content(const std::wstring & ns, const std::wstring & name) ...@@ -59,7 +57,10 @@ bool is_text_content(const std::wstring & ns, const std::wstring & name)
return false; return false;
} }
} }
void office_text_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"text:use-soft-page-breaks", text_use_soft_page_breaks_);
}
void office_text::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) void office_text::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
{ {
if (is_text_content(Ns, Name)) if (is_text_content(Ns, Name))
...@@ -80,6 +81,8 @@ void office_text::serialize(std::wostream & _Wostream) ...@@ -80,6 +81,8 @@ void office_text::serialize(std::wostream & _Wostream)
{ {
CP_XML_NODE_SIMPLE() CP_XML_NODE_SIMPLE()
{ {
office_text_attlist_.serialize(CP_GET_XML_NODE());
BOOST_FOREACH(office_element_ptr & elm, content_) BOOST_FOREACH(office_element_ptr & elm, content_)
{ {
elm->serialize(CP_XML_STREAM()); elm->serialize(CP_XML_STREAM());
......
...@@ -4,13 +4,26 @@ ...@@ -4,13 +4,26 @@
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h> #include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h> #include <cpdoccore/xml/nodetype.h>
#include "office_elements.h" #include "office_elements.h"
#include "office_elements_create.h" #include "office_elements_create.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include "Bool.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
/// \class office_text //office_text_attlist
class office_text_attlist
{
public:
_CP_OPT(Bool) text_use_soft_page_breaks_;
void serialize(CP_ATTR_NODE);
};
/// \brief office:text /// \brief office:text
class office_text : public office_element_impl<office_text> class office_text : public office_element_impl<office_text>
{ {
...@@ -30,6 +43,8 @@ public: ...@@ -30,6 +43,8 @@ public:
// virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name); // virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
// virtual void add_text(const std::wstring & Text); // virtual void add_text(const std::wstring & Text);
office_text_attlist office_text_attlist_;
private: private:
bool text_global_; bool text_global_;
// TODO: office-text-content-prelude: // TODO: office-text-content-prelude:
......
...@@ -299,6 +299,8 @@ void text_format_properties_content::serialize(std::wostream & _Wostream,const w ...@@ -299,6 +299,8 @@ void text_format_properties_content::serialize(std::wostream & _Wostream,const w
CP_XML_ATTR_OPT(L"style:text-overline-color", style_text_overline_color_); CP_XML_ATTR_OPT(L"style:text-overline-color", style_text_overline_color_);
CP_XML_ATTR_OPT(L"style:text-overline-mode", style_text_overline_mode_); CP_XML_ATTR_OPT(L"style:text-overline-mode", style_text_overline_mode_);
CP_XML_ATTR_OPT(L"style:text-overline-style", style_text_overline_style_); CP_XML_ATTR_OPT(L"style:text-overline-style", style_text_overline_style_);
common_border_attlist_.serialize(CP_GET_XML_NODE());
} }
} }
} }
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "office_elements.h" #include "office_elements.h"
#include "office_elements_create.h" #include "office_elements_create.h"
#include "bool.h" #include "common_attlists.h"
#include "style_ref.h"
#include "fontvariant.h" #include "fontvariant.h"
#include "texttransform.h" #include "texttransform.h"
#include "color.h" #include "color.h"
...@@ -261,6 +261,8 @@ public: ...@@ -261,6 +261,8 @@ public:
// style:text-overline-style // style:text-overline-style
_CP_OPT(std::wstring) style_text_overline_style_; _CP_OPT(std::wstring) style_text_overline_style_;
common_border_attlist common_border_attlist_;
}; };
class style_text_properties; class style_text_properties;
......
...@@ -787,7 +787,7 @@ void table_rows_and_groups::add_child_element(office_element_ptr & child_element ...@@ -787,7 +787,7 @@ void table_rows_and_groups::add_child_element(office_element_ptr & child_element
{ {
content_.push_back(child_element); content_.push_back(child_element);
} }
else if (type == typeTableTableRows || type == typeTableTableRow) else if (type == typeTableTableRows || type == typeTableTableRow || type == typeTableTableHeaderRows)
{ {
_CP_PTR(table_rows_no_group) elm = table_rows_no_group::create(Context); _CP_PTR(table_rows_no_group) elm = table_rows_no_group::create(Context);
elm->add_child_element(child_element); elm->add_child_element(child_element);
......
...@@ -25,6 +25,8 @@ namespace Oox2Odf ...@@ -25,6 +25,8 @@ namespace Oox2Odf
} }
Converter::Converter(const std::wstring & path, std::wstring type) Converter::Converter(const std::wstring & path, std::wstring type)
{ {
impl_ = NULL;
if (type == L"text") impl_ = new DocxConverter(path); if (type == L"text") impl_ = new DocxConverter(path);
if (type == L"spreadsheet") impl_ = new XlsxConverter(path); if (type == L"spreadsheet") impl_ = new XlsxConverter(path);
} }
...@@ -40,6 +42,7 @@ namespace Oox2Odf ...@@ -40,6 +42,7 @@ namespace Oox2Odf
} }
void Converter::write(const std::wstring & path) const void Converter::write(const std::wstring & path) const
{ {
if (!impl_)return;
return impl_->write(path); return impl_->write(path);
} }
......
...@@ -18,6 +18,9 @@ namespace cpdoccore ...@@ -18,6 +18,9 @@ namespace cpdoccore
class length_or_percent; class length_or_percent;
class style_paragraph_properties; class style_paragraph_properties;
class style_text_properties; class style_text_properties;
class color;
class length;
class text_align;
} }
} }
namespace OOX namespace OOX
...@@ -318,7 +321,7 @@ public: ...@@ -318,7 +321,7 @@ public:
void convert(OOX::Spreadsheet::CT_Marker *marker, CAtlArray<OOX::Spreadsheet::CT_DPt*> & dPt); void convert(OOX::Spreadsheet::CT_Marker *marker, CAtlArray<OOX::Spreadsheet::CT_DPt*> & dPt);
void convert(OOX::Spreadsheet::CT_ExternalData *external_data); void convert(OOX::Spreadsheet::CT_ExternalData *external_data);
void convert(OOX::Spreadsheet::CT_NumData *num_data); void convert(OOX::Spreadsheet::CT_NumData *num_data);
void convert(OOX::Spreadsheet::CT_StrData *str_data); void convert(OOX::Spreadsheet::CT_StrData *str_data, bool label = false);
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf::font_size) & odf_font_size); void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf::font_size) & odf_font_size);
......
...@@ -835,6 +835,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Marker* marker, CAtlArray<OOX::S ...@@ -835,6 +835,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Marker* marker, CAtlArray<OOX::S
odf_context()->chart_context()->start_data_point_series(1); odf_context()->chart_context()->start_data_point_series(1);
convert(dPt[i]->m_oSpPr.GetPointer()); convert(dPt[i]->m_oSpPr.GetPointer());
convert(dPt[i]->m_marker); convert(dPt[i]->m_marker);
if (dPt[i]->m_explosion && dPt[i]->m_explosion->m_val)
odf_context()->chart_context()->set_series_pie_explosion(*dPt[i]->m_explosion->m_val);
odf_context()->chart_context()->end_element(); odf_context()->chart_context()->end_element();
current_point = set_point+1; current_point = set_point+1;
...@@ -904,7 +906,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SerTx* ser_tx) ...@@ -904,7 +906,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SerTx* ser_tx)
{ {
if (ser_tx->m_strRef->m_f)odf_context()->chart_context()->set_series_label_formula(string2std_string(*ser_tx->m_strRef->m_f)); if (ser_tx->m_strRef->m_f)odf_context()->chart_context()->set_series_label_formula(string2std_string(*ser_tx->m_strRef->m_f));
convert(ser_tx->m_strRef->m_strCache); convert(ser_tx->m_strRef->m_strCache,true);
} }
//if (ser_tx->m_v)odf_context()->chart_context()->set_series_name(string2std_string(*ser_tx->m_v)); //if (ser_tx->m_v)odf_context()->chart_context()->set_series_name(string2std_string(*ser_tx->m_v));
...@@ -1008,7 +1010,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_NumData *num_data) ...@@ -1008,7 +1010,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_NumData *num_data)
odf_context()->chart_context()->set_cash(format, data); odf_context()->chart_context()->set_cash(format, data);
} }
void OoxConverter::convert(OOX::Spreadsheet::CT_StrData *str_data) void OoxConverter::convert(OOX::Spreadsheet::CT_StrData *str_data, bool label)
{ {
if (str_data == NULL)return; if (str_data == NULL)return;
std::vector<std::wstring> data; std::vector<std::wstring> data;
...@@ -1021,6 +1023,6 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_StrData *str_data) ...@@ -1021,6 +1023,6 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_StrData *str_data)
} }
std::wstring format; std::wstring format;
odf_context()->chart_context()->set_cash(format, data); odf_context()->chart_context()->set_cash(format, data,label);
} }
} }
\ No newline at end of file
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
#include "Converter.h" #include "Converter.h"
#include <boost/foreach.hpp>
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPOptional.h>
#include <Common/SimpleTypes_Word.h>
namespace OOX namespace OOX
{ {
class CDocx; class CDocx;
...@@ -18,9 +24,20 @@ namespace OOX ...@@ -18,9 +24,20 @@ namespace OOX
class CDrawing; class CDrawing;
class CGroupShape; class CGroupShape;
class CShape; class CShape;
class CPBdr;
} }
}
}
namespace ComplexTypes
{
namespace Word
{
class CColor;
class CJc;
class CBorder;
class CShading;
}
}
namespace cpdoccore namespace cpdoccore
{ {
namespace odf namespace odf
...@@ -34,6 +51,7 @@ namespace cpdoccore ...@@ -34,6 +51,7 @@ namespace cpdoccore
class odt_conversion_context; class odt_conversion_context;
} }
} }
using namespace cpdoccore; using namespace cpdoccore;
namespace Oox2Odf namespace Oox2Odf
...@@ -64,8 +82,8 @@ namespace Oox2Odf ...@@ -64,8 +82,8 @@ namespace Oox2Odf
void convert(OOX::Logic::CParagraph *oox_paragraph); void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run); void convert(OOX::Logic::CRun *oox_run);
void convert(OOX::Logic::CParagraphProperty *oox_paragraph_prop); void convert(OOX::Logic::CParagraphProperty *oox_paragraph_prop, odf::style_paragraph_properties *paragraph_properties);
void convert(OOX::Logic::CRunProperty *oox_run_prop); void convert(OOX::Logic::CRunProperty *oox_run_prop, odf::style_text_properties *text_properties);
void convert(OOX::Logic::CText *oox_text); void convert(OOX::Logic::CText *oox_text);
void convert(OOX::Logic::CAlternateContent *oox_alt_content); void convert(OOX::Logic::CAlternateContent *oox_alt_content);
void convert(OOX::Logic::CDrawing *oox_drawing); void convert(OOX::Logic::CDrawing *oox_drawing);
...@@ -76,6 +94,15 @@ namespace Oox2Odf ...@@ -76,6 +94,15 @@ namespace Oox2Odf
void convert(OOX::Logic::CShape *oox_shape); void convert(OOX::Logic::CShape *oox_shape);
void convert(OOX::Drawing::CChart *oox_chart); void convert(OOX::Drawing::CChart *oox_chart);
void convert(OOX::Drawing::CPicture *oox_chart); void convert(OOX::Drawing::CPicture *oox_chart);
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf::color) & odf_color);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length) & odf_size);
void convert(ComplexTypes::Word::CJc *oox_jc, _CP_OPT(odf::text_align) & align);
void convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties * paragraph_properties);
void convert(ComplexTypes::Word::CBorder *borderProp, std::wstring & odf_border_prop);
void convert(ComplexTypes::Word::CShading *oox_shading, odf::style_text_properties * text_properties );
void convert(SimpleTypes::CHexColor<> *color, SimpleTypes::CThemeColor<> *theme_color,
SimpleTypes::CUcharHexNumber<>* theme_tint,
SimpleTypes::CUcharHexNumber<>* theme_shade, _CP_OPT(odf::color) & odf_color);
}; };
} }
\ No newline at end of file
...@@ -1045,8 +1045,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf::style_pa ...@@ -1045,8 +1045,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf::style_pa
} }
if (aligment->m_oTextRotation.IsInit()) if (aligment->m_oTextRotation.IsInit())
{ {
cell_properties->style_table_cell_properties_attlist_.common_rotation_angle_attlist_.style_rotation_angle_ = aligment->m_oTextRotation->GetValue(); int rot = aligment->m_oTextRotation->GetValue();
cell_properties->style_table_cell_properties_attlist_.style_rotation_align_= odf::rotation_align(odf::rotation_align::Bottom); if (rot <=180 && rot >= 0 )
{
cell_properties->style_table_cell_properties_attlist_.common_rotation_angle_attlist_.style_rotation_angle_ = rot;
cell_properties->style_table_cell_properties_attlist_.style_rotation_align_= odf::rotation_align(odf::rotation_align::Bottom);
}
else if (rot == 0xff)//
cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf::direction(odf::direction::Ttb);
} }
if(aligment->m_oHorizontal.IsInit()) if(aligment->m_oHorizontal.IsInit())
{ {
......
...@@ -88,10 +88,8 @@ namespace odf ...@@ -88,10 +88,8 @@ namespace odf
} }
class odf_conversion_context; class odf_conversion_context;
class ods_conversion_context; class ods_conversion_context;
class color;
class background_color; class background_color;
class font_size; class font_size;
class length;
} }
} }
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//1 //1
//2 //2
//0 //0
//82 //85
#define INTVER 1,2,0,82 #define INTVER 1,2,0,85
#define STRVER "1,2,0,82\0" #define STRVER "1,2,0,85\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