Commit 88656048 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormat Reader/Writer reveiw ..

parent 5f1d429b
......@@ -872,13 +872,16 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
CP_XML_STREAM() << get_text_tracked_context().dumpPPr_;
get_text_tracked_context().dumpPPr_.clear();
}
if (run_style.tellp() > 0 && in_styles == false)
if ((run_style.tellp() > 0 && in_styles == false) || !get_text_tracked_context().dumpRPrInsDel_.empty())
{
CP_XML_NODE(L"w:rPr")
{
CP_XML_STREAM() << get_text_tracked_context().dumpRPrInsDel_;
const std::wstring & test_str = run_style.str();
CP_XML_STREAM() << test_str;
}
get_text_tracked_context().dumpRPrInsDel_.clear();
}
}
}
......@@ -1285,7 +1288,8 @@ void docx_conversion_context::start_text_changes (std::wstring id)
output_stream() << L" w:id=\"" << std::to_wstring(current_id_changes++) << "\"";
output_stream() << L">";
if (state.type == 2) output_stream() << state.content;
if (state.type == 2)
output_stream() << state.content;
}
}
......@@ -1293,12 +1297,17 @@ void docx_conversion_context::start_changes()
{
if (map_current_changes_.empty()) return;
text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear();
text_tracked_context_.dumpRPrInsDel_.clear();
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
{
text_tracked_context::_state &state = it->second;
if (state.type == 0) continue; //unknown change ... todooo
std::wstring change_attr;
change_attr += L" w:date=\"" + state.date + L"\"";
change_attr += L" w:author=\"" + state.author + L"\"";
......@@ -1306,13 +1315,12 @@ void docx_conversion_context::start_changes()
if (state.type == 1)
{
output_stream() << L"<w:ins" << change_attr << L">";
text_tracked_context_.dumpRPrInsDel_ = L"<w:ins" + change_attr + L"/>";
}
if (state.type == 2)
{
output_stream() << L"<w:del" << change_attr << L">";
output_stream() << state.content;
text_tracked_context_.dumpRPrInsDel_ = L"<w:del" + change_attr + L"/>";
}
if (state.type == 3)
......@@ -1331,7 +1339,7 @@ void docx_conversion_context::start_changes()
props->docx_convert(*this);
std::wstring attr = get_styles_context().paragraph_attr().str();
text_tracked_context_.dumpPPr_ = L"<w:pPrChange" + change_attr + (attr.empty() ? L">" : (L" " + attr + L">"));
text_tracked_context_.dumpPPr_ += L"<w:pPrChange" + change_attr + (attr.empty() ? L">" : (L" " + attr + L">"));
text_tracked_context_.dumpPPr_ += get_styles_context().paragraph_nodes().str();
if (t_props)
{
......@@ -1366,17 +1374,18 @@ void docx_conversion_context::start_changes()
void docx_conversion_context::end_changes()
{
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
{
text_tracked_context::_state &state = it->second;
//for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
//{
// text_tracked_context::_state &state = it->second;
if (state.type == 0) continue; //unknown change ... libra format change skip
if (state.type == 3) continue;
// if (state.type == 0) continue; //unknown change ... libra format change skip
// if (state.type == 3) continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
}
// if (state.type == 1) output_stream() << L"</w:ins>";
// if (state.type == 2) output_stream() << L"</w:del>";
//}
text_tracked_context_.dumpRPrInsDel_.clear();
text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear();
}
......
......@@ -508,6 +508,7 @@ public:
};
std::wstring dumpPPr_;
std::wstring dumpRPr_;
std::wstring dumpRPrInsDel_;
text_tracked_context(docx_conversion_context & context);
......
......@@ -206,7 +206,7 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
Context.output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
if (!Context.output_stream() << Context.get_text_tracked_context().dumpPPr_.empty())
if (!Context.get_text_tracked_context().dumpPPr_.empty())
{
Context.output_stream() << Context.get_text_tracked_context().dumpPPr_;
Context.get_text_tracked_context().dumpPPr_.clear();
......@@ -218,6 +218,14 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
{
Context.output_stream() << L"<w:outlineLvl w:val=\"" << *Attr.outline_level_ - 1 << L"\" />";
}
if (!Context.get_text_tracked_context().dumpRPrInsDel_.empty())
{
Context.output_stream() << L"<w:rPr>";
Context.output_stream() << Context.get_text_tracked_context().dumpRPrInsDel_;
Context.get_text_tracked_context().dumpRPrInsDel_.clear();
Context.output_stream() << L"</w:rPr>";
}
Context.output_stream() << L"</w:pPr>";
return 2;
}
......
......@@ -439,21 +439,26 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if (oox_paragraph->m_oParagraphProperty->m_oRPr.IsInit())
{
//удаление знака абзаца - объединение со следующим - в либре нету
//id = convert(oox_paragraph->m_oParagraphProperty->m_oRPr->m_oDel.GetPointer(), 2);
//if (id >= 0) id_change_properties.push_back(std::pair<int, int> (2, id)); удаление знака абзаца - объединение со следующим ... todooo
//if (id >= 0) id_change_properties.push_back(std::pair<int, int> (2, id));
id = convert(oox_paragraph->m_oParagraphProperty->m_oRPr->m_oIns.GetPointer(), 1);
if (id >= 0) id_change_properties.push_back(std::pair<int, int> (1, id));
//вставка знака абзаца - разделение текущего параграфа - в либре нету
//if (oox_paragraph->m_arrItems.size() < 2)//только для пустых
{
id = convert(oox_paragraph->m_oParagraphProperty->m_oRPr->m_oIns.GetPointer(), 1);
if (id >= 0) id_change_properties.push_back(std::pair<int, int> (1, id));
}
id = convert(oox_paragraph->m_oParagraphProperty->m_oRPr->m_oRPrChange.GetPointer());
if (id >= 0) id_change_properties.push_back(std::pair<int, int> (3, id));
}
if (oox_paragraph->m_oParagraphProperty->m_oSectPr.IsInit())
{
id = convert(oox_paragraph->m_oParagraphProperty->m_oSectPr->m_oSectPrChange.GetPointer());
if (id >= 0) id_change_properties.push_back(std::pair<int, int> (3, id));
}
//if (oox_paragraph->m_oParagraphProperty->m_oSectPr.IsInit())
//{
// id = convert(oox_paragraph->m_oParagraphProperty->m_oSectPr->m_oSectPrChange.GetPointer());
// if (id >= 0) id_change_properties.push_back(std::pair<int, int> (3, id));
//}
id = convert(oox_paragraph->m_oParagraphProperty->m_oPPrChange.GetPointer());
if (id >= 0) id_change_properties.push_back(std::pair<int, int> (3, id));
......@@ -602,6 +607,8 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
odt_context->end_list_item();
}
//---------------------------------------------------------------------------------------------------------------------
//std::sort(id_change_properties.begin(), id_change_properties.end());
for (int i = 0; i < id_change_properties.size(); i++)
{
odt_context->end_change(id_change_properties[i].second, id_change_properties[i].first);
......@@ -2698,19 +2705,12 @@ void DocxConverter::convert(OOX::Drawing::CInline *oox_inline)
odt_context->drawing_context()->set_drawings_rect(x, y, width, height);
if (odt_context->text_context()->list_state_.started_list)
{
odt_context->drawing_context()->set_anchor(odf_types::anchor_type::Char);
}
else
{
odt_context->drawing_context()->set_anchor(odf_types::anchor_type::AsChar); //плохо в списке с интервалом между строками 200%
}
odt_context->drawing_context()->set_anchor(odf_types::anchor_type::AsChar);
if (oox_inline->m_oDistL.IsInit())odt_context->drawing_context()->set_margin_left(oox_inline->m_oDistL->ToPoints());
if (oox_inline->m_oDistT.IsInit())odt_context->drawing_context()->set_margin_top(oox_inline->m_oDistT->ToPoints());
if (oox_inline->m_oDistR.IsInit())odt_context->drawing_context()->set_margin_right(oox_inline->m_oDistR->ToPoints());
if (oox_inline->m_oDistB.IsInit())odt_context->drawing_context()->set_margin_bottom(oox_inline->m_oDistB->ToPoints());
if (oox_inline->m_oDistL.IsInit()) odt_context->drawing_context()->set_margin_left (oox_inline->m_oDistL->ToPoints());
if (oox_inline->m_oDistT.IsInit()) odt_context->drawing_context()->set_margin_top (oox_inline->m_oDistT->ToPoints());
if (oox_inline->m_oDistR.IsInit()) odt_context->drawing_context()->set_margin_right (oox_inline->m_oDistR->ToPoints());
if (oox_inline->m_oDistB.IsInit()) odt_context->drawing_context()->set_margin_bottom (oox_inline->m_oDistB->ToPoints());
//вертикальное выравнивание относительно строки поставим в середину (иначе по нижнему краю почемуто)
......
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