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

буквица

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57152 954022d7-b5bf-4e40-9824-e11837661b57
parent bb37a6df
...@@ -1002,7 +1002,6 @@ void odf_chart_context::set_legend_position(int val) ...@@ -1002,7 +1002,6 @@ void odf_chart_context::set_legend_position(int val)
case 3: legend->chart_legend_attlist_.chart_legend_position_ = L"end"; break;//st_legendposR case 3: legend->chart_legend_attlist_.chart_legend_position_ = L"end"; break;//st_legendposR
case 4: legend->chart_legend_attlist_.chart_legend_position_ = L"top"; break;//st_legendposT case 4: legend->chart_legend_attlist_.chart_legend_position_ = L"top"; break;//st_legendposT
} }
legend->chart_legend_attlist_.chart_legend_align_ = L"center";
} }
void odf_chart_context::set_layout_x(double *val,int mode)//edge, factor void odf_chart_context::set_layout_x(double *val,int mode)//edge, factor
{ {
...@@ -1339,7 +1338,7 @@ void odf_chart_context::Impl::create_local_table_rows(ods_table_state * table_st ...@@ -1339,7 +1338,7 @@ void odf_chart_context::Impl::create_local_table_rows(ods_table_state * table_st
table_state->start_cell(cell_elm,office_element_ptr()); table_state->start_cell(cell_elm,office_element_ptr());
table_state->set_cell_value(cells[i].val, true); table_state->set_cell_value(cells[i].val, true);
//add type //add type ???
table_state->end_cell(); table_state->end_cell();
curr_cell = cells[i].col; curr_cell = cells[i].col;
...@@ -1430,16 +1429,47 @@ void odf_chart_context::Impl::create_local_table() ...@@ -1430,16 +1429,47 @@ void odf_chart_context::Impl::create_local_table()
for (long i=0; i < max_columns; i++) for (long i=0; i < max_columns; i++)
cols_elm->add_child_element(col_elm); cols_elm->add_child_element(col_elm);
if (cells_cash_label.size() > 0) office_element_ptr row_headers_elm;
office_element_ptr row_elm;
if (cells_cash_label.size() > 0 || cells_cash.size() > 0)
{
if (cells_cash_label.size() > 0)
{
create_element(L"table", L"table-header-rows",row_headers_elm, odf_context_);
table_state->start_headers(row_headers_elm);
create_local_table_rows(table_state, cells_cash_label ,true);
table_state->end_headers();
}
if (cells_cash.size() > 0) create_local_table_rows(table_state, cells_cash ,false);
else
{
create_element(L"table", L"table-rows",row_elm, odf_context_);
table_state->add_row(row_elm,1,office_element_ptr());
}
}
else
{ {
office_element_ptr row_headers_elm;
create_element(L"table", L"table-header-rows",row_headers_elm, odf_context_); create_element(L"table", L"table-header-rows",row_headers_elm, odf_context_);
table_state->start_headers(row_headers_elm); table_state->start_headers(row_headers_elm);
create_local_table_rows(table_state, cells_cash_label ,true); {
create_element(L"table", L"table-row",row_elm, odf_context_);
table_state->add_row(row_elm,1,office_element_ptr());
{
office_element_ptr cell_elm;
create_element(L"table", L"table-cell",cell_elm, odf_context_);
table_state->start_cell(cell_elm,office_element_ptr());
table_state->end_cell();
}
}
table_state->end_headers(); table_state->end_headers();
create_element(L"table", L"table-rows",row_elm, odf_context_);
table_state->add_row(row_elm,1,office_element_ptr());
} }
create_local_table_rows(table_state, cells_cash ,false);
} }
delete table_state; delete table_state;
......
...@@ -61,6 +61,7 @@ void odf_text_context::add_text_content(const std::wstring & text) ...@@ -61,6 +61,7 @@ void odf_text_context::add_text_content(const std::wstring & text)
{ {
if (current_level_.size() > 0 ) if (current_level_.size() > 0 )
current_level_.back()->add_text(text); current_level_.back()->add_text(text);
} }
} }
void odf_text_context::start_paragraph(bool styled) void odf_text_context::start_paragraph(bool styled)
...@@ -144,6 +145,7 @@ void odf_text_context::end_paragraph() ...@@ -144,6 +145,7 @@ void odf_text_context::end_paragraph()
{ {
current_level_.pop_back(); current_level_.pop_back();
} }
paragraph_properties_ = NULL;
} }
void odf_text_context::start_element(office_element_ptr & elm) void odf_text_context::start_element(office_element_ptr & elm)
...@@ -192,9 +194,13 @@ void odf_text_context::start_span(bool styled) ...@@ -192,9 +194,13 @@ void odf_text_context::start_span(bool styled)
text_span* span = dynamic_cast<text_span*>(span_elm.get()); text_span* span = dynamic_cast<text_span*>(span_elm.get());
if (span) span->text_style_name_ = style_ref(style_name); if (span) span->text_style_name_ = style_ref(style_name);
if (parent_span_style_.length() >0 && style_) if (style_)
{ {
style_->style_parent_style_name_ = parent_span_style_; if (parent_span_style_.length() >0)
{
style_->style_parent_style_name_ = parent_span_style_;
}
text_properties_ = style_->style_content_.get_style_text_properties();//
} }
} }
...@@ -214,6 +220,8 @@ void odf_text_context::end_span() ...@@ -214,6 +220,8 @@ void odf_text_context::end_span()
if (current_level_.size() > 0) if (current_level_.size() > 0)
current_level_.pop_back(); current_level_.pop_back();
text_properties_ = NULL;
} }
void odf_text_context::add_textline_break() void odf_text_context::add_textline_break()
{ {
...@@ -233,30 +241,21 @@ void odf_text_context::add_text_style(office_element_ptr & style_elm, std::wstri ...@@ -233,30 +241,21 @@ void odf_text_context::add_text_style(office_element_ptr & style_elm, std::wstri
{ {
if (style_name.size() < 1 || !style_elm)return; if (style_name.size() < 1 || !style_elm)return;
if (text_elements_list_.size() < 1 )return; if (current_level_.size() < 1 )return;
if (text_span* span = dynamic_cast<text_span*>(text_elements_list_.back().elm.get())) if (text_span* span = dynamic_cast<text_span*>(current_level_.back().get()))
{ {
span->text_style_name_ = style_ref(style_name); 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())) if (text_p* p = dynamic_cast<text_p*>(current_level_.back().get()))
{ {
p->paragraph_.paragraph_attrs_.text_style_name_ = style_ref(style_name); 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;
} }
if (text_h* h = dynamic_cast<text_h*>(text_elements_list_.back().elm.get())) if (text_h* h = dynamic_cast<text_h*>(current_level_.back().get()))
{ {
h->paragraph_.paragraph_attrs_.text_style_name_ = style_ref(style_name); h->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_tab() void odf_text_context::add_tab()
......
...@@ -347,7 +347,6 @@ void ods_table_state::set_row_height(double height) ...@@ -347,7 +347,6 @@ void ods_table_state::set_row_height(double height)
rows_.back().size = height;//pt rows_.back().size = height;//pt
row_properties->style_table_row_properties_attlist_.style_row_height_ = length(height,length::pt);//length(length(height,length::pt).get_value_unit(length::cm),length::cm); row_properties->style_table_row_properties_attlist_.style_row_height_ = length(height,length::pt);//length(length(height,length::pt).get_value_unit(length::cm),length::cm);
} }
bool ods_table_state::is_cell_hyperlink() bool ods_table_state::is_cell_hyperlink()
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include "styles.h" #include "styles.h"
#include "style_paragraph_properties.h"
#include "style_table_properties.h" #include "style_table_properties.h"
#include "style_section_properties.h" #include "style_section_properties.h"
#include "style_text_properties.h"
#include "office_text.h" #include "office_text.h"
#include "paragraph_elements.h" #include "paragraph_elements.h"
...@@ -17,6 +19,22 @@ ...@@ -17,6 +19,22 @@
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
namespace utils
{
double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name, double font_size)
{
double appr_px = 0;//(int)_gdi_graphics_::calculate_size_symbol_asc(metrix.font_name,metrix.font_size,metrix.italic,metrix.bold);
if (appr_px <0.01)
{
appr_px = /*(int)*/_gdi_graphics_::calculate_size_symbol(font_name,font_size,false,false, str_test);
//appr_px = ((int)(appr_px+0.5) + 2*(int)appr_px)/3.;
}
return appr_px*0.55;
}
}
odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument) odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context(outputDocument),comment_context_(this), page_layout_context_(this), main_text_context_(NULL) : odf_conversion_context(outputDocument),comment_context_(this), page_layout_context_(this), main_text_context_(NULL)
{ {
...@@ -24,6 +42,7 @@ odt_conversion_context::odt_conversion_context(package::odf_document * outputDoc ...@@ -24,6 +42,7 @@ odt_conversion_context::odt_conversion_context(package::odf_document * outputDoc
current_field_.started = false; current_field_.started = false;
is_hyperlink_ = false; is_hyperlink_ = false;
drop_cap_state_.clear();
} }
odt_conversion_context::~odt_conversion_context() odt_conversion_context::~odt_conversion_context()
...@@ -106,6 +125,23 @@ void odt_conversion_context::end_text_context() ...@@ -106,6 +125,23 @@ void odt_conversion_context::end_text_context()
} }
void odt_conversion_context::add_text_content(std::wstring & text) void odt_conversion_context::add_text_content(std::wstring & text)
{ {
if (drop_cap_state_.enabled)
{
int count = text.size();
drop_cap_state_.characters += count;
if (drop_cap_state_.inline_style == false)
{
style_text_properties * props = text_context()->get_text_properties();
if (props)
{
std::wstring f_name = props->content().fo_font_family_.get_value_or(L"Arial");
double f_size = props->content().fo_font_size_.get_value_or(font_size(length(12,length::pt))).get_length().get_value_unit(length::pt);
drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size);
}
}
}
text_context()->add_text_content(text); text_context()->add_text_content(text);
} }
void odt_conversion_context::start_drawings() void odt_conversion_context::start_drawings()
...@@ -293,11 +329,11 @@ void odt_conversion_context::end_paragraph() ...@@ -293,11 +329,11 @@ void odt_conversion_context::end_paragraph()
sections_.back().empty = false; sections_.back().empty = false;
} }
} }
void odt_conversion_context::start_run() void odt_conversion_context::start_run(bool styled)
{ {
if (is_hyperlink_ && text_context_.size() > 0) return; if (is_hyperlink_ && text_context_.size() > 0) return;
text_context()->start_span(); text_context()->start_span(styled);
} }
void odt_conversion_context::end_run() void odt_conversion_context::end_run()
{ {
...@@ -365,5 +401,63 @@ void odt_conversion_context::start_image(std::wstring & image_file_name) ...@@ -365,5 +401,63 @@ void odt_conversion_context::start_image(std::wstring & image_file_name)
drawing_context()->start_image(odf_ref_name); drawing_context()->start_image(odf_ref_name);
} }
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
{
if (drop_cap_state_.enabled) end_drop_cap(); // 2 ïîäðÿä âàùå âîçìîæíû ???
if (paragraph_properties == NULL) return;
drop_cap_state_.enabled = true;
drop_cap_state_.paragraph_properties = paragraph_properties;
office_element_ptr comm_elm;
create_element(L"style", L"drop-cap",drop_cap_state_.paragraph_properties->content().style_drop_cap_,this);
}
void odt_conversion_context::set_drop_cap_lines(int lines)
{
if (!drop_cap_state_.enabled) return;
if (!drop_cap_state_.paragraph_properties) return;
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content().style_drop_cap_.get());
if (drop_cap)drop_cap->style_lines_ = lines;
}
void odt_conversion_context::set_drop_cap_margin(bool val)
{
if (!drop_cap_state_.enabled) return;
drop_cap_state_.inline_style = !val;
}
void odt_conversion_context::end_drop_cap()
{
if (!drop_cap_state_.enabled) return;
if (drop_cap_state_.characters >0 && drop_cap_state_.paragraph_properties)
{
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content().style_drop_cap_.get());
if (drop_cap)
{
drop_cap->style_length_ = drop_cap_length(drop_cap_state_.characters);
}
if (drop_cap_state_.inline_style == false)
{
//ñäâèíóòü ïåðâóþ ñòðîêó - òàê ÷òîá áóêâèöà âñÿ (÷òî ïîìåñòèòñÿ) áûëà íà ïîëå
//double indent_pt = 0;
//double indent_percent = 0;
//if (drop_cap_state_.paragraph_properties->content().fo_text_indent_)
//{
// if ( drop_cap_state_.paragraph_properties->content().fo_text_indent_->get_type() == length_or_percent::Length)
// indent_pt = drop_cap_state_.paragraph_properties->content().fo_text_indent_->get_length().get_value_unit(length::pt);
// else
// indent_percent = drop_cap_state_.paragraph_properties->content().fo_text_indent_->get_percent()->get_value();
//}
drop_cap_state_.paragraph_properties->content().fo_text_indent_ = length(length(-drop_cap_state_.characters_size_pt,length::pt).get_value_unit(length::cm),length::cm);
//drop_cap_state_.characters * size_char;
}
}
drop_cap_state_.clear();
}
} }
} }
...@@ -55,13 +55,18 @@ public: ...@@ -55,13 +55,18 @@ public:
void end_field(); void end_field();
void set_field_instr(std::wstring instr); void set_field_instr(std::wstring instr);
void start_run(); void start_run(bool styled = false);
void end_run(); void end_run();
void add_section(); void add_section();
void add_section_columns(int count, double space_pt, bool separator ); void add_section_columns(int count, double space_pt, bool separator );
void add_section_column(std::vector<std::pair<double,double>> width_space); void add_section_column(std::vector<std::pair<double,double>> width_space);
void start_drop_cap(style_paragraph_properties * paragraph_properties);
void set_drop_cap_lines(int lines);
void set_drop_cap_margin(bool val);
void end_drop_cap();
bool start_comment(int oox_comment_id); bool start_comment(int oox_comment_id);
void end_comment(int oox_comment_id); void end_comment(int oox_comment_id);
...@@ -82,7 +87,7 @@ private: ...@@ -82,7 +87,7 @@ private:
std::vector<office_element_ptr> current_paragraphs_; // for section, if needed std::vector<office_element_ptr> current_paragraphs_; // for section, if needed
std::vector<odt_section_state> sections_; std::vector<odt_section_state> sections_;
struct _field struct _field_state
{ {
bool enabled; bool enabled;
int type; int type;
...@@ -92,6 +97,18 @@ private: ...@@ -92,6 +97,18 @@ private:
bool is_hyperlink_; bool is_hyperlink_;
struct _drop_cap_state
{
void clear(){enabled = false; paragraph_properties = NULL; characters = 0; inline_style = true; characters_size_pt =0;}
bool enabled;
style_paragraph_properties *paragraph_properties;
int characters;
bool inline_style;
double characters_size_pt;
}drop_cap_state_;
}; };
......
...@@ -70,10 +70,10 @@ void style_drop_cap::serialize(std::wostream & strm) ...@@ -70,10 +70,10 @@ void style_drop_cap::serialize(std::wostream & strm)
{ {
CP_XML_NODE_SIMPLE() CP_XML_NODE_SIMPLE()
{ {
CP_XML_ATTR (L"style:length", style_length_); CP_XML_ATTR_OPT(L"style:length", style_length_);
CP_XML_ATTR (L"style:lines", style_lines_); CP_XML_ATTR_OPT(L"style:lines", style_lines_);
CP_XML_ATTR_OPT(L"style:distance", style_distance_); CP_XML_ATTR_OPT(L"style:distance", style_distance_);
CP_XML_ATTR_OPT(L"style:style-name", style_style_name_); CP_XML_ATTR_OPT(L"style:style-name",style_style_name_);
} }
} }
...@@ -195,6 +195,10 @@ void paragraph_format_properties::serialize(std::wostream & _Wostream ,const wch ...@@ -195,6 +195,10 @@ void paragraph_format_properties::serialize(std::wostream & _Wostream ,const wch
CP_XML_ATTR_OPT(L"style:background-transparency", style_background_transparency_); CP_XML_ATTR_OPT(L"style:background-transparency", style_background_transparency_);
CP_XML_ATTR_OPT(L"style:join_border", style_join_border_); CP_XML_ATTR_OPT(L"style:join_border", style_join_border_);
if (style_tab_stops_) style_tab_stops_->serialize(CP_XML_STREAM());
if (style_drop_cap_) style_drop_cap_->serialize(CP_XML_STREAM());
if (style_background_image_)style_background_image_->serialize(CP_XML_STREAM());
} }
} }
} }
......
...@@ -116,12 +116,11 @@ public: ...@@ -116,12 +116,11 @@ public:
virtual void add_child_element(office_element_ptr & child){} virtual void add_child_element(office_element_ptr & child){}
virtual void serialize(std::wostream & strm); virtual void serialize(std::wostream & strm);
drop_cap_length style_length_; _CP_OPT(drop_cap_length) style_length_;
unsigned int style_lines_; _CP_OPT(unsigned int) style_lines_;
_CP_OPT(length) style_distance_; _CP_OPT(length) style_distance_;
_CP_OPT(style_ref) style_style_name_; _CP_OPT(style_ref) style_style_name_;
_CP_OPT(common_xlink_attlist) common_xlink_attlist_; _CP_OPT(common_xlink_attlist) common_xlink_attlist_;
}; };
......
...@@ -35,6 +35,9 @@ DocxConverter::DocxConverter(const std::wstring & path) ...@@ -35,6 +35,9 @@ DocxConverter::DocxConverter(const std::wstring & path)
const OOX::CPath oox_path(CString(path.c_str())); const OOX::CPath oox_path(CString(path.c_str()));
docx_document = new OOX::CDocx(oox_path); docx_document = new OOX::CDocx(oox_path);
//set flags to default
m_bKeepNextParagraph = false;
} }
void DocxConverter::write(const std::wstring & path) void DocxConverter::write(const std::wstring & path)
{ {
...@@ -212,16 +215,28 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) ...@@ -212,16 +215,28 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if (oox_paragraph == NULL) return; if (oox_paragraph == NULL) return;
bool styled = false; bool styled = false;
bool bStartNewParagraph = !m_bKeepNextParagraph;
if (oox_paragraph->m_oParagraphProperty) if (oox_paragraph->m_oParagraphProperty)
{ {
styled = true; styled = true;
odf::style_paragraph_properties *paragraph_properties = NULL;
odt_context->styles_context()->create_style(L"",odf::style_family::Paragraph, true, false, -1); if (m_bKeepNextParagraph)
odf::style_paragraph_properties * paragraph_properties = odt_context->styles_context()->last_state().get_paragraph_properties(); {
odf::odf_style_state *state = odt_context->styles_context()->last_state(odf::style_family::Paragraph);
if (state)
paragraph_properties = state->get_paragraph_properties();
}
else
{
odt_context->styles_context()->create_style(L"",odf::style_family::Paragraph, true, false, -1);
paragraph_properties = odt_context->styles_context()->last_state().get_paragraph_properties();
}
convert(oox_paragraph->m_oParagraphProperty, paragraph_properties); convert(oox_paragraph->m_oParagraphProperty, paragraph_properties);
} }
odt_context->start_paragraph(styled); if (bStartNewParagraph) odt_context->start_paragraph(styled);
for ( int nIndex = 0; nIndex < oox_paragraph->m_arrItems.GetSize(); nIndex++ ) for ( int nIndex = 0; nIndex < oox_paragraph->m_arrItems.GetSize(); nIndex++ )
{ {
...@@ -237,15 +252,28 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) ...@@ -237,15 +252,28 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
break; break;
} }
} }
odt_context->end_paragraph(); if (m_bKeepNextParagraph) odt_context->end_drop_cap();
if (bStartNewParagraph && !m_bKeepNextParagraph) odt_context->end_paragraph();
} }
void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87 math 17.3.2.25 void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87 math 17.3.2.25
{ {
if (oox_run == NULL) return; if (oox_run == NULL) return;
odt_context->start_run();
bool styled = false; bool styled = false;
if (oox_run->m_oRunProperty)
{
styled = true;
odt_context->styles_context()->create_style(L"",odf::style_family::Text, true, false, -1);
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
convert(oox_run->m_oRunProperty, text_properties);
}
odt_context->start_run(styled);
for(int i = 0; i < oox_run->m_arrItems.GetSize(); ++i) for(int i = 0; i < oox_run->m_arrItems.GetSize(); ++i)
{ {
// Run - - // Run - -
...@@ -263,17 +291,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87 ...@@ -263,17 +291,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
}break; }break;
case OOX::et_w_rPr: case OOX::et_w_rPr:
{ {
styled = true; // ..
OOX::Logic::CRunProperty* pRProp= static_cast<OOX::Logic::CRunProperty*>(oox_run->m_arrItems[i]);
odt_context->styles_context()->create_style(L"",odf::style_family::Text, true, false, -1);
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
convert(pRProp, text_properties);
odf::odf_style_state * state = odt_context->styles_context()->last_state(odf::style_family::Text);
if (state)
odt_context->text_context()->add_text_style(state->get_office_element(),state->get_name());
}break; }break;
case OOX::et_w_lastRenderedPageBreak: case OOX::et_w_lastRenderedPageBreak:
{ {
...@@ -326,15 +344,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87 ...@@ -326,15 +344,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
convert(oox_run->m_arrItems[i]); convert(oox_run->m_arrItems[i]);
} }
} }
if (styled)
{
//odf::odf_style_state * state = odt_context->styles_context()->last_state(odf::style_family::Text);
//if (state)
// odt_context->text_context()->add_text_style(state->get_office_element(),state->get_name());
//
}
odt_context->end_run(); odt_context->end_run();
} }
void DocxConverter::convert(OOX::Logic::CFldChar *oox_fld) void DocxConverter::convert(OOX::Logic::CFldChar *oox_fld)
{ {
...@@ -362,6 +372,8 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp ...@@ -362,6 +372,8 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
if (!oox_paragraph_pr) return; if (!oox_paragraph_pr) return;
if (!paragraph_properties) return; if (!paragraph_properties) return;
m_bKeepNextParagraph = false;
if (oox_paragraph_pr->m_oPStyle.IsInit() && oox_paragraph_pr->m_oPStyle->m_sVal.IsInit()) if (oox_paragraph_pr->m_oPStyle.IsInit() && oox_paragraph_pr->m_oPStyle->m_sVal.IsInit())
{ {
std::wstring style_name = string2std_string(*oox_paragraph_pr->m_oPStyle->m_sVal); std::wstring style_name = string2std_string(*oox_paragraph_pr->m_oPStyle->m_sVal);
...@@ -500,7 +512,14 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp ...@@ -500,7 +512,14 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
paragraph_properties->content().outline_level_ = level; paragraph_properties->content().outline_level_ = level;
odt_context->text_context()->set_outline_level ( level); odt_context->text_context()->set_outline_level ( level);
} }
if (oox_paragraph_pr->m_oKeepNext.IsInit())
{
m_bKeepNextParagraph = true;
}
convert(oox_paragraph_pr->m_oFramePr.GetPointer(), paragraph_properties); //
convert(oox_paragraph_pr->m_oSectPr.GetPointer()); convert(oox_paragraph_pr->m_oSectPr.GetPointer());
} }
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root) void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root)
...@@ -575,6 +594,31 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r ...@@ -575,6 +594,31 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
odt_context->add_section_column(width_space); odt_context->add_section_column(width_space);
} }
} }
void DocxConverter::convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf::style_paragraph_properties * paragraph_properties)
{
if (oox_frame_pr == NULL) return;
if (paragraph_properties == NULL) return;
odt_context->start_drop_cap(paragraph_properties);
if (oox_frame_pr->m_oDropCap.IsInit() && oox_frame_pr->m_oDropCap->GetValue() == SimpleTypes::dropcapMargin)
odt_context->set_drop_cap_margin(true);
if (oox_frame_pr->m_oLines.IsInit())
odt_context->set_drop_cap_lines(oox_frame_pr->m_oLines->GetValue());
//nullable<SimpleTypes::COnOff<> > m_oAnchorLock;
//nullable<SimpleTypes::CTwipsMeasure > m_oH;
//nullable<SimpleTypes::CHAnchor<> > m_oHAnchor;
//nullable<SimpleTypes::CHeightRule<> > m_oHRule;
//nullable<SimpleTypes::CTwipsMeasure > m_oHSpace;
//nullable<SimpleTypes::CVAnchor<> > m_oVAnchor;
//nullable<SimpleTypes::CTwipsMeasure > m_oVSpace;
//nullable<SimpleTypes::CTwipsMeasure > m_oW;
//nullable<SimpleTypes::CWrap<> > m_oWrap;
//nullable<SimpleTypes::CSignedTwipsMeasure > m_oX;
//nullable<SimpleTypes::CXAlign<> > m_oXAlign;
//nullable<SimpleTypes::CSignedTwipsMeasure > m_oY;
//nullable<SimpleTypes::CYAlign<> > m_oYAlign;
}
void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties * paragraph_properties) void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties * paragraph_properties)
{ {
if (oox_border == NULL) return; if (oox_border == NULL) return;
......
...@@ -45,6 +45,7 @@ namespace ComplexTypes ...@@ -45,6 +45,7 @@ namespace ComplexTypes
class CJc; class CJc;
class CBorder; class CBorder;
class CShading; class CShading;
class CFramePr;
} }
} }
namespace cpdoccore namespace cpdoccore
...@@ -94,8 +95,9 @@ namespace Oox2Odf ...@@ -94,8 +95,9 @@ 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, odf::style_paragraph_properties *paragraph_properties); void convert(OOX::Logic::CParagraphProperty *oox_paragraph_prop, odf::style_paragraph_properties *paragraph_properties);
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf::style_text_properties *text_properties);
void convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties *paragraph_properties); void convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties *paragraph_properties);
void convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf::style_paragraph_properties *paragraph_properties);
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf::style_text_properties *text_properties);
void convert(ComplexTypes::Word::CShading *oox_shading, odf::style_text_properties *text_properties ); void convert(ComplexTypes::Word::CShading *oox_shading, odf::style_text_properties *text_properties );
void convert(OOX::Logic::CFldChar *oox_fld); void convert(OOX::Logic::CFldChar *oox_fld);
void convert(OOX::Logic::CInstrText *oox_instr); void convert(OOX::Logic::CInstrText *oox_instr);
...@@ -126,5 +128,9 @@ namespace Oox2Odf ...@@ -126,5 +128,9 @@ namespace Oox2Odf
void convert(OOX::Logic::CCommentRangeStart *oox_comm_start); void convert(OOX::Logic::CCommentRangeStart *oox_comm_start);
void convert(OOX::Logic::CCommentRangeEnd *oox_comm_end); void convert(OOX::Logic::CCommentRangeEnd *oox_comm_end);
void convert(OOX::Logic::CCommentReference *oox_comm_ref); void convert(OOX::Logic::CCommentReference *oox_comm_ref);
//--------------------------------------------------------------------------------
bool m_bKeepNextParagraph;
}; };
} }
\ No newline at end of file
...@@ -81,14 +81,19 @@ namespace _gdi_graphics_ ...@@ -81,14 +81,19 @@ namespace _gdi_graphics_
Gdiplus::GdiplusShutdown(gdiplusToken); Gdiplus::GdiplusShutdown(gdiplusToken);
return result; return result;
} }
double static calculate_size_symbol(std::wstring name, double size, bool italic, bool bold) double static calculate_size_symbol(std::wstring name, double size, bool italic, bool bold, std::wstring test_str = L"")
{ {
double result =0; double result =0;
Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken=0; ULONG_PTR gdiplusToken=0;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
//// ////
std::wstring test_string = L"0123456789"; bool to_one_char = false;
if (test_str.length() <1 )
{
test_str = L"0123456789";
to_one_char = true;
}
int style = Gdiplus::FontStyleRegular; int style = Gdiplus::FontStyleRegular;
if (bold && italic) style = Gdiplus::FontStyleBoldItalic; if (bold && italic) style = Gdiplus::FontStyleBoldItalic;
...@@ -105,9 +110,10 @@ namespace _gdi_graphics_ ...@@ -105,9 +110,10 @@ namespace _gdi_graphics_
Gdiplus::SizeF layout; Gdiplus::SizeF layout;
Gdiplus::RectF bound; Gdiplus::RectF bound;
Gdiplus::Status res = gr->MeasureString(test_string.c_str(),test_string.length(),font,layout,&bound); Gdiplus::Status res = gr->MeasureString(test_str.c_str(),test_str.length(),font,layout,&bound);
if (res==0)result = (bound.Width - 2)/ test_string.length(); if (res==0)result = (bound.Width - 2);
if (to_one_char) result /= test_str.length();
//normalize to dpi = 96; //normalize to dpi = 96;
double dpi = gr->GetDpiX(); double dpi = gr->GetDpiX();
......
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