diff --git a/MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.h b/MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.h index 71a1f490e1..01fd1b5bda 100644 --- a/MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.h +++ b/MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.h @@ -173,9 +173,6 @@ private: int m_lIndexSrc; int m_lIndexDst; - LONG m_lWidth; - LONG m_lHeight; - LONG m_lX; LONG m_lY; @@ -197,6 +194,9 @@ private: int m_lMaxAdjUse; public: + LONG m_lWidth; + LONG m_lHeight; + // все в одно не получится, формулы появляются и при конвертации path/adj и т.д. NSBinPptxRW::CXmlWriter m_oGuidsRes; NSBinPptxRW::CXmlWriter m_oPathRes; diff --git a/OOXML/Common/ComplexTypes.cpp b/OOXML/Common/ComplexTypes.cpp index 402aa85064..f6902902e8 100644 --- a/OOXML/Common/ComplexTypes.cpp +++ b/OOXML/Common/ComplexTypes.cpp @@ -2615,14 +2615,6 @@ namespace Word WritingElement_ReadAttributes_Read_else_if(oReader, L"w:after-autospacing", m_oAfterAutospacing) WritingElement_ReadAttributes_End(oReader) - if (m_oLineRule.IsInit()) - { - if (m_oLineRule->GetValue() == SimpleTypes::ELineSpacingRule::linespacingruleAuto) - { - m_oLine.reset(); // or set 240 - } - } - if (m_oLine.IsInit()) { if (m_oLine->GetValue() < 0) diff --git a/OOXML/DocxFormat/Logic/Vml.cpp b/OOXML/DocxFormat/Logic/Vml.cpp index 016ac0311e..1e22b501d4 100644 --- a/OOXML/DocxFormat/Logic/Vml.cpp +++ b/OOXML/DocxFormat/Logic/Vml.cpp @@ -51,6 +51,9 @@ #include "../../XlsxFormat/Drawing/CellAnchor.h" #include "../../XlsxFormat/Drawing/FromTo.h" +#include "../../../MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.h" +#include "../../../MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.h" + #include "../../../DesktopEditor/raster/ImageFileFormatChecker.h" namespace OOX @@ -1268,6 +1271,117 @@ namespace OOX CVmlCommonElements::mergeFrom(shape_type); } + void CShape::ConvertToPptx(double width, double height) + { + NSGuidesVML::CFormulasManager oManager; + NSGuidesVML::CFormulaConverter oFormulaConverter; + std::vector arHandles; + std::vector arAdjustments; + + ODRAW::CPath oPath; + + if (m_oCoordSize.IsInit()) + { + oFormulaConverter.m_lWidth = m_oCoordSize->GetX(); + oFormulaConverter.m_lHeight = m_oCoordSize->GetY(); + + oPath.SetCoordsize(m_oCoordSize->GetX(), m_oCoordSize->GetY()); + } + + NSGuidesVML::CFormParam pParamCoef; + pParamCoef.m_eType = NSGuidesVML::ptValue; + pParamCoef.m_lParam = 65536; + pParamCoef.m_lCoef = 65536; + + oFormulaConverter.ConvertCoef(pParamCoef); + + if (m_sAdj.IsInit()) + { + std::vector arAdj; + boost::algorithm::split(arAdj, *m_sAdj, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on); + + for (size_t i = 0; i < arAdj.size(); ++i) + { + if (arAdj.empty()) arAdjustments.push_back(0); + else arAdjustments.push_back(XmlUtils::GetInteger(arAdj[i])); + } + } + for (size_t i = 0; i < m_arrItems.size(); ++i) + { + switch (m_arrItems[i]->getType()) + { + case OOX::et_v_formulas: + { + OOX::Vml::CFormulas* formulas = dynamic_cast(m_arrItems[i]); + for (auto formula : formulas->m_arrItems) + { + oManager.AddFormula(formula->m_sEqn); + } + oManager.CalculateResults(); + }break; + case OOX::et_v_path: + { + + }break; + case OOX::et_v_handles: + { + OOX::Vml::CHandles* handles = dynamic_cast(m_arrItems[i]); + for (auto handle : handles->m_arrItems) + { + CHandle_ oH; + if (handle->m_oPolar.IsInit()) oH.polar = handle->m_oPolar->ToString(); + oH.position = handle->m_oPosition.ToString(); + oH.radiusrange = handle->m_oRadiusRange.ToString(); + oH.switchHandle = handle->m_oSwitch.ToString(); + oH.xrange = handle->m_oXRange.ToString(); + oH.yrange = handle->m_oYRange.ToString(); + + arHandles.push_back(oH); + } + }break; + } + } + oFormulaConverter.ConvertFormula(oManager.m_arFormulas); + + std::wstring vml_path = m_oPath->GetValue(); + oFormulaConverter.ConvertPath(vml_path, oPath); + oFormulaConverter.ConvertHandle(arHandles, arAdjustments, PPTShapes::sptNotPrimitive); + oFormulaConverter.SetTextRectDefault(); + //--------------------------------------------------------------------------------------------------------------------- + std::wstring strXmlPPTX = L""; + + if (oFormulaConverter.m_oAdjRes.GetSize() == 0) + strXmlPPTX += L""; + else + strXmlPPTX += L"" + oFormulaConverter.m_oAdjRes.GetXmlString() + L""; + + if (oFormulaConverter.m_oGuidsRes.GetSize() == 0) + strXmlPPTX += L"" + oFormulaConverter.m_oCoef.GetXmlString() + L""; + else + strXmlPPTX += L"" + oFormulaConverter.m_oCoef.GetXmlString() + oFormulaConverter.m_oGuidsRes.GetXmlString() + L""; + + if (oFormulaConverter.m_oHandleRes.GetSize() == 0) + strXmlPPTX += L""; + else + strXmlPPTX += L"" + oFormulaConverter.m_oHandleRes.GetXmlString() + L""; + + strXmlPPTX += L""; + + if (oFormulaConverter.m_oTextRect.GetSize() != 0) + strXmlPPTX += oFormulaConverter.m_oTextRect.GetXmlString(); + + strXmlPPTX += L""; + strXmlPPTX += oFormulaConverter.m_oPathRes.GetXmlString(); + strXmlPPTX += L""; + strXmlPPTX += L""; + + XmlUtils::CXmlNode oNode; + if (oNode.FromXmlString(strXmlPPTX)) + { + m_oCustGeom.Init(); + m_oCustGeom->fromXML(oNode); + } + } //-------------------------------------------------------------------------------- // CShapeType 14.1.2.20 (Part4) //-------------------------------------------------------------------------------- diff --git a/OOXML/DocxFormat/Logic/Vml.h b/OOXML/DocxFormat/Logic/Vml.h index 3351d41d4b..ec1348a498 100644 --- a/OOXML/DocxFormat/Logic/Vml.h +++ b/OOXML/DocxFormat/Logic/Vml.h @@ -40,6 +40,13 @@ #include "../WritingElement.h" #include "VmlOfficeDrawing.h" +namespace PPTX +{ + namespace Logic + { + class CustGeom; + } +} namespace OOX { namespace Spreadsheet @@ -684,6 +691,8 @@ namespace OOX void mergeFrom(CShapeType* shape_type); + void ConvertToPptx(double width, double height); + private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); @@ -693,6 +702,8 @@ namespace OOX nullable m_oPath; nullable_string m_sGfxData; nullable_string m_sEquationXML; +//-------------------------------------------------------------------------- + nullable m_oCustGeom; }; class CClientData : public WritingElement diff --git a/OdfFile/Writer/Converter/ConvertVml.cpp b/OdfFile/Writer/Converter/ConvertVml.cpp index d9e7d694a6..de66957c09 100644 --- a/OdfFile/Writer/Converter/ConvertVml.cpp +++ b/OdfFile/Writer/Converter/ConvertVml.cpp @@ -71,18 +71,7 @@ namespace Oox2Odf } } } - void OoxConverter::convert(OOX::Vml::CFormulas *vml_formulas) - { - if (vml_formulas == NULL) return; - for (std::vector::iterator it = vml_formulas->m_arrItems.begin(); it != vml_formulas->m_arrItems.end(); ++it) - { - OOX::Vml::CF *cf = dynamic_cast(*it); - if (cf == NULL) continue; - - //odf_context()->drawing_context()->add_formula(L"", cf->m_sEqn); - } - } void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style) { @@ -311,9 +300,6 @@ namespace Oox2Odf // odf_context()->drawing_context()->set_anchor(2); } - - //if (width_pt && height_pt) - // odf_context()->drawing_context()->set_viewBox(width_pt.get(), height_pt.get()); } void OoxConverter::convert(OOX::Vml::CShape *vml_shape, OOX::VmlOffice::COLEObject* vml_object) { @@ -366,11 +352,14 @@ namespace Oox2Odf odf_context()->drawing_context()->end_object_ole(); } } -//----------------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------------- + + bool bCustom = false; + if (vml_shape->m_oSpt.IsInit()) { SimpleTypes::Vml::SptType sptType = static_cast(vml_shape->m_oSpt->GetValue()); - odf_context()->drawing_context()->start_shape(OOX::VmlShapeType2PrstShape(sptType)); + odf_context()->drawing_context()->start_shape(OOX::VmlShapeType2PrstShape(sptType)); // ?? test for bCustom } else if ((vml_shape->m_oConnectorType.IsInit()) && (vml_shape->m_oConnectorType->GetValue() != SimpleTypes::connectortypeNone)) { @@ -382,46 +371,7 @@ namespace Oox2Odf odf_context()->drawing_context()->start_shape(1000); odf_context()->drawing_context()->set_line_width(1.); - std::wstring vml_path = vml_shape->m_oPath->GetValue(); - std::wstring odf_path; - - bool isDigitLast = true; - - for (size_t i = 0; i < vml_path.size(); ++i) - { - if (vml_path[i] == L',') - { - odf_path += L" "; - isDigitLast = true; - } - else - { - if (vml_path[i] >= L'0' && vml_path[i] <= L'9') - { - if (!isDigitLast) odf_path += L" "; - isDigitLast = true; - } - else - { - if (isDigitLast) odf_path += L" "; - isDigitLast = false; - } - - odf_path += vml_path[i]; - std::transform(odf_path.begin(), odf_path.end(), odf_path.begin(), toupper); - } - } - - odf_context()->drawing_context()->set_path(odf_path); - - if (vml_shape->m_oCoordSize.IsInit()) - { - odf_context()->drawing_context()->set_viewBox(vml_shape->m_oCoordSize->GetX(), vml_shape->m_oCoordSize->GetY()); - } - else - { - odf_context()->drawing_context()->set_viewBox(21600, 212600); - } + bCustom = true; } else if (vml_shape->m_bImage) { @@ -435,6 +385,16 @@ namespace Oox2Odf convert(dynamic_cast(vml_shape)); + if (bCustom) + { + //_CP_OPT(double) width, height; + //odf_context()->drawing_context()->get_size(width, height); + + vml_shape->ConvertToPptx(1, 1); + + convert(vml_shape->m_oCustGeom.GetPointer()); + //odf_context()->drawing_context()->set_viewBox(*width, *height); + } odf_context()->drawing_context()->end_shape(); odf_context()->drawing_context()->end_drawing(); } @@ -689,25 +649,6 @@ namespace Oox2Odf odf_context()->drawing_context()->end_drawing(); } - void OoxConverter::convert(OOX::Vml::CPath *vml_path) - { - if (vml_path == NULL) return; - - //SimpleTypes::CTrueFalse m_oArrowOk; - //nullable m_oConnectAngles; - //nullable m_oConnectLocs; - //SimpleTypes::CConnectType m_oConnectType; - //SimpleTypes::CTrueFalse m_oExtrusionOk; - //SimpleTypes::CTrueFalse m_oFillOk; - //SimpleTypes::CTrueFalse m_oGradientShapeOk; - //nullable m_oId; - //SimpleTypes::CTrueFalse m_oInsetPenOk; - //SimpleTypes::Vml::CVml_Vector2D_Units m_oLimo; - //SimpleTypes::CTrueFalse m_oShadowOk; - //SimpleTypes::CTrueFalse m_oStrokeOk; - //nullable m_oTextBoxRect; - //SimpleTypes::CTrueFalse m_oTextPathOk; - } void OoxConverter::convert(OOX::Vml::CPolyLine *vml_polyline) { if (vml_polyline == NULL) return; diff --git a/OdfFile/Writer/Converter/Converter.cpp b/OdfFile/Writer/Converter/Converter.cpp index 2504961d47..0c78a1219e 100644 --- a/OdfFile/Writer/Converter/Converter.cpp +++ b/OdfFile/Writer/Converter/Converter.cpp @@ -512,7 +512,7 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) }break; case OOX::et_v_shape: { - convert(dynamic_cast(oox_unknown)); + convert(dynamic_cast(oox_unknown), NULL); }break; case OOX::et_v_oval: { @@ -558,11 +558,7 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) { convert(dynamic_cast(oox_unknown)); }break; - case OOX::et_v_path: - { - convert(dynamic_cast(oox_unknown)); - }break; - case OOX::et_v_textpath: + case OOX::et_v_textpath: { convert(dynamic_cast(oox_unknown)); }break; @@ -574,10 +570,6 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) { convert(dynamic_cast(oox_unknown)); }break; - case OOX::et_v_formulas: - { - convert(dynamic_cast(oox_unknown)); - }break; case OOX::et_v_shadow: { convert(dynamic_cast(oox_unknown)); diff --git a/OdfFile/Writer/Converter/Converter.h b/OdfFile/Writer/Converter/Converter.h index aca93327cc..a7405866ad 100644 --- a/OdfFile/Writer/Converter/Converter.h +++ b/OdfFile/Writer/Converter/Converter.h @@ -660,7 +660,6 @@ public: void convert(OOX::Vml::CFill *vml_fill); void convert(OOX::Vml::CLine *vml_line); void convert(OOX::Vml::COval *vml_oval); - void convert(OOX::Vml::CPath *vml_path); void convert(OOX::Vml::CPolyLine *vml_polyline); void convert(OOX::Vml::CRect *vml_rect); void convert(OOX::Vml::CRoundRect *vml_roundrect); @@ -672,7 +671,6 @@ public: void convert(OOX::VmlWord::CWrap *vml_wrap); void convert(OOX::Vml::CGroup *vml_group); void convert(OOX::Vml::CVmlCommonElements *vml_attr); - void convert(OOX::Vml::CFormulas *vml_formulas); void convert(OOX::Drawing::COfficeArtExtensionList *ext_list); void convert(OOX::Drawing::COfficeArtExtension *art_ext); diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index 106ea175e7..f4b67ee321 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -3103,9 +3103,9 @@ void DocxConverter::convert(OOX::Logic::CObject* oox_obj) std::wstring pathImage = find_link_by_id(sIdImageFileCache, 1, bExternal); std::wstring odf_ref_image = odf_context()->add_imageobject(pathImage); - odf_context()->drawing_context()->set_image_replacement(odf_ref_image); - - OoxConverter::convert(oox_obj->m_oShape.GetPointer()); + odf_context()->drawing_context()->set_image_replacement(odf_ref_image); + + OoxConverter::convert(oox_obj->m_oShape.GetPointer(), NULL); odf_context()->drawing_context()->end_object_ole(); diff --git a/OdfFile/Writer/Format/odf_drawing_context.cpp b/OdfFile/Writer/Format/odf_drawing_context.cpp index e7948b9896..b05d8f961f 100644 --- a/OdfFile/Writer/Format/odf_drawing_context.cpp +++ b/OdfFile/Writer/Format/odf_drawing_context.cpp @@ -998,8 +998,10 @@ void odf_drawing_context::end_shape() if (path) { if (impl_->current_drawing_state_.view_box_.empty() && impl_->current_drawing_state_.svg_width_ && impl_->current_drawing_state_.svg_height_) - set_viewBox( impl_->current_drawing_state_.svg_width_->get_value_unit(length::cm) * 1000, - impl_->current_drawing_state_.svg_height_->get_value_unit(length::cm) *1000); + { + set_viewBox(impl_->current_drawing_state_.svg_width_->get_value_unit(length::cm) * 1000, + impl_->current_drawing_state_.svg_height_->get_value_unit(length::cm) * 1000); + } if (!impl_->current_drawing_state_.path_.empty()) path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_; if (!impl_->current_drawing_state_.view_box_.empty()) path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_; @@ -1135,9 +1137,9 @@ void odf_drawing_context::end_shape() if (shape_define) { if (impl_->current_drawing_state_.oox_shape_ && impl_->current_drawing_state_.oox_shape_->view_box) - enhanced->svg_viewbox_ = impl_->current_drawing_state_.oox_shape_->view_box; + enhanced->svg_viewbox_ = impl_->current_drawing_state_.oox_shape_->view_box; else - enhanced->svg_viewbox_ = shape_define->view_box; + enhanced->svg_viewbox_ = shape_define->view_box; enhanced->attlist_.draw_type_ = shape_define->odf_type_name; enhanced->attlist_.draw_text_areas_ = shape_define->text_areas; @@ -1805,9 +1807,9 @@ void odf_drawing_context::set_viewBox (double W, double H) { impl_->current_drawing_state_.oox_shape_->view_box = impl_->current_drawing_state_.view_box_; - if (impl_->current_drawing_state_.oox_shape_->sub_view_size) - impl_->current_drawing_state_.oox_shape_->sub_view_size = *impl_->current_drawing_state_.oox_shape_->sub_view_size + L" " + std::to_wstring((int)W) + L" " + std::to_wstring((int)H); - else + //if (impl_->current_drawing_state_.oox_shape_->sub_view_size) + // impl_->current_drawing_state_.oox_shape_->sub_view_size = *impl_->current_drawing_state_.oox_shape_->sub_view_size + L" " + std::to_wstring((int)W) + L" " + std::to_wstring((int)H); + //else impl_->current_drawing_state_.oox_shape_->sub_view_size = std::to_wstring((int)W) + L" " + std::to_wstring((int)H); } } @@ -2123,31 +2125,45 @@ void odf_drawing_context::set_position_line(_CP_OPT(double) & x_pt, _CP_OPT(doub if (line == NULL) return; if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && x_pt) - x_pt = *x_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x ; - // + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0); + { + //x_pt = *x_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x; + // + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0); + x_pt = (*x_pt + impl_->current_group_->shift_x) * impl_->current_group_->scale_cx; + } if (x_pt && !line->draw_line_attlist_.svg_x1_) - line->draw_line_attlist_.svg_x1_ = length(length(*x_pt,length::pt).get_value_unit(length::cm),length::cm); + line->draw_line_attlist_.svg_x1_ = length(length(*x_pt, length::pt).get_value_unit(length::cm), length::cm); if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && y_pt) - y_pt = *y_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y; - //+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0); + { + //y_pt = *y_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y; + //+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0); + y_pt = (*y_pt + impl_->current_group_->shift_y) * impl_->current_group_->scale_cy; + } if (y_pt && !line->draw_line_attlist_.svg_y1_) - line->draw_line_attlist_.svg_y1_ = length(length(*y_pt,length::pt).get_value_unit(length::cm),length::cm); + line->draw_line_attlist_.svg_y1_ = length(length(*y_pt, length::pt).get_value_unit(length::cm), length::cm); /////////////////////////////////////// if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && x2_pt) - x2_pt = *x2_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x ; - // + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0); + { + //x2_pt = *x2_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x; + // + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0); + x2_pt = (*x2_pt + impl_->current_group_->shift_x) * impl_->current_group_->scale_cx; + } - if (x2_pt && !line->draw_line_attlist_.svg_x2_) line->draw_line_attlist_.svg_x2_ = length(length(*x2_pt,length::pt).get_value_unit(length::cm),length::cm); + if (x2_pt && !line->draw_line_attlist_.svg_x2_) + line->draw_line_attlist_.svg_x2_ = length(length(*x2_pt, length::pt).get_value_unit(length::cm), length::cm); if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && y2_pt) - y2_pt = *y2_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y; - //+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0); + { + //y2_pt = *y2_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y; + //+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0); + y2_pt = (*y2_pt + impl_->current_group_->shift_y) * impl_->current_group_->scale_cy; + } - if (y2_pt && !line->draw_line_attlist_.svg_y2_) line->draw_line_attlist_.svg_y2_ = length(length(*y2_pt,length::pt).get_value_unit(length::cm),length::cm); + if (y2_pt && !line->draw_line_attlist_.svg_y2_) + line->draw_line_attlist_.svg_y2_ = length(length(*y2_pt, length::pt).get_value_unit(length::cm), length::cm); } void odf_drawing_context::get_position(_CP_OPT(double) & x_pt, _CP_OPT(double) & y_pt) @@ -2307,8 +2323,8 @@ void odf_drawing_context::set_line_head(int type, int len, int width) if (impl_->current_drawing_state_.svg_width_ && impl_->current_drawing_state_.svg_height_) { - double sz_x =impl_->current_drawing_state_.svg_width_->get_value_unit(odf_types::length::pt); - double sz_y =impl_->current_drawing_state_.svg_height_->get_value_unit(odf_types::length::pt); + double sz_x = impl_->current_drawing_state_.svg_width_->get_value_unit(odf_types::length::pt); + double sz_y = impl_->current_drawing_state_.svg_height_->get_value_unit(odf_types::length::pt); impl_->current_graphic_properties->draw_marker_start_width_ = length((std::max)(sz_x, sz_y) / 10., odf_types::length::pt); }