Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x2t fix after testing #76

Merged
merged 1 commit into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion ASCOfficeOdfFileW/source/OdfFormat/odf_table_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<style*>(impl_->current_table().columns[index].style_elm.get());

if (style_ == NULL) return;
Expand Down Expand Up @@ -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);
}

}

Expand Down
75 changes: 67 additions & 8 deletions ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand All @@ -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<PPTX::Slide*>(current_document());
PPTX::SlideMaster *pSlideMaster = dynamic_cast<PPTX::SlideMaster*>(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<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pFind = pVml->m_mapShapes.find(sShapeId);

if (pVml->m_mapShapes.end() != pFind)
{
OOX::Vml::CVmlCommonElements* pShape = dynamic_cast<OOX::Vml::CVmlCommonElements*>(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<OOX::Vml::CImageData*>(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<OOX::File> pFile = pVml->Find(sIdImageFileCache);

if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
{
OOX::Image* pImageFileCache = static_cast<OOX::Image*>(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);

Expand Down Expand Up @@ -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_)
{
Expand All @@ -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)
{
Expand Down
24 changes: 20 additions & 4 deletions ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -2112,15 +2115,28 @@ 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;

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_);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down