Commit 959d5e5f authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - presentation - fix multi-level list, master list styles

parent 8ee0cf4b
......@@ -291,8 +291,9 @@ office_element_ptr odf_conversion_context::start_tabs()
}
std::wstring odf_conversion_context::add_image(const std::wstring & image_file_name)
{
std::wstring odf_ref_name ;
if (image_file_name.empty()) return L"";
std::wstring odf_ref_name ;
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage, odf_ref_name);
return odf_ref_name;
......
......@@ -317,6 +317,11 @@ void odf_drawing_context::set_presentation (bool bMaster)
impl_->is_presentation_ = bMaster;
}
_CP_OPT(bool) odf_drawing_context::get_presentation ()
{
return impl_->is_presentation_;
}
void odf_drawing_context::set_footer_state(bool Val)
{
impl_->is_footer_ = Val;
......@@ -491,14 +496,20 @@ void odf_drawing_context::end_drawing()
_CP_OPT(std::wstring) draw_layer;
if (impl_->is_presentation_.get() == true)
{//master
if (impl_->current_drawing_state_.presentation_class_)
draw_layer = L"backgroundobjects";
else draw_layer = L"layout";
draw_layer = L"backgroundobjects";
//if (impl_->current_drawing_state_.presentation_class_)
// draw_layer = L"backgroundobjects";
//else draw_layer = L"layout";
if (!impl_->current_drawing_state_.presentation_class_)
impl_->current_drawing_state_.presentation_class_ = presentation_class::outline;
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_user_transformed_ = true;
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_placeholder_ = false;
}
else
{//slide
if (impl_->current_drawing_state_.presentation_class_)
draw_layer = L"layout";
draw_layer = L"layout";
}
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_class_ = impl_->current_drawing_state_.presentation_class_;
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_layer_ = draw_layer;
......@@ -696,7 +707,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
draw_base* draw = dynamic_cast<draw_base*>(draw_elm.get());
if (draw == NULL)return;
//////////
styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
if (is_presentation_ && current_drawing_state_.presentation_class_)
styles_context_->create_style(L"", style_family::Presentation, true, false, -1);
else
styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
office_element_ptr & style_shape_elm = styles_context_->last_state()->get_office_element();
std::wstring style_name;
......@@ -708,7 +722,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
current_graphic_properties = style_->content_.get_graphic_properties();
}
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
if (is_presentation_ && current_drawing_state_.presentation_class_)
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_style_name_ = style_name;
else
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int level = current_level_.size();
......@@ -1175,16 +1192,16 @@ void odf_drawing_context::set_placeholder_type (int val)
{
switch(val)
{
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::text; break;
case 1: impl_->current_drawing_state_.presentation_class_ = presentation_class::chart; break;
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
case 1: impl_->current_drawing_state_.presentation_class_ = presentation_class::chart; break;
case 2: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 3: impl_->current_drawing_state_.presentation_class_ = presentation_class::title; break;
case 4: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 5: impl_->current_drawing_state_.presentation_class_ = presentation_class::date_time; break;
case 6: impl_->current_drawing_state_.presentation_class_ = presentation_class::footer; break;
case 7: impl_->current_drawing_state_.presentation_class_ = presentation_class::header; break;
case 8: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 9: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 6: impl_->current_drawing_state_.presentation_class_ = presentation_class::footer; break;
case 7: impl_->current_drawing_state_.presentation_class_ = presentation_class::header; break;
case 8: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 9: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 10: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 11: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 12: impl_->current_drawing_state_.presentation_class_ = presentation_class::page_number;break;
......@@ -1192,7 +1209,7 @@ void odf_drawing_context::set_placeholder_type (int val)
case 14: impl_->current_drawing_state_.presentation_class_ = presentation_class::table; break;
case 15: impl_->current_drawing_state_.presentation_class_ = presentation_class::title; break;
default:
impl_->current_drawing_state_.presentation_class_ = presentation_class::text; break;
impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
}
//todooo draw_layer for master for sldnum, datetime ...
}
......@@ -2455,7 +2472,7 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
{
if (text_context == NULL || impl_->current_level_.size() < 1 ) return;
if (impl_->is_presentation_ && *impl_->is_presentation_) return;
//if (impl_->is_presentation_ && *impl_->is_presentation_) return;
for (size_t i = 0; i < text_context->text_elements_list_.size(); i++)
{
......
......@@ -60,7 +60,8 @@ public:
odf_drawing_context (odf_conversion_context *odf_context);
~odf_drawing_context ();
void set_presentation (bool bMaster);
void set_presentation (bool bMaster);
_CP_OPT(bool) get_presentation ();
void set_drawings_rect (_CP_OPT(double) x_pt, _CP_OPT(double) y_pt, _CP_OPT(double) width_pt, _CP_OPT(double) height_pt);
void clear ();
......
......@@ -108,7 +108,7 @@ std::wstring odf_lists_styles_context::get_style_name(int oox_style_num)
return L"";
}
}
void odf_lists_styles_context::start_style(int based_number)
void odf_lists_styles_context::start_style(bool bMaster, int based_number)
{
list_format_state state;
......@@ -120,14 +120,13 @@ void odf_lists_styles_context::start_style(int based_number)
{
state.oox_based_number = lists_format_array_.size();
state.odf_list_style_name = std::wstring(L"L") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
state.automatic = true; //document automatic style
}
else
{
state.oox_based_number = based_number;
state.odf_list_style_name = std::wstring(L"WWNum") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
state.automatic = false; //office style
}
state.automatic = !bMaster;
text_list_style *style = dynamic_cast<text_list_style *>(elm.get());
if (style == NULL)return;
......
......@@ -64,7 +64,7 @@ public:
odf_lists_styles_context();
void set_odf_context(odf_conversion_context * Context);
void start_style(int abstract_number = -1);
void start_style(bool bMaster, int abstract_number = -1);
int start_style_level(int level, int type);
style_list_level_properties * get_list_level_properties();
style_list_level_label_alignment * get_list_level_alignment_properties();
......
......@@ -208,23 +208,25 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
}
}
std::wstring pathImage;
std::wstring odf_ref;
std::wstring pathImage;
if (oox_picture->blipFill.blip.IsInit())
{
std::wstring sID;
bool bEmbedded = true;
if (oox_picture->blipFill.blip->embed.IsInit())
{
sID = oox_picture->blipFill.blip->embed->get();
std::wstring sID = oox_picture->blipFill.blip->embed->get();
pathImage = find_link_by_id(sID, 1);
odf_ref = odf_context()->add_image(pathImage);
}
else if (oox_picture->blipFill.blip->link.IsInit())
{
pathImage = oox_picture->blipFill.blip->link->get();
odf_ref = oox_picture->blipFill.blip->link->get();
bEmbedded = false;
}
}
std::wstring odf_ref = odf_context()->add_image(pathImage);
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_image(odf_ref);
{
......@@ -1098,16 +1100,7 @@ void OoxConverter::convert(PPTX::Logic::NvPr *oox_nvPr)
{
if (!oox_nvPr) return;
if (oox_nvPr->ph.is_init())
{
if (oox_nvPr->ph->type.IsInit())
odf_context()->drawing_context()->set_placeholder_type(oox_nvPr->ph->type->GetBYTECode());
if (oox_nvPr->ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(oox_nvPr->ph->idx.get());
//nullable_bool hasCustomPrompt;
//nullable_limit<Limit::Orient> orient;
//nullable_limit<Limit::PlaceholderSize> sz;
}
//ph уровнем выше
}
void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_props, int level)
......@@ -1157,19 +1150,22 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
odf_list_type = 1000;
const PPTX::Logic::BuBlip & buBlip = bullet.as<PPTX::Logic::BuBlip>();
std::wstring pathImage;
std::wstring sID;
std::wstring odf_ref;
bool bEmbedded = true;
if (buBlip.blip.embed.IsInit())
{
sID = buBlip.blip.embed->get();
pathImage = find_link_by_id(sID, 1);
std::wstring sID = buBlip.blip.embed->get();
std::wstring pathImage = find_link_by_id(sID, 1);
odf_ref = odf_context()->add_image(pathImage);
}
else if (buBlip.blip.link.IsInit())
{
pathImage = buBlip.blip.link->get();
odf_ref = buBlip.blip.link->get();
bEmbedded = false;
}
std::wstring odf_ref = odf_context()->add_image(pathImage);
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type );
odf_context()->styles_context()->lists_styles().set_bullet_image(odf_ref);
......@@ -1289,18 +1285,6 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
odf_context()->styles_context()->lists_styles().end_style_level();
}
void OoxConverter::convert_list (PPTX::Logic::TextListStyle *oox_list_style)
{
if (!oox_list_style) return;
odf_context()->styles_context()->lists_styles().start_style();
for (int i = 0; i < 9; i++)
{
convert_list_level(oox_list_style->levels[0].GetPointer(), i);
}
odf_context()->styles_context()->lists_styles().end_style();
}
void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::TextListStyle *oox_list_style)
{
if (!oox_paragraph)return;
......@@ -1311,7 +1295,7 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
bool list_present = false;
std::wstring list_style_name;
int list_level = 0;
int list_level = -1;
NSCommon::nullable<PPTX::Logic::TextParagraphPr> paraPr;
......@@ -1323,10 +1307,12 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
list_local = true;
}
if (oox_list_style && list_level >= 0 && list_level < 10)
if (oox_list_style)
{
if (oox_list_style->levels[list_level].IsInit())
oox_list_style->levels[list_level]->Merge(paraPr);
int i = (list_level >= 0 && list_level < 10) ? list_level : 0;
if (oox_list_style->levels[i].IsInit())
oox_list_style->levels[i]->Merge(paraPr);
}
if (oox_paragraph->pPr.IsInit())
oox_paragraph->pPr->Merge(paraPr);
......@@ -1341,7 +1327,6 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
list_present = true;
if (paraPr->ParagraphBullet.is<PPTX::Logic::BuNone>())
list_present = false;
else if (list_level == 0) list_level = 1;
}
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
odf_writer::style_paragraph_properties* paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
......@@ -1361,6 +1346,7 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
if (odf_context()->drawing_context()->is_wordart())
odf_context()->drawing_context()->set_paragraph_properties(paragraph_properties);
}
list_level++;
if (oox_paragraph->RunElems.empty() && list_present) list_present = false; // ms не обозначает присутствие списка, libra - показывает значек
......@@ -1381,29 +1367,31 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
{
if (list_local)
{
odf_context()->styles_context()->lists_styles().start_style();
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
convert_list_level(oox_paragraph->pPr.GetPointer(), list_level - 1);
odf_context()->styles_context()->lists_styles().end_style();
list_style_name = odf_context()->styles_context()->lists_styles().get_style_name(); //last added
}
else
{
// !!!
}
list_style_name = odf_context()->styles_context()->lists_styles().get_style_name(); //last added
odf_context()->text_context()->start_list(list_style_name);
//odf_context()->text_context()->start_list(list_style_name);
}
odf_context()->text_context()->start_list_item();
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
list_style_name = L"";
while (odf_context()->text_context()->list_state_.levels.size() < list_level)
if (odf_context()->text_context()->list_state_.levels.size() < list_level)
{
odf_context()->text_context()->start_list(list_style_name);
odf_context()->text_context()->start_list_item();
while (odf_context()->text_context()->list_state_.levels.size() < list_level)
{
odf_context()->text_context()->start_list(list_style_name);
odf_context()->text_context()->start_list_item();
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
list_style_name = L"";
}
}
else
odf_context()->text_context()->start_list_item();
}
else if (odf_context()->text_context()->list_state_.started_list == true)
{
......@@ -1417,10 +1405,10 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
}
odf_context()->text_context()->end_paragraph();
if(list_present)
{
odf_context()->text_context()->end_list_item();
}
//if(list_present)
//{
// odf_context()->text_context()->end_list_item();
//}
}
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style, int level, odf_writer::style_paragraph_properties * paragraph_properties
, odf_writer::style_text_properties * text_properties)
......@@ -1758,7 +1746,20 @@ void OoxConverter::convert(PPTX::Logic::MoveTo *oox_geom_path)
odf_context()->drawing_context()->add_path_element(std::wstring(L"M"), path_elm);
}
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style)
{
if (!oox_list_style) return;
if (oox_list_style->IsListStyleEmpty()) return;
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
for (int i = 0; i < 9; i++)
{
OoxConverter::convert_list_level(oox_list_style->levels[0].GetPointer(), i);
}
odf_context()->styles_context()->lists_styles().end_style();
}
void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeStyle* oox_style)
{
if (!oox_txBody) return;
......@@ -1766,6 +1767,8 @@ void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeSt
odf_context()->start_text_context();
convert(oox_txBody->lstStyle.GetPointer());
for (size_t i = 0; i < oox_txBody->Paragrs.size(); i++)
{
convert(&oox_txBody->Paragrs[i], oox_txBody->lstStyle.GetPointer());
......
......@@ -405,9 +405,9 @@ public:
void convert(PPTX::Logic::NvGrpSpPr *oox_nvSpPr);
void convert(PPTX::Logic::NvPr *oox_nvPr);
void convert(PPTX::Logic::Paragraph *oox_para, PPTX::Logic::TextListStyle *oox_list_style = NULL);
void convert(PPTX::Logic::TextListStyle *oox_list_style);
void convert_list_level (PPTX::Logic::TextParagraphPr *oox_para_props, int level);
void convert_list (PPTX::Logic::TextListStyle *oox_list_style);
void convert(PPTX::Logic::TextListStyle *oox_list_style, int level, cpdoccore::odf_writer::style_paragraph_properties *paragraph_properties,
cpdoccore::odf_writer::style_text_properties *text_properties);
......
......@@ -3017,7 +3017,7 @@ void DocxConverter::convert(OOX::Numbering::CAbstractNum* oox_num_style)
if (oox_num_style->m_oAbstractNumId.IsInit() == false) return;
odt_context->styles_context()->lists_styles().start_style(oox_num_style->m_oAbstractNumId->GetValue());
odt_context->styles_context()->lists_styles().start_style(false, oox_num_style->m_oAbstractNumId->GetValue());
//// Childs
//std::vector<OOX::Numbering::CLvl > m_arrLvl;
//nullable<ComplexTypes::Word::CMultiLevelType > m_oMultiLevelType;
......
......@@ -259,6 +259,8 @@ void PptxConverter::convert_styles()
odp_context->page_layout_context()->create_layer_sets();
}
void PptxConverter::convert_settings()
{
......@@ -339,8 +341,9 @@ void PptxConverter::convert_slides()
if (slide->Layout->clrMapOvr.IsInit() && slide->Layout->clrMapOvr->overrideClrMapping.IsInit())
current_clrMap = slide->Layout->clrMapOvr->overrideClrMapping.GetPointer();
current_slide = slide->Layout.operator->();
//current_slide = slide->Layout.operator->();
convert_slide(&slide->Layout->cSld, current_txStyles, true);
//add note master
odp_context->end_master_slide();
m_mapMasters.insert(std::make_pair(master_name, master_style_name));
......@@ -379,7 +382,7 @@ void PptxConverter::convert_slides()
odp_context->current_slide().set_master_page (master_style_name);
odp_context->current_slide().set_layout_page (layout_style_name);
convert_slide (slide->cSld.GetPointer(), current_txStyles, true);
convert_slide (slide->cSld.GetPointer(), current_txStyles);
convert (slide->comments.operator->());
convert (slide->Note.operator->());
......@@ -955,6 +958,14 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
if (pShape.IsInit() && pShape->nvSpPr.nvPr.ph.is_init())
{
pShape->FillLevelUp();
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
odf_context()->drawing_context()->set_placeholder_type(pShape->nvSpPr.nvPr.ph->type->GetBYTECode());
else
odf_context()->drawing_context()->set_placeholder_type(0);
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(pShape->nvSpPr.nvPr.ph->idx.get());
if (!bPlaceholders)
continue;
......@@ -989,20 +1000,12 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
pShape->Merge(update_shape);
//if (pShape->IsListStyleEmpty() == false)
//{
// //create list style
//}else if (listMasterStyle)
//{
//}
OoxConverter::convert(&update_shape);
}
else
{
OoxConverter::convert(pElem.operator->());
}
//convert(oox_slide->spTree.SpTreeElems[i].GetElem().operator->());
}
convert(oox_slide->controls.GetPointer());
}
......@@ -1030,7 +1033,11 @@ void PptxConverter::convert_layout(PPTX::Logic::CSld *oox_slide)
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_element(elm);
OoxConverter::convert(&pShape->nvSpPr.nvPr);
odf_context()->drawing_context()->set_placeholder_type(type);
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(*pShape->nvSpPr.nvPr.ph->idx);
OoxConverter::convert(pShape->spPr.xfrm.GetPointer());
odf_context()->drawing_context()->end_element();
......
......@@ -457,13 +457,8 @@ namespace PPTX
if (txBody.IsInit() == false) return true;
if (txBody->lstStyle.IsInit() == false) return true;
for (int i = 0; i < 10; i++)
{
if (txBody->lstStyle->levels[i].IsInit())
return false;
}
return true;
return txBody->lstStyle->IsListStyleEmpty();
}
void Shape::Merge(Shape& shape, bool bIsSlidePlaceholder)
......
......@@ -171,6 +171,20 @@ namespace PPTX
pReader->Seek(_end_rec);
}
bool IsListStyleEmpty()
{
for (int i = 0; i < 10; i++)
{
if (levels[i].IsInit())
{
if (levels[i]->ParagraphBullet.is_init() == false) continue;
if (levels[i]->ParagraphBullet.is<PPTX::Logic::BuNone>())continue;
return false;
}
}
return true;
}
void Merge(nullable<TextListStyle>& lstStyle)const
{
......
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