Commit 3aa734c7 authored by ElenaSubbotina's avatar ElenaSubbotina

.

parent 28263061
......@@ -1692,38 +1692,9 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
PPTX::Logic::Shape* pShape = new PPTX::Logic::Shape();
/*
#ifdef _DEBUG
const PPTX::Logic::CustGeom lpGeom = pShape->spPr.Geometry.as<PPTX::Logic::CustGeom>();
CString strShapeWWW = lpGeom.GetODString();
NSPresentationEditor::CShapeElement* lpShapeElement = new CShapeElement(strShapeWWW);
lpShapeElement->m_oShape.ReCalculate();
std::map<CString, long>* mapGuides = &((CPPTXShape*)(lpShapeElement->m_oShape.m_pShape))->FManager.mapGuides;
std::vector<double>* Guides = ((CPPTXShape*)(lpShapeElement->m_oShape.m_pShape))->FManager.Guides;
double formulas[1905];
for (int u = 0; u < 1905; u++)
{
CString strF = _T("");
strF.Format(_T("gd%d"), u);
long num = mapGuides->FindKey(strF);
if (num >= 0)
{
formulas[u] = (*Guides)[mapGuides->GetValueAt(num)];
}
}
#endif
*/
if (!pShape->TextBoxBodyPr.is_init())
pShape->TextBoxBodyPr = new PPTX::Logic::BodyPr();
bool bIsTrimTextPath = false;
if (pPPTShape->IsWordArt())
{
enum EFilltype
......@@ -1782,33 +1753,34 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
}
SimpleTypes::CTextShapeType<> oTextShapeType;
oTextShapeType.SetValue(eTextShapeType);
CString strPrstTxWarp = _T("<a:prstTxWarp prst=\"") + oTextShapeType.ToString() + _T("\"><a:avLst/></a:prstTxWarp>");
XmlUtils::CXmlNode oPrstTxWarpNode;
oPrstTxWarpNode.FromXmlString(strPrstTxWarp);
pShape->TextBoxBodyPr->prstTxWarp = oPrstTxWarpNode;
//pShape->TextBoxBodyPr->wrap = new PPTX::Limit::TextWrap();
//pShape->TextBoxBodyPr->wrap->set(_T("none"));
// TODO:
// тут утечки памяти. И вообще надо переписать. все намешано
// нужно с комментами прояснить всю конвертацию
bool bTrimTextPath = false, bFitShape = false, bFitPath = false;
XmlUtils::CXmlNodes oChilds;
if (oNodeShape.GetNodes(_T("*"), oChilds))
{
EFilltype eFillType = etSolidFill;
LONG lChildsCount = oChilds.GetCount();
std::vector<CString> wordArtString;
EFilltype eFillType = etNoFill;;
CString sTxbxContent = _T("<w:txbxContent>");
CString srPr;
CString sFont = (_T("Arial Black"));
//CString sDashStyle;
CString sFont = _T("Arial Black");
int nFontSize = 36;
LONG lChildsCount = oChilds.GetCount();
std::vector<CString> strString;
BYTE lAlpha;
bool bOpacity = false;
bool bOpacity2 = false;
double nFocus = 0;
int nAngle = 90;
bool bColors = false;
PPTX::Logic::ColorModifier oMod;
PPTX::Logic::ColorModifier oMod2;
std::vector<PPTX::Logic::UniColor*> arColors;
......@@ -1816,22 +1788,19 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
std::vector<int> arPos;
std::vector<int> arPosNew;
std::map<PPTX::Logic::UniColor*, int> arGradMap;
double nFocus = 0;
int nAngle = 90;
bool bColors = false;
int R = 255;
int G = 255;
int B = 255;
int R = 255, G = 255, B = 255;
nullable_string sFillColor;
oNodeShape.ReadAttributeBase(L"fillcolor", sFillColor);
if (sFillColor.is_init())
{
eFillType = etSolidFill;
NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sFillColor);
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = _T("a");
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
arColors.push_back(&pSolid->Color);
......@@ -1841,8 +1810,6 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
G = color.G;
B = color.B;
}
else
eFillType = etNoFill;
if (eFillType == etNoFill)
{
......@@ -1852,6 +1819,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
if (!sFilled.is_init() || (*sFilled != _T("false") && *sFilled != _T("f")))
{
eFillType = etSolidFill;
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = _T("a");
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
......@@ -1874,12 +1842,12 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
if (tmpString.IsEmpty())
{
tmpString = oNodeP.GetAttribute(_T("string"));
CorrectXmlString(tmpString ); // мы используем его в хмл
strString.push_back(tmpString );
CorrectXmlString(tmpString );
wordArtString.push_back(tmpString );
}
else
{
CorrectXmlString(tmpString ); // мы используем его в хмл
CorrectXmlString(tmpString );
int pos1 = 0, pos2 = 0;
......@@ -1888,15 +1856,14 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
pos2 = tmpString.Find(_T("\n"), pos1);
if (pos2 > 0)
{
strString.push_back(tmpString.Mid(pos1, pos2 - pos1));
wordArtString.push_back(tmpString.Mid(pos1, pos2 - pos1));
pos1 = pos2 + 1;
}
else break;
}
strString.push_back(tmpString.Mid(pos1, tmpString.GetLength() - pos1));
wordArtString.push_back(tmpString.Mid(pos1, tmpString.GetLength() - pos1));
}
CString strStyle = oNodeP.GetAttribute(_T("style"));
PPTX::CCSS oCSSParser;
oCSSParser.LoadFromString2(strStyle);
......@@ -1912,30 +1879,26 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
nFontSize = _wtoi(pPair->second.GetBuffer()) * 2;
}
if (true)
{
nullable_string sFitPath;
oNodeP.ReadAttributeBase(L"fitpath", sFitPath);
if (sFitPath.is_init() && (*sFitPath == _T("true") || *sFitPath == _T("t")))
{
nFontSize = 2;
bFitPath = true;
}
nullable_string sFitShape;
oNodeP.ReadAttributeBase(L"fitshape", sFitShape);
if (sFitShape.is_init() && (*sFitShape == _T("true") || *sFitShape == _T("t")))
{
nFontSize = 2;
bFitShape = true;
}
nullable_string sTrim;
oNodeP.ReadAttributeBase(L"trim", sTrim);
if (sTrim.is_init() && (*sTrim == _T("true") || *sTrim == _T("t")))
{
bIsTrimTextPath = true;
}
bTrimTextPath = true;
}
}
else if (_T("fill") == strNameP)
{
......@@ -1944,16 +1907,34 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
nullable_string sColor2;
nullable_string sType;
nullable_string sFocus;
nullable_string sFocusSize;
nullable_string sFocusPosition;
nullable_string sAngle;
nullable_string sColors;
oNodeP.ReadAttributeBase(L"opacity", sOpacity);
oNodeP.ReadAttributeBase(L"opacity2", sOpacity2);
oNodeP.ReadAttributeBase(L"color2", sColor2);
oNodeP.ReadAttributeBase(L"type", sType);
oNodeP.ReadAttributeBase(L"focus", sFocus);
oNodeP.ReadAttributeBase(L"angle", sAngle);
oNodeP.ReadAttributeBase(L"colors", sColors);
oNodeP.ReadAttributeBase(L"opacity" , sOpacity);
oNodeP.ReadAttributeBase(L"opacity2" , sOpacity2);
oNodeP.ReadAttributeBase(L"color2" , sColor2);
oNodeP.ReadAttributeBase(L"type" , sType);
oNodeP.ReadAttributeBase(L"focus" , sFocus);
oNodeP.ReadAttributeBase(L"focussize" , sFocusSize);
oNodeP.ReadAttributeBase(L"focusposition" , sFocusPosition);
oNodeP.ReadAttributeBase(L"angle" , sAngle);
oNodeP.ReadAttributeBase(L"colors" , sColors);
if (sType.is_init())
{
if (*sType == _T("gradient")) eFillType = etGradFill;
else if (*sType == _T("gradientradial")) eFillType = etGradFill;
else if (*sType == _T("pattern")) eFillType = etPattFill;
else if (*sType == _T("tile")) eFillType = etBlipFill;
else if (*sType == _T("frame")) eFillType = etBlipFill;
}
else
{
if (sFocus.is_init() || sColors.is_init() || sAngle.is_init() || sFocusSize.is_init() || sFocusPosition.is_init())
eFillType = etGradFill;
}
if (sFocus.is_init())
{
......@@ -1964,8 +1945,8 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
bOpacity = true;
lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
oMod.name = _T("alpha");
int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA;
oMod.val = (int)(lAlpha * 100000.0 / 255.0);
if (arColors.at(0)->is_init())
arColors.at(0)->Color->Modifiers.push_back(oMod);
}
......@@ -1974,16 +1955,13 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
bOpacity2 = true;
lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity2);
oMod.name = _T("alpha");
int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod2.val = nA;
oMod2.val = (int)(lAlpha * 100000.0 / 255.0);
if (arColors.at(1)->is_init())
arColors.at(1)->Color->Modifiers.push_back(oMod2);
}
if (sColor2.is_init())
{
if (etSolidFill == eFillType)
eFillType = etGradFill;
NSPresentationEditor::CColor color;
if (sColor2->Find(L"fill") != -1)
{
......@@ -2014,6 +1992,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
arColors.push_back(oColor);
else
{
//дублирование
PPTX::Logic::UniColor *oColor1 = new PPTX::Logic::UniColor();
oColor1->Color = new PPTX::Logic::SrgbClr();
oColor1->Color->SetRGB(color.R, color.G, color.B);
......@@ -2024,22 +2003,10 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
}
arPos.push_back(100000);
}
if (sType.is_init())
{
if (*sType == _T("gradient"))
{
eFillType = etGradFill;
}
else if (*sType == _T("gradientradial") || *sType == _T("gradientRadial"))
{
// TODO: дописать радиальный!!!
eFillType = etGradFill;
}
}
if (sAngle.is_init())
{
nAngle = _wtoi(sAngle->GetBuffer());
nAngle = (-1)*nAngle + 90;
nAngle = (-1) * nAngle + 90;
}
if (sColors.is_init())
{
......@@ -2054,7 +2021,6 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
resToken = strColors.Tokenize(_T(";"), curPos);
while (resToken != _T(""))
{
CString strPos = resToken.Left(resToken.Find(_T(" ")));
CString strColor = resToken.Right(resToken.GetLength() - resToken.Find(_T(" ")) - 1);
double pos;
......@@ -2074,7 +2040,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
arGradMap.insert(std::pair<PPTX::Logic::UniColor*, int>(oColor, (int)pos) );
resToken = strColors.Tokenize(_T(";"), curPos);
};
}
}
}
......@@ -2111,12 +2077,14 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
}
}*/
}
CString strRPr, strPPr, strSize;
srPr += _T("<w:rFonts w:ascii=\"") + sFont + _T("\" w:hAnsi=\"") + sFont + _T("\"/>");
CString strSize;
strSize.Format(_T("%d"), nFontSize);
srPr += _T("<w:sz w:val=\"") + strSize + _T("\"/><w:szCs w:val=\"") + strSize + _T("\"/>");
strPPr = _T("<w:jc w:val=\"center\"/>");
strRPr += _T("<w:rFonts w:ascii=\"") + sFont + _T("\" w:hAnsi=\"") + sFont + _T("\"/>");
strRPr += _T("<w:sz w:val=\"") + strSize + _T("\"/><w:szCs w:val=\"") + strSize + _T("\"/>");
nullable_string sStrokeColor;
nullable_string sStrokeWeight;
......@@ -2126,18 +2094,17 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
oNodeShape.ReadAttributeBase(L"stroked", sStroked);
//textFill
srPr += _T("<w14:textFill>");
strRPr += _T("<w14:textFill>");
if (eFillType == etSolidFill)
{
srPr += _T("<w14:solidFill>");
srPr += arColors.at(0)->toXML();
srPr += _T("</w14:solidFill>");
strRPr += _T("<w14:solidFill>");
strRPr += arColors.at(0)->toXML();
strRPr += _T("</w14:solidFill>");
}
else if (eFillType == etGradFill)
{
srPr += _T("<w14:gradFill><w14:gsLst>");
strRPr += _T("<w14:gradFill><w14:gsLst>");
int nSize = arColors.size();
bool bRevert = false;
int nColorsLen = arColors.size();
......@@ -2177,7 +2144,6 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
//else if (-1 < nFocus && nFocus < 0)
else if (((nAngle != 90) && (-1 < nFocus && nFocus < 0)) || ((nAngle == 90) && (0 < nFocus && nFocus < 1)))
{
if (nAngle != 90)
dNewZero *= -1;
......@@ -2227,33 +2193,38 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
CString strPos;
strPos.Format(_T("%d"), pos);
srPr += _T("<w14:gs w14:pos = \"") + strPos + _T("\">");
srPr += color;
srPr += _T("</w14:gs>");
strRPr += _T("<w14:gs w14:pos = \"") + strPos + _T("\">");
strRPr += color;
strRPr += _T("</w14:gs>");
}
CString strAngle;
strAngle.Format(_T("%d"), nAngle * 60000);
srPr += _T("</w14:gsLst><w14:lin w14:ang=\"") + strAngle + _T("\" w14:scaled=\"0\"/></w14:gradFill>");
strRPr += _T("</w14:gsLst><w14:lin w14:ang=\"") + strAngle + _T("\" w14:scaled=\"0\"/></w14:gradFill>");
}
else if (eFillType == etNoFill)
srPr += _T("<w14:noFill/>");
{
strRPr += _T("<w14:noFill/>");
}
else
{
//не существует в природе
}
srPr += _T("</w14:textFill>");
strRPr += _T("</w14:textFill>");
//textOutline
double m_dValue;
CString strStrokeW;
double m_dValue = 1;
if (sStrokeWeight.is_init())
{
CString strW(*sStrokeWeight);
strW.Remove('pt');
m_dValue = _wtof(strW);
}
else
m_dValue = 1;
CString strStrokeW;
strStrokeW.Format(_T("%d"), (int)Pt_To_Emu(m_dValue));
srPr += _T("<w14:textOutline w14:w=\"") + strStrokeW + _T("\">");
strRPr += _T("<w14:textOutline w14:w=\"") + strStrokeW + _T("\">");
smart_ptr<PPTX::Logic::SolidFill> pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = _T("a");
......@@ -2265,7 +2236,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
{
if (*sStroked == _T("false") || *sStroked == _T("f"))
{
srPr += _T("<w14:noFill/>");
strRPr += _T("<w14:noFill/>");
bStroked = false;
}
}
......@@ -2279,15 +2250,15 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
pSolid->Color.Color->SetRGB(0x00, 0x00, 0x00);
if (bStroked)
srPr += pSolid->toXML();
strRPr += pSolid->toXML();
srPr += _T("</w14:textOutline>");
strRPr += _T("</w14:textOutline>");
for (int i = 0; i < strString.size(); i++)
for (int i = 0; i < wordArtString.size(); i++)
{
CString sParaRun = _T("<w:r><w:rPr>") + srPr + _T("</w:rPr>") + _T("<w:t>") + strString[i] + _T("</w:t></w:r>");
CString sParaRun = _T("<w:r><w:rPr>") + strRPr + _T("</w:rPr>") + _T("<w:t>") + wordArtString[i] + _T("</w:t></w:r>");
sTxbxContent += _T("<w:p><w:pPr><w:rPr>") + srPr + _T("</w:rPr></w:pPr>") + sParaRun + _T("</w:p>");
sTxbxContent += _T("<w:p><w:pPr>") + strPPr + _T("<w:rPr>") + strRPr + _T("</w:rPr></w:pPr>") + sParaRun + _T("</w:p>");
}
sTxbxContent += _T("</w:txbxContent>");
pShape->TextBoxShape = sTxbxContent;
......@@ -2300,7 +2271,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
pShape->TextBoxBodyPr->rIns = 0;
pShape->TextBoxBodyPr->bIns = 0;
if (!bIsTrimTextPath)
if (!bTrimTextPath)
{
// нужно для данного размера шейпа выставить отступы сверху и снизу
// top: Ascent - CapHeight
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment