//#include "stdafx.h" #include "Geometry.h" #include "../../../ASCPresentationEditor/OfficeDrawing/Elements.h" #include "../../../ASCPresentationEditor/OfficeDrawing/Shapes/BaseShape/Common.h" namespace PPTX { namespace Logic { void Geometry::ConvertToCustomVML(IRenderer* pOOXToVMLRenderer, CString& strPath, CString& strRect, LONG& lWidth, LONG& lHeight) { #ifdef AVS_USE_CONVERT_PPTX_TOCUSTOM_VML NSPresentationEditor::CShapeElement* lpShapeElement = NULL; if (this->is()) { const PPTX::Logic::PrstGeom lpGeom = this->as(); OOXMLShapes::ShapeType _lspt = PPTX2EditorAdvanced::GetShapeTypeFromStr(lpGeom.prst.get()); if(_lspt == OOXMLShapes::sptNil) return; lpShapeElement = new NSPresentationEditor::CShapeElement(NSBaseShape::pptx, (int)_lspt); CString strAdjustValues = lpGeom.GetODString(); lpShapeElement->m_oShape.m_pShape->LoadAdjustValuesList(strAdjustValues); } else if (this->is()) { const PPTX::Logic::CustGeom lpGeom = this->as(); CString strShape = lpGeom.GetODString(); lpShapeElement = new NSPresentationEditor::CShapeElement(strShape); } if (lpShapeElement == NULL) return; double dCoordSizeX = (double)(std::max)((int)lWidth, 1); double dCoordSizeY = (double)(std::max)((int)lHeight, 1); LONG lCoordSize = 100000; lpShapeElement->m_oShape.m_pShape->SetWidthHeightLogic(dCoordSizeX, dCoordSizeY); lpShapeElement->m_oShape.m_pShape->ReCalculate(); pOOXToVMLRenderer->put_Width((double)lCoordSize / dCoordSizeX); pOOXToVMLRenderer->put_Height((double)lCoordSize / dCoordSizeY); CGeomShapeInfo oInfo; oInfo.m_dLeft = 0; oInfo.m_dTop = 0; oInfo.m_dWidth = dCoordSizeX; oInfo.m_dHeight = dCoordSizeY; NSPresentationEditor::CPath& oPath = lpShapeElement->m_oShape.m_pShape->m_oPath; VARIANT var; var.vt = VT_I4; var.lVal = 0; COOXToVMLGeometry* pOOXToVMLGeometry = dynamic_cast(pOOXToVMLRenderer); if(NULL != pOOXToVMLGeometry) pOOXToVMLGeometry->NewShape(); NSPresentationEditor::CGraphicPath oGrPath; CMetricInfo oMetricInfo; int nSize = oPath.m_arParts.size(); for (int nIndex = 0; nIndex < nSize; ++nIndex) { oGrPath.Clear(); oPath.m_arParts[nIndex].ToRendererOOX(&oGrPath, oInfo, oMetricInfo, NSBaseShape::pptx); pOOXToVMLRenderer->put_PenAlpha(oGrPath.m_bStroke ? 255 : 0); pOOXToVMLRenderer->put_BrushAlpha1(oGrPath.m_bFill ? 255 : 0); oGrPath.m_dWidthMM = (double)lCoordSize / dCoordSizeX; oGrPath.m_dHeightMM = (double)lCoordSize / dCoordSizeY; oGrPath.Draw(pOOXToVMLRenderer); } if(NULL != pOOXToVMLGeometry) pOOXToVMLGeometry->ResultPath(&strPath); if (lpShapeElement->m_oShape.m_pShape->m_arTextRects.size() <= 0) { strRect = _T("0,0,100000,100000"); } else { Aggplus::RECT& txRect = lpShapeElement->m_oShape.m_pShape->m_arTextRects[0]; //double dkoefX = (double)lCoordSize / max(1, dCoordSizeX); //double dkoefY = (double)lCoordSize / max(1, dCoordSizeY); double _dWidth = ShapeSize; double _dHeight = ShapeSize; lpShapeElement->m_oShape.m_pShape->GetWidthHeightLogic(_dWidth, _dHeight); double dkoefX = (double)lCoordSize / (std::max)(1., _dWidth); double dkoefY = (double)lCoordSize / (std::max)(1., _dHeight); strRect = _T(""); strRect.Format(_T("%d,%d,%d,%d"), (int)(dkoefX * txRect.left), (int)(dkoefY * txRect.top), (int)(dkoefX * txRect.right), (int)(dkoefY * txRect.bottom)); } #endif } } }