From df4e1445f602bdaa1fa4cff2aee5e2a5e1953f39 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Thu, 17 Jul 2025 10:36:02 +0300 Subject: [PATCH] fix bug #75800 --- MsBinaryFile/DocFile/VMLShapeMapping.cpp | 3 +- .../ASCOfficeDrawingConverter.cpp | 99 ++++++++++++++++++- .../ASCOfficeDrawingConverter.h | 1 + 3 files changed, 97 insertions(+), 6 deletions(-) diff --git a/MsBinaryFile/DocFile/VMLShapeMapping.cpp b/MsBinaryFile/DocFile/VMLShapeMapping.cpp index 55e7d3aff5..9f79914b0a 100644 --- a/MsBinaryFile/DocFile/VMLShapeMapping.cpp +++ b/MsBinaryFile/DocFile/VMLShapeMapping.cpp @@ -1052,7 +1052,8 @@ namespace DocFileFormat { if (nAdjValues) { - m_pXmlWriter->WriteAttribute(L"arcsize", m_nAdjValues[0]); + double dArcsize = m_nAdjValues[0] / 21600.; + m_pXmlWriter->WriteAttribute(L"arcsize", dArcsize); } } else if (DocFileFormat::msosptPictureFrame == nCode) diff --git a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp index 5bf8ce0801..896bf315aa 100644 --- a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp +++ b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp @@ -2350,7 +2350,10 @@ void CDrawingConverter::ConvertShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::CX } else { - pPPTShape->SetAdjustment(0, value.GetValue() / 10.); + if (value.GetValue() < 1) + pPPTShape->SetAdjustment(0, value.GetValue() * 10000); + else + pPPTShape->SetAdjustment(0, value.GetValue() / 10.); } } pPPTShape->ReCalculate(); @@ -2560,7 +2563,10 @@ void CDrawingConverter::ConvertShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::CX if (pPPTShape != NULL) { if (!bSetShape) + { oShapeElem.m_pShape->setBaseShape(CBaseShapePtr(pPPTShape)); + bSetShape = true; + } if (bIsNeedCoordSizes) { LoadCoordSize(oNodeShape, oShapeElem.m_pShape); @@ -3022,13 +3028,13 @@ void CDrawingConverter::ConvertShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::CX } CheckBrushShape(elem, oNodeShape, pPPTShape); - CheckBorderShape(elem, oNodeShape, pPPTShape); + CheckEffectShape(elem, oNodeShape, pPPTShape); ////test - NSBinPptxRW::CXmlWriter oXml; - elem->toXmlWriter(&oXml); - std::wstring test = oXml.GetXmlString(); + //NSBinPptxRW::CXmlWriter oXml; + //elem->toXmlWriter(&oXml); + //std::wstring test = oXml.GetXmlString(); } @@ -4845,6 +4851,89 @@ void CDrawingConverter::SendMainProps(const std::wstring& strMainProps, std::wst **pMainProps = strMainProps; } } +void CDrawingConverter::CheckEffectShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape) +{ + if (!oElem) return; + + PPTX::Logic::Shape* pShape = dynamic_cast (oElem->GetElem().operator ->()); + PPTX::Logic::Pic* pPicture = dynamic_cast (oElem->GetElem().operator ->()); + + PPTX::Logic::SpPr* pSpPr = NULL; + + if (pShape) pSpPr = &pShape->spPr; + if (pPicture) pSpPr = &pPicture->spPr; + + if (!pSpPr) return; + + XmlUtils::CXmlNode oNodeShadow = oNode.ReadNode(L"v:shadow"); + SimpleTypes::CTrueFalse bShadowEnabled = SimpleTypes::booleanTrue; + + if (oNodeShadow.IsValid()) + { + XmlMacroReadAttributeBase(oNodeShadow, L"on", bShadowEnabled); + } + if (bShadowEnabled.GetBool()) + { + nullable oColor; + nullable oColor2; + nullable_string oId; + nullable oMatrix; + SimpleTypes::CTrueFalse oObscured; + SimpleTypes::Vml::CVml_Vector2D_Units_Or_Percentage oOffset; + SimpleTypes::Vml::CVml_Vector2D_Units_Or_Percentage oOffset2; + nullable oOpacity; + nullable oOrigin; + SimpleTypes::CShadowType oType; + + XmlMacroReadAttributeBase(oNodeShadow, L"id", oId); + XmlMacroReadAttributeBase(oNodeShadow, L"type", oType); + XmlMacroReadAttributeBase(oNodeShadow, L"color", oColor); + XmlMacroReadAttributeBase(oNodeShadow, L"opacity", oOpacity); + XmlMacroReadAttributeBase(oNodeShadow, L"offset", oOffset); + XmlMacroReadAttributeBase(oNodeShadow, L"origin", oOrigin); + XmlMacroReadAttributeBase(oNodeShadow, L"obscured", oObscured); + XmlMacroReadAttributeBase(oNodeShadow, L"color2", oColor2); + XmlMacroReadAttributeBase(oNodeShadow, L"offset2", oOffset2); + XmlMacroReadAttributeBase(oNodeShadow, L"matrix", oMatrix); + + if (false == pSpPr->EffectList.is_init()) + pSpPr->EffectList.List = new PPTX::Logic::EffectLst(); + + PPTX::Logic::EffectLst* pEffectLst = dynamic_cast(pSpPr->EffectList.List.GetPointer()); + + pEffectLst->outerShdw.Init(); + + pEffectLst->outerShdw->Color.Color = new PPTX::Logic::SrgbClr(); + + if (oColor.IsInit()) + pEffectLst->outerShdw->Color.Color->SetRGB(oColor->Get_R(), oColor->Get_G(), oColor->Get_B()); + else + pEffectLst->outerShdw->Color.Color->SetRGB(0x80, 0x80, 0x80); + + if (oOpacity.is_init()) + { + BYTE lAlpha = oOpacity->GetValue() * 255; + + PPTX::Logic::ColorModifier oMod; + oMod.name = L"alpha"; + int nA = (int)(lAlpha * 100000.0 / 255.0); + oMod.val = nA; + pEffectLst->outerShdw->Color.Color->Modifiers.push_back(oMod); + } + double offsetX = oOffset.IsXinPoints() ? oOffset.GetX() : 0; + double offsetY = oOffset.IsYinPoints() ? oOffset.GetY() : 0; + + double dist = sqrt(offsetX * offsetX + offsetY * offsetY); + double dir = (offsetX != 0) ? atan(offsetY / offsetX) * 180. / 3.1415926 : 0; + if (offsetX < 0) dir += 180; + if (dir < 0) dir += 360; + + pEffectLst->outerShdw->dist = dist * (635 * 20); + pEffectLst->outerShdw->dir = (int)(dir * 60000); + pEffectLst->outerShdw->rotWithShape = false; + } + +} void CDrawingConverter::CheckBorderShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape) { if (!oElem) return; diff --git a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.h b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.h index b7e8b9f468..3fc3dd46f7 100644 --- a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.h +++ b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.h @@ -298,6 +298,7 @@ namespace NSBinPptxRW void CheckBrushShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape); void CheckPenShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape); void CheckBorderShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape); + void CheckEffectShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape); void ConvertColor (PPTX::Logic::UniColor& uniColor, nullable_string& sColor, nullable_string& sOpacity); void LoadCoordSize (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);