Commit 369596b8 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix dropCap, sections

parent 15af8f56
......@@ -67,7 +67,7 @@
Name="VCLinkerTool"
AdditionalDependencies="Urlmon.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
IgnoreDefaultLibraryNames=""
IgnoreEmbeddedIDL="true"
GenerateDebugInformation="true"
SubSystem="1"
......
......@@ -59,7 +59,7 @@ HRESULT convert_single(std::wstring srcFileName)
switch(fileChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"document"; break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"text"; break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: dstPath += L"-my.ods"; type = L"spreadsheet"; break;
......
......@@ -118,7 +118,7 @@ void odt_conversion_context::start_document()
void odt_conversion_context::end_document()
{
//add sections to root
for (size_t i = 0; i< sections_.size(); i++)
for (size_t i = 0; i < sections_.size(); i++)
{
root_document_->add_child_element(sections_[i].elm);
}
......@@ -183,7 +183,8 @@ odf_text_context* odt_conversion_context::text_context()
}
void odt_conversion_context::start_text_context()
{
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, odf_conversion_context::styles_context()));
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, /*odf_conversion_context::*/styles_context()));
//объекты с текстом в колонтитулах
if (!new_text_context_)return;
text_context_.push_back(new_text_context_);
......@@ -199,17 +200,18 @@ void odt_conversion_context::add_text_content(const std::wstring & text)
{
if (drop_cap_state_.enabled)
{
int count = text.size();
int count = text.length();
drop_cap_state_.characters += count;
if (drop_cap_state_.inline_style == false)
style_text_properties * props = text_context()->get_text_properties();
if (props)
{
style_text_properties * props = text_context()->get_text_properties();
if (props)
if (drop_cap_state_.inline_style == false)
{
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, applicationFonts_);
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, applicationFonts_);
}
}
}
......@@ -479,6 +481,14 @@ int odt_conversion_context::get_current_section_columns()
}
void odt_conversion_context::add_section(bool continuous)
{
//--dump first elements to root------------------------------------------------
for (size_t i = 0; i< current_root_elements_.size(); i++)
{
root_document_->add_child_element(current_root_elements_[i].elm);
}
current_root_elements_.clear();
//----------------------------------------------------------------------------
odt_section_state state;
state.empty = true;
......@@ -662,9 +672,9 @@ void odt_conversion_context::set_no_list()
}
void odt_conversion_context::flush_section()
{
if (sections_.size() > 0 && sections_.back().empty)
if (!sections_.empty() && sections_.back().empty)
{
for (size_t i=0; i< current_root_elements_.size(); i++)
for (size_t i = 0; i < current_root_elements_.size(); i++)
{
if ((sections_.back().continuous && i < 2) || !sections_.back().continuous)
// при вставлении параграфа возможен искусственный разрыв в параграфах - см add_page_break
......@@ -697,7 +707,7 @@ void odt_conversion_context::start_run(bool styled)
if (is_hyperlink_ && text_context_.size() > 0) return;
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && !current_field_.in_span)
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && !current_field_.in_span)
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
......@@ -705,7 +715,14 @@ void odt_conversion_context::start_run(bool styled)
text_context()->start_span(styled);
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
if (drop_cap_state_.enabled)
{
style_text_properties *props = text_context()->get_text_properties();
if (props)
props->apply_from(dynamic_cast<style_text_properties*>(drop_cap_state_.text_properties.get()));
}
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
......@@ -945,7 +962,14 @@ void odt_conversion_context::end_change (int id, int type)
// return (text_changes_state_.current_types.back() == 2);
//}
//--------------------------------------------------------------------------------------------------------
style_text_properties* odt_conversion_context::get_drop_cap_properties()
{
if (!drop_cap_state_.text_properties)
{
create_element(L"style", L"text-properties", drop_cap_state_.text_properties, this);
}
return dynamic_cast<style_text_properties *>(drop_cap_state_.text_properties.get());
}
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
{
if (drop_cap_state_.enabled)
......@@ -967,6 +991,8 @@ void odt_conversion_context::set_drop_cap_lines(int lines)
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;
drop_cap_state_.lines = lines;
}
void odt_conversion_context::set_drop_cap_margin(bool val)
{
......@@ -977,7 +1003,7 @@ void odt_conversion_context::end_drop_cap()
{
if (!drop_cap_state_.enabled) return;
if (drop_cap_state_.characters >0 && drop_cap_state_.paragraph_properties)
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)
......
......@@ -113,6 +113,8 @@ public:
void set_drop_cap_lines (int lines);
void set_drop_cap_margin(bool val);
void end_drop_cap ();
bool in_drop_cap () {return drop_cap_state_.enabled;}
style_text_properties* get_drop_cap_properties();
bool start_comment (int oox_comment_id);
void end_comment (int oox_comment_id);
......@@ -203,14 +205,25 @@ private:
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;
void clear()
{
enabled = false;
paragraph_properties = NULL;
characters = 0;
inline_style = true;
characters_size_pt = 0;
lines = 0;
text_properties = office_element_ptr();
}
bool enabled = false;
style_paragraph_properties *paragraph_properties = NULL;
office_element_ptr text_properties;
int lines = 0;
int characters = 0;
bool inline_style = false;
double characters_size_pt = 0;
}drop_cap_state_;
};
......
......@@ -269,8 +269,15 @@ void style_paragraph_properties::apply_from(style_paragraph_properties * Other)
content_.apply_from(Other->content_);
}
void paragraph_format_properties::clear()
void paragraph_format_properties::clear(bool bEraseDropCap)
{
if (bEraseDropCap)
{
style_drop_cap_ = office_element_ptr();
fo_text_indent_ = boost::none;
}
style_tab_stops_ = office_element_ptr();
style_background_image_ = office_element_ptr();
fo_line_height_ = boost::none;
style_line_height_at_least_ = boost::none;
style_line_spacing_ = boost::none;
......@@ -287,7 +294,6 @@ void paragraph_format_properties::clear()
style_register_true_ = boost::none;
fo_margin_left_ = boost::none;
fo_margin_right_ = boost::none;
//fo_text_indent_ = boost::none;//заточено под буквицу
style_auto_text_indent_ = boost::none;
fo_margin_top_ = boost::none;
fo_margin_bottom_ = boost::none;
......@@ -318,7 +324,11 @@ void paragraph_format_properties::clear()
text_number_lines_ = boost::none;
style_shadow_ = boost::none;
//todooo borders
common_border_attlist_.fo_border_ = boost::none;
common_border_attlist_.fo_border_top_ = boost::none;
common_border_attlist_.fo_border_bottom_= boost::none;
common_border_attlist_.fo_border_left_ = boost::none;
common_border_attlist_.fo_border_right_ = boost::none;
}
void paragraph_format_properties::apply_from(paragraph_format_properties & Other)
......
......@@ -192,9 +192,8 @@ public:
void apply_from( paragraph_format_properties & Other);
void clear();
void clear(bool bEraseDropCap = true);
public:
_CP_OPT(odf_types::length) style_line_height_at_least_;
_CP_OPT(odf_types::length_or_percent) style_line_spacing_;
_CP_OPT(odf_types::Bool) style_font_independent_line_spacing_;
......@@ -277,7 +276,7 @@ public:
virtual void serialize(std::wostream & strm);
paragraph_format_properties content_;
paragraph_format_properties content_;
};
......
......@@ -158,11 +158,11 @@ namespace Oox2Odf
private:
struct _section
{
OOX::Logic::CSectionProperty *props;
std::vector<OOX::WritingElement*>::const_iterator start_para;
std::vector<OOX::WritingElement*>::const_iterator end_para;
OOX::Logic::CSectionProperty *props;
size_t start_para;
size_t end_para;
bool root;
bool bContinue = false;
} *current_section_properties;
OOX::CDocx *docx_document;
cpdoccore::odf_writer::package::odf_document *output_document;
......@@ -184,7 +184,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CBackground *oox_background, int type);
void convert(OOX::Logic::CSdt *oox_sdt);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root = false);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection);
void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run);
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);
......
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