diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_table_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_table_context.cpp index a9b1bfd72b4..d16ab215dcd 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_table_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_table_context.cpp @@ -342,6 +342,16 @@ void odf_table_context::change_current_column_width(double width) int index = impl_->current_table().current_column ; if (index < 0) return; + while(index >= impl_->current_table().columns.size()) + { + office_element_ptr elm; + create_element(L"table", L"table-column", elm, impl_->odf_context_); + + impl_->styles_context()->create_style(L"", style_family::TableColumn, true, false, -1); + + add_column(elm, true); + + } style *style_ = dynamic_cast(impl_->current_table().columns[index].style_elm.get()); if (style_ == NULL) return; @@ -527,7 +537,11 @@ void odf_table_context::set_cell_row_span_restart() cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = sz; } state.spanned_row_cell.clear(); - state.spanned_row_cell.push_back(impl_->current_table().cells.back().elm); + + if (false == impl_->current_table().cells.empty()) + { + state.spanned_row_cell.push_back(impl_->current_table().cells.back().elm); + } } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp index 7fc8924c5bf..bd529f7c9cb 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp @@ -37,6 +37,7 @@ #include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h" #include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h" +#include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h" @@ -267,6 +268,10 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) } if (oox_picture->oleObject.IsInit()) { + if (pathImage.empty() && oox_picture->blipFill.blip.IsInit()) + { + pathImage = oox_picture->blipFill.blip->oleFilepathImage; + } std::wstring pathOle; if (oox_picture->oleObject->m_oId.IsInit()) @@ -283,6 +288,58 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) { odf_context()->drawing_context()->set_program(*oox_picture->oleObject->m_sProgId); } + + if (pathImage.empty() && oox_picture->oleObject->m_sShapeId.IsInit()) + { + PPTX::Slide *pSlide = dynamic_cast(current_document()); + PPTX::SlideMaster *pSlideMaster = dynamic_cast(current_document()); + + OOX::CVmlDrawing *pVml = pSlide ? pSlide->Vml.operator->() : (pSlideMaster ? pSlideMaster->Vml.operator->() : NULL); + + if (pVml) + { + std::wstring sShapeId = oox_picture->oleObject->m_sShapeId.get(); + boost::unordered_map::iterator pFind = pVml->m_mapShapes.find(sShapeId); + + if (pVml->m_mapShapes.end() != pFind) + { + OOX::Vml::CVmlCommonElements* pShape = dynamic_cast(pFind->second.pElement); + + if (pShape) + { + for(size_t i = 0; i < pShape->m_arrItems.size(); ++i) + { + OOX::WritingElement* pChildElemShape = pShape->m_arrItems[i]; + + if(OOX::et_v_imagedata == pChildElemShape->getType()) + { + OOX::Vml::CImageData* pImageData = static_cast(pChildElemShape); + + std::wstring sIdImageFileCache; + + if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue(); + else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue(); + + if (!sIdImageFileCache.empty()) + { + //ищем физический файл ( rId относительно vml_drawing) + smart_ptr pFile = pVml->Find(sIdImageFileCache); + + if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type())) + { + OOX::Image* pImageFileCache = static_cast(pFile.operator->()); + + pathImage = pImageFileCache->filename().GetPath(); + } + } + } + } + } + } + } + + } + odf_ref_image = bEmbedded ? odf_context()->add_imageobject(pathImage) : pathImage; odf_context()->drawing_context()->set_image_replacement(odf_ref_image); @@ -1973,24 +2030,26 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run) if (!oox_run) return; bool styled = false; + odf_writer::odf_text_context* text_context = odf_context()->text_context(); + if (oox_run->rPr.IsInit()) { - odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties(); + odf_writer::style_text_properties * text_properties = text_context->get_text_properties(); if (!text_properties) { - odf_context()->styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1); - text_properties = odf_context()->styles_context()->last_state()->get_text_properties(); + text_context->get_styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1); + text_properties = text_context->get_styles_context()->last_state()->get_text_properties(); styled = true; } convert(oox_run->rPr.GetPointer(), text_properties); } - odf_context()->text_context()->start_span(styled); + text_context->start_span(styled); if ((oox_run->rPr.IsInit()) && (oox_run->rPr->hlinkClick.IsInit()) && (oox_run->rPr->hlinkClick->id.IsInit())) { - odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties(); + odf_writer::style_text_properties * text_properties = text_context->get_text_properties(); if (!text_properties->content_.fo_color_) { @@ -2010,13 +2069,13 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run) text_properties->content_.style_text_underline_style_ = odf_types::line_style::Solid; std::wstring hlink = find_link_by_id(oox_run->rPr->hlinkClick->id.get(), 2); - odf_context()->text_context()->add_hyperlink(hlink, oox_run->GetText()); + text_context->add_hyperlink(hlink, oox_run->GetText()); } else { - odf_context()->text_context()->add_text_content( oox_run->GetText()); + text_context->add_text_content( oox_run->GetText()); } - odf_context()->text_context()->end_span(); + text_context->end_span(); } void OoxConverter::convert(PPTX::Logic::Fld *oox_fld) { diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index 061ed5e0251..e46e758585c 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -437,7 +437,10 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) odt_context->text_context()->set_KeepNextParagraph(false); } //--------------------------------------------------------------------------------------------------------------------- - current_font_size.erase(current_font_size.begin() + 1, current_font_size.end()); + if (false == current_font_size.empty()) + { + current_font_size.erase(current_font_size.begin() + 1, current_font_size.end()); + } bool bStyled = false; bool bStartNewParagraph = !odt_context->text_context()->get_KeepNextParagraph(); @@ -2112,7 +2115,7 @@ void DocxConverter::convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf //tblwidthNil = 2, //tblwidthPct = 3 } -void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::style_text_properties * text_properties) +void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::style_text_properties * text_properties, bool is_list_styles) { if (oox_run_pr == NULL) return; if (text_properties == NULL) return; @@ -2120,7 +2123,20 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st if (oox_run_pr->m_oRStyle.IsInit() && oox_run_pr->m_oRStyle->m_sVal.IsInit()) { std::wstring style_name = *oox_run_pr->m_oRStyle->m_sVal; - odt_context->styles_context()->last_state()->set_parent_style_name(style_name); + + odf_writer::odf_style_state_ptr style_state; + //if (is_list_styles) + //{ + // style_state = odt_context->styles_context()->lists_styles()->last_state(); + //} + //else + { + style_state = odt_context->styles_context()->last_state(); + } + if (style_state) + { + style_state->set_parent_style_name(style_name); + } odf_writer::style_text_properties parent_text_properties; odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Text, &parent_text_properties.content_); @@ -3233,7 +3249,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl) odf_writer::odf_style_context* styles_context = odf_context()->page_layout_context()->get_local_styles_context(); odf_writer::style_text_properties *text_props = odt_context->styles_context()->lists_styles().get_text_properties(); - convert(oox_num_lvl->m_oRPr.GetPointer(), text_props); + convert(oox_num_lvl->m_oRPr.GetPointer(), text_props, true); //create text style for symbols list НА ЛОКАЛЬНОМ контексте - иначе пересечение имен стилей (todoo вытащить генерацию имен в общую часть) styles_context->create_style(L"", odf_types::style_family::Text, false, true, -1); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h index e5a0771c334..20e4ca3ad5f 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h @@ -189,7 +189,7 @@ namespace Oox2Odf void convert(OOX::Logic::CRun *oox_run); void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties); void convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf_writer::style_paragraph_properties *paragraph_properties); - void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties); + void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties, bool is_list_styles = false); void convert(ComplexTypes::Word::CShading *oox_shading, odf_writer::style_text_properties *text_properties ); void convert(OOX::Logic::CFldSimple *oox_fld); void convert(OOX::Logic::CFldChar *oox_fld); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp index 532e87adf96..bea83bee0c2 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp @@ -954,7 +954,9 @@ void PptxConverter::convert(PPTX::Logic::TableCell *oox_table_cell, int numCol) covered = true; if (oox_table_cell->CellProperties.IsInit()) + { styled = (oox_table_cell->CellProperties->is_empty == false); + } odp_context->slide_context()->start_table_cell(numCol, covered, styled); @@ -1193,8 +1195,8 @@ bool PptxConverter::convert(PPTX::Logic::TableCellProperties *oox_table_cell_pr) { if (!oox_table_cell_pr) return false; - odf_writer::style_table_cell_properties *odf_cell_props = odp_context->styles_context()->last_state()->get_table_cell_properties(); - odf_writer::style_paragraph_properties *odf_para_props = odp_context->styles_context()->last_state(odf_types::style_family::TableCell)->get_paragraph_properties(); + odf_writer::style_table_cell_properties *odf_cell_props = odp_context->slide_context()->get_styles_context()->last_state()->get_table_cell_properties(); + odf_writer::style_paragraph_properties *odf_para_props = odp_context->slide_context()->get_styles_context()->last_state(odf_types::style_family::TableCell)->get_paragraph_properties(); if (!odf_para_props) return false;