Commit e78fc0be authored by ElenaSubbotina's avatar ElenaSubbotina

x2t - fix users files

parent d9986d09
...@@ -1681,7 +1681,10 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -1681,7 +1681,10 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
if (!elem) return; if (!elem) return;
std::wstring strNameNode = oNodeShape.GetName(); std::wstring strNameNode = oNodeShape.GetName();
bool bIsNeedCoordSizes = true;
bool bIsNeedCoordSizes = true;
bool bTextBox = false;
bool bPicture = false;
std::wstring strStyleAdvenced = L""; std::wstring strStyleAdvenced = L"";
...@@ -1911,745 +1914,778 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -1911,745 +1914,778 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
oShapeElem.m_pShape->getBaseShape()->m_oPath.SetCoordsize(21600, 21600); oShapeElem.m_pShape->getBaseShape()->m_oPath.SetCoordsize(21600, 21600);
} }
if (pPPTShape->m_eType == PPTShapes::sptCTextBox)
{
bTextBox = true;
}
else if (pPPTShape->m_eType == PPTShapes::sptCFrame)
{
bPicture= true;
}
std::wstring strXmlPPTX; std::wstring strXmlPPTX;
PPTX::Logic::Shape* pShape = new PPTX::Logic::Shape(); PPTX::Logic::Shape* pShape = NULL; //todoooo + CxnSp
PPTX::Logic::Pic* pPicture = NULL;
if (!pShape->oTextBoxBodyPr.IsInit()) PPTX::Logic::SpPr* pSpPr = NULL;
pShape->oTextBoxBodyPr = new PPTX::Logic::BodyPr(); PPTX::Logic::CNvPr* pCNvPr = NULL;
if (bPicture)
{
pPicture = new PPTX::Logic::Pic();
elem->InitElem(pPicture);
if (pPPTShape->IsWordArt()) pSpPr = &pPicture->spPr;
pCNvPr = &pPicture->nvPicPr.cNvPr;
strXmlPPTX = oShapeElem.ConvertPPTShapeToPPTX(true);
}
else
{ {
enum EFilltype pShape = new PPTX::Logic::Shape();
{ elem->InitElem(pShape);
etBlipFill = 0,
etGradFill = 1,
etNoFill = 2,
etPattFill = 3,
etSolidFill = 4
};
PPTShapes::ShapeType eShapeType = pPPTShape->m_eType;
SimpleTypes::ETextShapeType eTextShapeType;
switch (eShapeType)
{
case PPTShapes::ShapeType::sptCTextPlain: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextPlain; break;
case PPTShapes::ShapeType::sptCTextArchUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchUp; break;
case PPTShapes::ShapeType::sptCTextArchDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchDown; break;
case PPTShapes::ShapeType::sptCTextButton: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextButton; break;
case PPTShapes::ShapeType::sptCTextCurveUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCurveUp; break;
case PPTShapes::ShapeType::sptCTextCurveDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCurveDown; break;
case PPTShapes::ShapeType::sptCTextCanUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCanUp; break;
case PPTShapes::ShapeType::sptCTextCanDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCanDown; break;
case PPTShapes::ShapeType::sptCTextWave1: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextWave1; break;
case PPTShapes::ShapeType::sptCTextWave2: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextWave2; break;
case PPTShapes::ShapeType::sptCTextWave3: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDoubleWave1; break;
case PPTShapes::ShapeType::sptCTextWave4: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextWave4; break;
case PPTShapes::ShapeType::sptCTextInflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextInflate; break;
case PPTShapes::ShapeType::sptCTextDeflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflate; break;
case PPTShapes::ShapeType::sptCTextInflateBottom: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextInflateBottom; break;
case PPTShapes::ShapeType::sptCTextDeflateBottom: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateBottom; break;
case PPTShapes::ShapeType::sptCTextInflateTop: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextInflateTop; break;
case PPTShapes::ShapeType::sptCTextDeflateTop: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateTop; break;
case PPTShapes::ShapeType::sptCTextDeflateInflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateInflate; break;
case PPTShapes::ShapeType::sptCTextDeflateInflateDeflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateInflateDeflate; break;
case PPTShapes::ShapeType::sptCTextFadeRight: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeRight; break;
case PPTShapes::ShapeType::sptCTextFadeLeft: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeLeft; break;
case PPTShapes::ShapeType::sptCTextFadeUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeUp; break;
case PPTShapes::ShapeType::sptCTextFadeDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeDown; break;
case PPTShapes::ShapeType::sptCTextSlantUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextSlantUp; break;
case PPTShapes::ShapeType::sptCTextSlantDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextSlantDown; break;
case PPTShapes::ShapeType::sptCTextCascadeUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCascadeUp; break;
case PPTShapes::ShapeType::sptCTextCascadeDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCascadeDown; break;
case PPTShapes::ShapeType::sptCTextButtonPour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextButtonPour; break;
case PPTShapes::ShapeType::sptCTextStop: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextStop; break;
case PPTShapes::ShapeType::sptCTextTriangle: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextTriangle; break;
case PPTShapes::ShapeType::sptCTextTriangleInverted: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextTriangleInverted; break;
case PPTShapes::ShapeType::sptCTextChevron: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextChevron; break;
case PPTShapes::ShapeType::sptCTextChevronInverted: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextChevronInverted; break;
case PPTShapes::ShapeType::sptCTextRingInside: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextRingInside; break;
case PPTShapes::ShapeType::sptCTextRingOutside: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextRingOutside; break;
case PPTShapes::ShapeType::sptCTextCirclePour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCirclePour; break;
case PPTShapes::ShapeType::sptCTextArchUpPour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchUpPour; break;
case PPTShapes::ShapeType::sptCTextArchDownPour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchDownPour; break;
default: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextNoShape; break;
}
SimpleTypes::CTextShapeType<> oTextShapeType;
oTextShapeType.SetValue(eTextShapeType);
std::wstring strPrstTxWarp = L"<a:prstTxWarp prst=\"" + oTextShapeType.ToString() + L"\"><a:avLst/></a:prstTxWarp>"; pSpPr = &pShape->spPr;
pCNvPr = &pShape->nvSpPr.cNvPr;
XmlUtils::CXmlNode oPrstTxWarpNode;
oPrstTxWarpNode.FromXmlString(strPrstTxWarp);
pShape->oTextBoxBodyPr->prstTxWarp = oPrstTxWarpNode; if (!pShape->oTextBoxBodyPr.IsInit())
pShape->oTextBoxBodyPr = new PPTX::Logic::BodyPr();
bool bTrimTextPath = false, bFitShape = false, bFitPath = false;
if (pPPTShape->IsWordArt())
XmlUtils::CXmlNodes oChilds;
if (oNodeShape.GetNodes(L"*", oChilds))
{ {
LONG lChildsCount = oChilds.GetCount(); enum EFilltype
std::vector<std::wstring> wordArtString;
EFilltype eFillType = etNoFill;;
std::wstring sTxbxContent = L"<w:txbxContent>";
std::wstring sFont = L"Arial Black";
int nFontSize = 36;
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;
std::vector<PPTX::Logic::UniColor*> arColorsNew;
std::vector<int> arPos;
std::vector<int> arPosNew;
std::map<PPTX::Logic::UniColor*, int> arGradMap;
int R = 255, G = 255, B = 255;
nullable_string sFillColor;
oNodeShape.ReadAttributeBase(L"fillcolor", sFillColor);
if (sFillColor.is_init())
{ {
eFillType = etSolidFill; etBlipFill = 0,
etGradFill = 1,
NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sFillColor); etNoFill = 2,
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill(); etPattFill = 3,
pSolid->m_namespace = L"a"; etSolidFill = 4
};
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B); PPTShapes::ShapeType eShapeType = pPPTShape->m_eType;
arColors.push_back(&pSolid->Color); SimpleTypes::ETextShapeType eTextShapeType;
arPos.push_back(0); switch (eShapeType)
{
R = color.R; case PPTShapes::ShapeType::sptCTextPlain: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextPlain; break;
G = color.G; case PPTShapes::ShapeType::sptCTextArchUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchUp; break;
B = color.B; case PPTShapes::ShapeType::sptCTextArchDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchDown; break;
case PPTShapes::ShapeType::sptCTextButton: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextButton; break;
case PPTShapes::ShapeType::sptCTextCurveUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCurveUp; break;
case PPTShapes::ShapeType::sptCTextCurveDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCurveDown; break;
case PPTShapes::ShapeType::sptCTextCanUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCanUp; break;
case PPTShapes::ShapeType::sptCTextCanDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCanDown; break;
case PPTShapes::ShapeType::sptCTextWave1: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextWave1; break;
case PPTShapes::ShapeType::sptCTextWave2: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextWave2; break;
case PPTShapes::ShapeType::sptCTextWave3: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDoubleWave1; break;
case PPTShapes::ShapeType::sptCTextWave4: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextWave4; break;
case PPTShapes::ShapeType::sptCTextInflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextInflate; break;
case PPTShapes::ShapeType::sptCTextDeflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflate; break;
case PPTShapes::ShapeType::sptCTextInflateBottom: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextInflateBottom; break;
case PPTShapes::ShapeType::sptCTextDeflateBottom: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateBottom; break;
case PPTShapes::ShapeType::sptCTextInflateTop: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextInflateTop; break;
case PPTShapes::ShapeType::sptCTextDeflateTop: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateTop; break;
case PPTShapes::ShapeType::sptCTextDeflateInflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateInflate; break;
case PPTShapes::ShapeType::sptCTextDeflateInflateDeflate: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextDeflateInflateDeflate; break;
case PPTShapes::ShapeType::sptCTextFadeRight: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeRight; break;
case PPTShapes::ShapeType::sptCTextFadeLeft: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeLeft; break;
case PPTShapes::ShapeType::sptCTextFadeUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeUp; break;
case PPTShapes::ShapeType::sptCTextFadeDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextFadeDown; break;
case PPTShapes::ShapeType::sptCTextSlantUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextSlantUp; break;
case PPTShapes::ShapeType::sptCTextSlantDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextSlantDown; break;
case PPTShapes::ShapeType::sptCTextCascadeUp: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCascadeUp; break;
case PPTShapes::ShapeType::sptCTextCascadeDown: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCascadeDown; break;
case PPTShapes::ShapeType::sptCTextButtonPour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextButtonPour; break;
case PPTShapes::ShapeType::sptCTextStop: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextStop; break;
case PPTShapes::ShapeType::sptCTextTriangle: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextTriangle; break;
case PPTShapes::ShapeType::sptCTextTriangleInverted: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextTriangleInverted; break;
case PPTShapes::ShapeType::sptCTextChevron: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextChevron; break;
case PPTShapes::ShapeType::sptCTextChevronInverted: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextChevronInverted; break;
case PPTShapes::ShapeType::sptCTextRingInside: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextRingInside; break;
case PPTShapes::ShapeType::sptCTextRingOutside: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextRingOutside; break;
case PPTShapes::ShapeType::sptCTextCirclePour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextCirclePour; break;
case PPTShapes::ShapeType::sptCTextArchUpPour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchUpPour; break;
case PPTShapes::ShapeType::sptCTextArchDownPour: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextArchDownPour; break;
default: eTextShapeType = SimpleTypes::ETextShapeType::textshapetypeTextNoShape; break;
} }
SimpleTypes::CTextShapeType<> oTextShapeType;
oTextShapeType.SetValue(eTextShapeType);
std::wstring strPrstTxWarp = L"<a:prstTxWarp prst=\"" + oTextShapeType.ToString() + L"\"><a:avLst/></a:prstTxWarp>";
if (eFillType == etNoFill) XmlUtils::CXmlNode oPrstTxWarpNode;
{ oPrstTxWarpNode.FromXmlString(strPrstTxWarp);
// default color for vml = white
nullable_string sFilled;
oNodeShape.ReadAttributeBase(L"filled", sFilled);
if (!sFilled.is_init() || (*sFilled != L"false") && *sFilled != L"f")
{
eFillType = etSolidFill;
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(R, G, B);
arColors.push_back(&pSolid->Color);
arPos.push_back(0);
}
}
for (LONG k = 0; k < lChildsCount; k++) pShape->oTextBoxBodyPr->prstTxWarp = oPrstTxWarpNode;
{
XmlUtils::CXmlNode oNodeP; bool bTrimTextPath = false, bFitShape = false, bFitPath = false;
oChilds.GetAt(k, oNodeP);
std::wstring strNameP = XmlUtils::GetNameNoNS(oNodeP.GetName()); XmlUtils::CXmlNodes oChilds;
if (L"textpath" == strNameP) if (oNodeShape.GetNodes(L"*", oChilds))
{
LONG lChildsCount = oChilds.GetCount();
std::vector<std::wstring> wordArtString;
EFilltype eFillType = etNoFill;;
std::wstring sTxbxContent = L"<w:txbxContent>";
std::wstring sFont = L"Arial Black";
int nFontSize = 36;
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;
std::vector<PPTX::Logic::UniColor*> arColorsNew;
std::vector<int> arPos;
std::vector<int> arPosNew;
std::map<PPTX::Logic::UniColor*, int> arGradMap;
int R = 255, G = 255, B = 255;
nullable_string sFillColor;
oNodeShape.ReadAttributeBase(L"fillcolor", sFillColor);
if (sFillColor.is_init())
{ {
std::wstring tmpString = oNodeP.GetText(); //для обхода &#xA пишется дубль в контент eFillType = etSolidFill;
NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sFillColor);
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
arColors.push_back(&pSolid->Color);
arPos.push_back(0);
R = color.R;
G = color.G;
B = color.B;
}
if (tmpString.empty()) if (eFillType == etNoFill)
{
// default color for vml = white
nullable_string sFilled;
oNodeShape.ReadAttributeBase(L"filled", sFilled);
if (!sFilled.is_init() || (*sFilled != L"false") && *sFilled != L"f")
{ {
tmpString = oNodeP.GetAttribute(L"string"); eFillType = etSolidFill;
CorrectXmlString(tmpString );
wordArtString.push_back(tmpString ); PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(R, G, B);
arColors.push_back(&pSolid->Color);
arPos.push_back(0);
} }
else }
{
CorrectXmlString(tmpString ); for (LONG k = 0; k < lChildsCount; k++)
{
XmlUtils::CXmlNode oNodeP;
oChilds.GetAt(k, oNodeP);
int pos1 = 0, pos2 = 0; std::wstring strNameP = XmlUtils::GetNameNoNS(oNodeP.GetName());
if (L"textpath" == strNameP)
{
std::wstring tmpString = oNodeP.GetText(); //для обхода &#xA пишется дубль в контент
while(pos1 < (int)tmpString.length() && pos2 < (int)tmpString.length()) if (tmpString.empty())
{
tmpString = oNodeP.GetAttribute(L"string");
CorrectXmlString(tmpString );
wordArtString.push_back(tmpString );
}
else
{ {
pos2 = (int)tmpString.find(L"\n", pos1); CorrectXmlString(tmpString );
if (pos2 > 0)
int pos1 = 0, pos2 = 0;
while(pos1 < (int)tmpString.length() && pos2 < (int)tmpString.length())
{ {
wordArtString.push_back(tmpString.substr(pos1, pos2 - pos1)); pos2 = (int)tmpString.find(L"\n", pos1);
pos1 = pos2 + 1; if (pos2 > 0)
{
wordArtString.push_back(tmpString.substr(pos1, pos2 - pos1));
pos1 = pos2 + 1;
}
else break;
} }
else break; wordArtString.push_back(tmpString.substr(pos1, tmpString.length() - pos1));
} }
wordArtString.push_back(tmpString.substr(pos1, tmpString.length() - pos1));
}
std::wstring strStyle = oNodeP.GetAttribute(L"style"); std::wstring strStyle = oNodeP.GetAttribute(L"style");
PPTX::CCSS oCSSParser; PPTX::CCSS oCSSParser;
oCSSParser.LoadFromString2(strStyle); oCSSParser.LoadFromString2(strStyle);
std::map<std::wstring, std::wstring>::iterator pPair = oCSSParser.m_mapSettings.find(L"font-family"); std::map<std::wstring, std::wstring>::iterator pPair = oCSSParser.m_mapSettings.find(L"font-family");
if (pPair != oCSSParser.m_mapSettings.end()) if (pPair != oCSSParser.m_mapSettings.end())
{ {
sFont = pPair->second; sFont = pPair->second;
XmlUtils::replace_all(sFont, L"\"", L""); XmlUtils::replace_all(sFont, L"\"", L"");
} }
pPair = oCSSParser.m_mapSettings.find(L"font-size"); pPair = oCSSParser.m_mapSettings.find(L"font-size");
if (pPair != oCSSParser.m_mapSettings.end()) if (pPair != oCSSParser.m_mapSettings.end())
{ {
nFontSize = _wtoi(pPair->second.c_str()) * 2; nFontSize = _wtoi(pPair->second.c_str()) * 2;
} }
nullable_string sFitPath;
oNodeP.ReadAttributeBase(L"fitpath", sFitPath);
if (sFitPath.is_init() && (*sFitPath == L"true" || *sFitPath == L"t"))
{
bFitPath = true;
}
nullable_string sFitShape;
oNodeP.ReadAttributeBase(L"fitshape", sFitShape);
if (sFitShape.is_init() && (*sFitShape == L"true" || *sFitShape == L"t"))
{
bFitShape = true;
}
nullable_string sTrim;
oNodeP.ReadAttributeBase(L"trim", sTrim);
if (sTrim.is_init() && (*sTrim == L"true" || *sTrim == L"t"))
{
bTrimTextPath = true;
}
}
else if (L"fill" == strNameP)
{
nullable_string sOpacity;
nullable_string sOpacity2;
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"focussize" , sFocusSize);
oNodeP.ReadAttributeBase(L"focusposition" , sFocusPosition);
oNodeP.ReadAttributeBase(L"angle" , sAngle);
oNodeP.ReadAttributeBase(L"colors" , sColors);
if (sType.is_init())
{
if (*sType == L"gradient") eFillType = etGradFill;
else if (*sType == L"gradientradial") eFillType = etGradFill;
else if (*sType == L"pattern") eFillType = etPattFill;
else if (*sType == L"tile") eFillType = etBlipFill;
else if (*sType == L"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()) nullable_string sFitPath;
{ oNodeP.ReadAttributeBase(L"fitpath", sFitPath);
nFocus = _wtoi(sFocus->c_str())/100.0; if (sFitPath.is_init() && (*sFitPath == L"true" || *sFitPath == L"t"))
} {
if (sOpacity.is_init()) bFitPath = true;
{ }
bOpacity = true;
lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
oMod.name = L"alpha";
oMod.val = (int)(lAlpha * 100000.0 / 255.0);
if (arColors.at(0)->is_init()) nullable_string sFitShape;
arColors.at(0)->Color->Modifiers.push_back(oMod); oNodeP.ReadAttributeBase(L"fitshape", sFitShape);
} if (sFitShape.is_init() && (*sFitShape == L"true" || *sFitShape == L"t"))
if (sOpacity2.is_init()) {
{ bFitShape = true;
bOpacity2 = true; }
lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity2);
oMod.name = L"alpha"; nullable_string sTrim;
oMod2.val = (int)(lAlpha * 100000.0 / 255.0); oNodeP.ReadAttributeBase(L"trim", sTrim);
if (sTrim.is_init() && (*sTrim == L"true" || *sTrim == L"t"))
if (arColors.at(1)->is_init()) {
arColors.at(1)->Color->Modifiers.push_back(oMod2); bTrimTextPath = true;
}
} }
if (sColor2.is_init()) else if (L"fill" == strNameP)
{ {
NSPresentationEditor::CColor color; nullable_string sOpacity;
if (sColor2->find(L"fill") != -1) nullable_string sOpacity2;
{ nullable_string sColor2;
std::wstring sColorEffect = *sColor2; nullable_string sType;
if (sColorEffect.length() > 5) nullable_string sFocus;
sColorEffect = sColorEffect.substr(5); nullable_string sFocusSize;
nullable_string sFocusPosition;
int resR, resG, resB; nullable_string sAngle;
GetColorWithEffect(sColorEffect, R, G, B, resR, resG, resB); nullable_string sColors;
color.R = resR; oNodeP.ReadAttributeBase(L"opacity" , sOpacity);
color.G = resG; oNodeP.ReadAttributeBase(L"opacity2" , sOpacity2);
color.B = resB; oNodeP.ReadAttributeBase(L"color2" , sColor2);
} oNodeP.ReadAttributeBase(L"type" , sType);
else oNodeP.ReadAttributeBase(L"focus" , sFocus);
{ oNodeP.ReadAttributeBase(L"focussize" , sFocusSize);
color = NS_DWC_Common::getColorFromString(*sColor2); oNodeP.ReadAttributeBase(L"focusposition" , sFocusPosition);
} oNodeP.ReadAttributeBase(L"angle" , sAngle);
oNodeP.ReadAttributeBase(L"colors" , sColors);
PPTX::Logic::UniColor *oColor = new PPTX::Logic::UniColor();
oColor->Color = new PPTX::Logic::SrgbClr(); if (sType.is_init())
oColor->Color->SetRGB(color.R, color.G, color.B); {
if (*sType == L"gradient") eFillType = etGradFill;
if (bOpacity2) else if (*sType == L"gradientradial") eFillType = etGradFill;
oColor->Color->Modifiers.push_back(oMod2); else if (*sType == L"pattern") eFillType = etPattFill;
else if (*sType == L"tile") eFillType = etBlipFill;
if (arColors.size() > 0) else if (*sType == L"frame") eFillType = etBlipFill;
arColors.push_back(oColor); }
else else
{ {
//дублирование if (sFocus.is_init() || sColors.is_init() || sAngle.is_init() || sFocusSize.is_init() || sFocusPosition.is_init())
PPTX::Logic::UniColor *oColor1 = new PPTX::Logic::UniColor(); eFillType = etGradFill;
oColor1->Color = new PPTX::Logic::SrgbClr();
oColor1->Color->SetRGB(color.R, color.G, color.B);
arColors.push_back(oColor1);
arPos.push_back(0);
arColors.push_back(oColor);
} }
arPos.push_back(100000);
}
if (sAngle.is_init())
{
nAngle = _wtoi(sAngle->c_str());
nAngle = (-1) * nAngle + 90;
}
if (sColors.is_init())
{
bColors = true;
std::wstring strColors = sColors.get();
arColors.clear();
arPos.clear();
std::vector<std::wstring> arSplit; if (sFocus.is_init())
boost::algorithm::split(arSplit, strColors, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on); {
nFocus = _wtoi(sFocus->c_str())/100.0;
}
if (sOpacity.is_init())
{
bOpacity = true;
lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
oMod.name = L"alpha";
oMod.val = (int)(lAlpha * 100000.0 / 255.0);
for (size_t i = 0 ; i < arSplit.size(); i++) if (arColors.at(0)->is_init())
{ arColors.at(0)->Color->Modifiers.push_back(oMod);
int p = (int)arSplit[i].find(L" "); }
if (sOpacity2.is_init())
{
bOpacity2 = true;
lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity2);
oMod.name = L"alpha";
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())
{
NSPresentationEditor::CColor color;
if (sColor2->find(L"fill") != -1)
{
std::wstring sColorEffect = *sColor2;
if (sColorEffect.length() > 5)
sColorEffect = sColorEffect.substr(5);
std::wstring strPos = arSplit[i].substr(0, p); int resR, resG, resB;
std::wstring strColor = arSplit[i].substr(p + 1); GetColorWithEffect(sColorEffect, R, G, B, resR, resG, resB);
double pos = strPos.empty() ? 0 : _wtof(strPos.c_str()); color.R = resR;
color.G = resG;
color.B = resB;
}
else
{
color = NS_DWC_Common::getColorFromString(*sColor2);
}
NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(strColor); PPTX::Logic::UniColor *oColor = new PPTX::Logic::UniColor();
PPTX::Logic::UniColor *oColor = new PPTX::Logic::UniColor(); oColor->Color = new PPTX::Logic::SrgbClr();
oColor->Color = new PPTX::Logic::SrgbClr(); oColor->Color->SetRGB(color.R, color.G, color.B);
oColor->Color->SetRGB(color.R, color.G, color.B);
if (pos <= 1) if (bOpacity2)
pos = 100000 * pos; oColor->Color->Modifiers.push_back(oMod2);
else
pos = pos / 65536 * 100000;
arColors.push_back(oColor);
arPos.push_back((int)pos);
arGradMap.insert(std::pair<PPTX::Logic::UniColor*, int>(oColor, (int)pos) ); if (arColors.size() > 0)
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);
arColors.push_back(oColor1);
arPos.push_back(0);
arColors.push_back(oColor);
}
arPos.push_back(100000);
}
if (sAngle.is_init())
{
nAngle = _wtoi(sAngle->c_str());
nAngle = (-1) * nAngle + 90;
}
if (sColors.is_init())
{
bColors = true;
std::wstring strColors = sColors.get();
} arColors.clear();
} arPos.clear();
} std::vector<std::wstring> arSplit;
/*else if (L"dashstyle") == strNameP) boost::algorithm::split(arSplit, strColors, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
{
nullable_string sStrokeDashStyle;
oNodeP.ReadAttributeBase(L"dashstyle", sStrokeDashStyle);
if (sStrokeDashStyle.is_init())
{
if (*sStrokeDashStyle == L"solid"))
sDashStyle = L"solid");
else if (*sStrokeDashStyle == L"shortdash"))
sDashStyle = L"sysDash");
else if (*sStrokeDashStyle == L"shortdot"))
sDashStyle = L"sysDot");
else if (*sStrokeDashStyle == L"shortdashdot"))
sDashStyle = L"sysDashDot");
else if (*sStrokeDashStyle == L"shortdashdotdot"))
sDashStyle = L"sysDashDotDot");
else if (*sStrokeDashStyle == L"dot"))
sDashStyle = L"dot");
else if (*sStrokeDashStyle == L"dash"))
sDashStyle = L"dash");
else if (*sStrokeDashStyle == L"longdash"))
sDashStyle = L"lgDash");
else if (*sStrokeDashStyle == L"dashdot"))
sDashStyle = L"dashDot");
else if (*sStrokeDashStyle == L"longdashdot"))
sDashStyle = L"lgDashDot");
else if (*sStrokeDashStyle == L"longdashdotdot"))
sDashStyle = L"lgDashDotDot");
else
sDashStyle = L"solid");
}
}*/
}
std::wstring strRPr, strPPr;
std::wstring sSize = std::to_wstring(nFontSize);
strPPr = L"<w:jc w:val=\"center\"/>";
strRPr += L"<w:rFonts w:ascii=\"" + sFont + L"\" w:hAnsi=\"" + sFont + L"\"/>"; for (size_t i = 0 ; i < arSplit.size(); i++)
strRPr += L"<w:sz w:val=\"" + sSize + L"\"/><w:szCs w:val=\"" + sSize+ L"\"/>"; {
int p = (int)arSplit[i].find(L" ");
nullable_string sStrokeColor; std::wstring strPos = arSplit[i].substr(0, p);
nullable_string sStrokeWeight; std::wstring strColor = arSplit[i].substr(p + 1);
nullable_string sStroked;
oNodeShape.ReadAttributeBase(L"strokecolor", sStrokeColor);
oNodeShape.ReadAttributeBase(L"strokeweight", sStrokeWeight);
oNodeShape.ReadAttributeBase(L"stroked", sStroked);
//textFill double pos = strPos.empty() ? 0 : _wtof(strPos.c_str());
strRPr += L"<w14:textFill>";
if (eFillType == etSolidFill)
{
strRPr += L"<w14:solidFill>";
strRPr += arColors.at(0)->toXML();
strRPr += L"</w14:solidFill>";
}
else if (eFillType == etGradFill)
{
strRPr += L"<w14:gradFill><w14:gsLst>";
int nSize = (int)arColors.size();
bool bRevert = false;
int nColorsLen = (int)arColors.size();
int nDiff = nSize - 1;
if (nFocus != 1 && nFocus != 0)
nSize = nSize + nDiff;
double nShift = 100000 / nSize;
double dNewZero = 100000 * nFocus;
//(0 < nFocus && nFocus < 1)
if (((nAngle == 90) && (-1 < nFocus && nFocus < 0)) || ((nAngle != 90) && (0 < nFocus && nFocus < 1)))
{
if (nAngle == 90)
dNewZero *= -1;
arColorsNew.push_back(arColors.at(nColorsLen - 1)); NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(strColor);
arPosNew.push_back(0); PPTX::Logic::UniColor *oColor = new PPTX::Logic::UniColor();
oColor->Color = new PPTX::Logic::SrgbClr();
oColor->Color->SetRGB(color.R, color.G, color.B);
for (int i = nColorsLen - 2; i > 0; i--) if (pos <= 1)
{ pos = 100000 * pos;
arColorsNew.push_back(arColors.at(i)); else
pos = pos / 65536 * 100000;
arColors.push_back(oColor);
arPos.push_back((int)pos);
double dPosNew = dNewZero * arPos.at(i) / 100000; arGradMap.insert(std::pair<PPTX::Logic::UniColor*, int>(oColor, (int)pos) );
arPosNew.push_back((int)dPosNew);
}
for (int i = 0; i < nColorsLen; i++) }
{ }
arColorsNew.push_back(arColors.at(i));
double dPosNew = dNewZero * arPos.at(i) / 100000 + dNewZero;
arPosNew.push_back((int)dPosNew);
} }
/*else if (L"dashstyle") == strNameP)
{
nullable_string sStrokeDashStyle;
oNodeP.ReadAttributeBase(L"dashstyle", sStrokeDashStyle);
if (sStrokeDashStyle.is_init())
{
if (*sStrokeDashStyle == L"solid"))
sDashStyle = L"solid");
else if (*sStrokeDashStyle == L"shortdash"))
sDashStyle = L"sysDash");
else if (*sStrokeDashStyle == L"shortdot"))
sDashStyle = L"sysDot");
else if (*sStrokeDashStyle == L"shortdashdot"))
sDashStyle = L"sysDashDot");
else if (*sStrokeDashStyle == L"shortdashdotdot"))
sDashStyle = L"sysDashDotDot");
else if (*sStrokeDashStyle == L"dot"))
sDashStyle = L"dot");
else if (*sStrokeDashStyle == L"dash"))
sDashStyle = L"dash");
else if (*sStrokeDashStyle == L"longdash"))
sDashStyle = L"lgDash");
else if (*sStrokeDashStyle == L"dashdot"))
sDashStyle = L"dashDot");
else if (*sStrokeDashStyle == L"longdashdot"))
sDashStyle = L"lgDashDot");
else if (*sStrokeDashStyle == L"longdashdotdot"))
sDashStyle = L"lgDashDotDot");
else
sDashStyle = L"solid");
}
}*/
} }
//else if (-1 < nFocus && nFocus < 0) std::wstring strRPr, strPPr;
else if (((nAngle != 90) && (-1 < nFocus && nFocus < 0)) || ((nAngle == 90) && (0 < nFocus && nFocus < 1))) std::wstring sSize = std::to_wstring(nFontSize);
{
if (nAngle != 90) strPPr = L"<w:jc w:val=\"center\"/>";
dNewZero *= -1;
strRPr += L"<w:rFonts w:ascii=\"" + sFont + L"\" w:hAnsi=\"" + sFont + L"\"/>";
strRPr += L"<w:sz w:val=\"" + sSize + L"\"/><w:szCs w:val=\"" + sSize+ L"\"/>";
nullable_string sStrokeColor;
nullable_string sStrokeWeight;
nullable_string sStroked;
oNodeShape.ReadAttributeBase(L"strokecolor", sStrokeColor);
oNodeShape.ReadAttributeBase(L"strokeweight", sStrokeWeight);
oNodeShape.ReadAttributeBase(L"stroked", sStroked);
for (int i = 0; i < nColorsLen - 1; i++) //textFill
strRPr += L"<w14:textFill>";
if (eFillType == etSolidFill)
{
strRPr += L"<w14:solidFill>";
strRPr += arColors.at(0)->toXML();
strRPr += L"</w14:solidFill>";
}
else if (eFillType == etGradFill)
{
strRPr += L"<w14:gradFill><w14:gsLst>";
int nSize = (int)arColors.size();
bool bRevert = false;
int nColorsLen = (int)arColors.size();
int nDiff = nSize - 1;
if (nFocus != 1 && nFocus != 0)
nSize = nSize + nDiff;
double nShift = 100000 / nSize;
double dNewZero = 100000 * nFocus;
//(0 < nFocus && nFocus < 1)
if (((nAngle == 90) && (-1 < nFocus && nFocus < 0)) || ((nAngle != 90) && (0 < nFocus && nFocus < 1)))
{ {
arColorsNew.push_back(arColors.at(i)); if (nAngle == 90)
dNewZero *= -1;
double dPosNew = dNewZero * arPos.at(i) / 100000 ; arColorsNew.push_back(arColors.at(nColorsLen - 1));
arPosNew.push_back((int)dPosNew); arPosNew.push_back(0);
for (int i = nColorsLen - 2; i > 0; i--)
{
arColorsNew.push_back(arColors.at(i));
double dPosNew = dNewZero * arPos.at(i) / 100000;
arPosNew.push_back((int)dPosNew);
}
for (int i = 0; i < nColorsLen; i++)
{
arColorsNew.push_back(arColors.at(i));
double dPosNew = dNewZero * arPos.at(i) / 100000 + dNewZero;
arPosNew.push_back((int)dPosNew);
}
} }
//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;
for (int i = 0; i < nColorsLen - 1; i++)
{
arColorsNew.push_back(arColors.at(i));
double dPosNew = dNewZero * arPos.at(i) / 100000 ;
arPosNew.push_back((int)dPosNew);
}
arColorsNew.push_back(arColors.at(nColorsLen - 1)); arColorsNew.push_back(arColors.at(nColorsLen - 1));
arPosNew.push_back((int)dNewZero); arPosNew.push_back((int)dNewZero);
for (int i = nColorsLen - 2; i >= 0; i--) for (int i = nColorsLen - 2; i >= 0; i--)
{
arColorsNew.push_back(arColors.at(i));
double n1 = 1 - (double)arPos.at(i) / 100000;
double dPosNew = dNewZero * n1 + dNewZero;
arPosNew.push_back((int)dPosNew);
}
}
//nFocus == 0
else if ((nAngle != 90 && nFocus == 0) || (nAngle == 90 && nFocus == 1))
{ {
arColorsNew.push_back(arColors.at(i)); for (int i = 0; i < nColorsLen; i++)
{
arColorsNew.push_back(arColors.at(i));
arPosNew.push_back(arPos.at(i));
}
}
//nFocus == 1
else if ((nAngle != 90 && nFocus == 1) || (nAngle == 90 && nFocus == 0))
{
for (int i = nColorsLen - 1; i >= 0; i--)
{
arColorsNew.push_back(arColors.at(i));
arPosNew.push_back(arPos.at(nColorsLen - i - 1));
}
}
double n1 = 1 - (double)arPos.at(i) / 100000; for (size_t i = 0; i < arColorsNew.size(); i++)
double dPosNew = dNewZero * n1 + dNewZero;
arPosNew.push_back((int)dPosNew);
}
}
//nFocus == 0
else if ((nAngle != 90 && nFocus == 0) || (nAngle == 90 && nFocus == 1))
{
for (int i = 0; i < nColorsLen; i++)
{ {
arColorsNew.push_back(arColors.at(i)); int pos = arPosNew.at(i);
arPosNew.push_back(arPos.at(i)); std::wstring color = arColorsNew.at(i)->toXML();
std::wstring strPos = std::to_wstring(pos);
strRPr += L"<w14:gs w14:pos = \"" + strPos + L"\">";
strRPr += color;
strRPr += L"</w14:gs>";
} }
std::wstring strAngle = std::to_wstring(nAngle * 60000);
strRPr += L"</w14:gsLst><w14:lin w14:ang=\"" + strAngle + L"\" w14:scaled=\"0\"/></w14:gradFill>";
} }
//nFocus == 1 else if (eFillType == etNoFill)
else if ((nAngle != 90 && nFocus == 1) || (nAngle == 90 && nFocus == 0))
{ {
for (int i = nColorsLen - 1; i >= 0; i--) strRPr += L"<w14:noFill/>";
{ }
arColorsNew.push_back(arColors.at(i)); else
arPosNew.push_back(arPos.at(nColorsLen - i - 1)); {
} //не существует в природе
} }
for (size_t i = 0; i < arColorsNew.size(); i++) strRPr += L"</w14:textFill>";
//textOutline
double m_dValue = 1;
if (sStrokeWeight.is_init())
{ {
int pos = arPosNew.at(i); std::wstring strW(*sStrokeWeight);
std::wstring color = arColorsNew.at(i)->toXML(); int p = (int)strW.find(L"pt");
std::wstring strPos = std::to_wstring(pos); if (p >= 0)
strW.erase(p);
strRPr += L"<w14:gs w14:pos = \"" + strPos + L"\">"; m_dValue = _wtof(strW.c_str());
strRPr += color;
strRPr += L"</w14:gs>";
} }
std::wstring strAngle = std::to_wstring(nAngle * 60000);
strRPr += L"</w14:gsLst><w14:lin w14:ang=\"" + strAngle + L"\" w14:scaled=\"0\"/></w14:gradFill>";
}
else if (eFillType == etNoFill)
{
strRPr += L"<w14:noFill/>";
}
else
{
//не существует в природе
}
strRPr += L"</w14:textFill>"; std::wstring strStrokeW = std::to_wstring((int)Pt_To_Emu(m_dValue));
strRPr += L"<w14:textOutline w14:w=\"" + strStrokeW + L"\">";
//textOutline smart_ptr<PPTX::Logic::SolidFill> pSolid = new PPTX::Logic::SolidFill();
double m_dValue = 1; pSolid->m_namespace = L"a";
if (sStrokeWeight.is_init()) pSolid->Color.Color = new PPTX::Logic::SrgbClr();
{ NSPresentationEditor::CColor color;
std::wstring strW(*sStrokeWeight);
int p = (int)strW.find(L"pt"); bool bStroked = true;
if (p >= 0) if (sStroked.is_init())
strW.erase(p); {
if (*sStroked == L"false" || *sStroked == L"f")
{
strRPr += L"<w14:noFill/>";
bStroked = false;
}
}
if (sStrokeColor.is_init())
{
color = NS_DWC_Common::getColorFromString(*sStrokeColor);
pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
}
else
pSolid->Color.Color->SetRGB(0x00, 0x00, 0x00);
m_dValue = _wtof(strW.c_str()); if (bStroked)
} strRPr += pSolid->toXML();
std::wstring strStrokeW = std::to_wstring((int)Pt_To_Emu(m_dValue)); strRPr += L"</w14:textOutline>";
strRPr += L"<w14:textOutline w14:w=\"" + strStrokeW + L"\">";
smart_ptr<PPTX::Logic::SolidFill> pSolid = new PPTX::Logic::SolidFill(); for (size_t i = 0; i < wordArtString.size(); i++)
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
NSPresentationEditor::CColor color;
bool bStroked = true;
if (sStroked.is_init())
{
if (*sStroked == L"false" || *sStroked == L"f")
{ {
strRPr += L"<w14:noFill/>"; std::wstring sParaRun = L"<w:r><w:rPr>" + strRPr + L"</w:rPr>" + L"<w:t>" + wordArtString[i] + L"</w:t></w:r>";
bStroked = false;
sTxbxContent += L"<w:p><w:pPr>" + strPPr + L"<w:rPr>" + strRPr + L"</w:rPr></w:pPr>" + sParaRun + L"</w:p>";
} }
} sTxbxContent += L"</w:txbxContent>";
pShape->strTextBoxShape = sTxbxContent;
if (sStrokeColor.is_init())
{
color = NS_DWC_Common::getColorFromString(*sStrokeColor);
pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
} }
else strXmlPPTX = L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>";
pSolid->Color.Color->SetRGB(0x00, 0x00, 0x00);
if (bStroked)
strRPr += pSolid->toXML();
strRPr += L"</w14:textOutline>"; // у старого wordArt никаких отступов
pShape->oTextBoxBodyPr->lIns = 0;
pShape->oTextBoxBodyPr->tIns = 0;
pShape->oTextBoxBodyPr->rIns = 0;
pShape->oTextBoxBodyPr->bIns = 0;
for (size_t i = 0; i < wordArtString.size(); i++) if (!bTrimTextPath)
{ {
std::wstring sParaRun = L"<w:r><w:rPr>" + strRPr + L"</w:rPr>" + L"<w:t>" + wordArtString[i] + L"</w:t></w:r>"; // нужно для данного размера шейпа выставить отступы сверху и снизу
// top: Ascent - CapHeight
sTxbxContent += L"<w:p><w:pPr>" + strPPr + L"<w:rPr>" + strRPr + L"</w:rPr></w:pPr>" + sParaRun + L"</w:p>"; // bottom: Descent
} }
sTxbxContent += L"</w:txbxContent>";
pShape->strTextBoxShape = sTxbxContent;
} }
strXmlPPTX = L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>"; else
// у старого wordArt никаких отступов
pShape->oTextBoxBodyPr->lIns = 0;
pShape->oTextBoxBodyPr->tIns = 0;
pShape->oTextBoxBodyPr->rIns = 0;
pShape->oTextBoxBodyPr->bIns = 0;
if (!bTrimTextPath)
{
// нужно для данного размера шейпа выставить отступы сверху и снизу
// top: Ascent - CapHeight
// bottom: Descent
}
}
else
{
strXmlPPTX = oShapeElem.ConvertPPTShapeToPPTX(true);
}
XmlUtils::CXmlNode oNodeG;
oNodeG.FromXmlString(strXmlPPTX);
pShape->spPr.Geometry = oNodeG;
XmlUtils::CXmlNode oNodeTextBox;
std::wstring sTextboxStyle;
if (oNodeShape.GetNode(L"v:textbox", oNodeTextBox))
{
XmlUtils::CXmlNode oNodeContent;
if (oNodeTextBox.GetNode(L"w:txbxContent", oNodeContent))
{ {
pShape->oTextBoxShape = oNodeContent; strXmlPPTX = oShapeElem.ConvertPPTShapeToPPTX(true);
}
else if (oNodeTextBox.GetNode(L"div", oNodeContent))
{//The <div> tag was used to create an area in which the rotation would take place.
ConvertTextVML(oNodeTextBox, pShape);
} }
std::wstring sTextInset = oNodeTextBox.GetAttribute(L"inset"); XmlUtils::CXmlNode oNodeTextBox;
std::wstring sTextInsetMode = oNodeTextBox.GetAttribute(L"o:insetmode");
sTextboxStyle = oNodeTextBox.GetAttribute(L"style"); std::wstring sTextboxStyle;
if (oNodeShape.GetNode(L"v:textbox", oNodeTextBox))
if (L"" != sTextInset && ((L"" == sTextInsetMode) || (L"custom" == sTextInsetMode)))
{ {
PPTX::CStringTrimmer oTrimmer; XmlUtils::CXmlNode oNodeContent;
oTrimmer.m_Separator = (wchar_t)','; if (oNodeTextBox.GetNode(L"w:txbxContent", oNodeContent))
oTrimmer.LoadFromString(sTextInset); {
pShape->oTextBoxShape = oNodeContent;
double dTextMarginLeft = oTrimmer.GetParameter(0, 0.1); }
double dTextMarginTop = oTrimmer.GetParameter(1, 0.05); else if (oNodeTextBox.GetNode(L"div", oNodeContent))
double dTextMarginRight = oTrimmer.GetParameter(2, 0.1); {//The <div> tag was used to create an area in which the rotation would take place.
double dTextMarginBottom = oTrimmer.GetParameter(3, 0.05); ConvertTextVML(oNodeTextBox, pShape);
}
pShape->oTextBoxBodyPr->lIns = (int)(12700 * dTextMarginLeft);
pShape->oTextBoxBodyPr->tIns = (int)(12700 * dTextMarginTop);
pShape->oTextBoxBodyPr->rIns = (int)(12700 * dTextMarginRight);
pShape->oTextBoxBodyPr->bIns = (int)(12700 * dTextMarginBottom);
}
if (!sTextboxStyle.empty()) std::wstring sTextInset = oNodeTextBox.GetAttribute(L"inset");
{//todooo прописать все остальное std::wstring sTextInsetMode = oNodeTextBox.GetAttribute(L"o:insetmode");
PPTX::CCSS oCSSParser; sTextboxStyle = oNodeTextBox.GetAttribute(L"style");
oCSSParser.LoadFromString2(sTextboxStyle);
if (oCSSParser.m_mapSettings.size() > 0)
{
std::map<std::wstring, std::wstring>::iterator pPair = oCSSParser.m_mapSettings.find(L"layout-flow");
if (pPair != oCSSParser.m_mapSettings.end())
{
if (pPair->second == L"vertical")
{
pShape->oTextBoxBodyPr->vert = new PPTX::Limit::TextVerticalType();
pShape->oTextBoxBodyPr->vert->set(L"vert");
}
}
pPair = oCSSParser.m_mapSettings.find(L"mso-layout-flow-alt");
if (pPair != oCSSParser.m_mapSettings.end())
{
if (pPair->second == L"bottom-to-top")
{
if (pShape->oTextBoxBodyPr->vert.IsInit() == false)
pShape->oTextBoxBodyPr->vert = new PPTX::Limit::TextVerticalType();
pShape->oTextBoxBodyPr->vert->set(L"vert270");
}
}
if (pShape->oTextBoxBodyPr->vert.IsInit())
{
if (pShape->txBody.IsInit() == false)
pShape->txBody = new PPTX::Logic::TxBody();
if (!pShape->txBody->bodyPr.IsInit())
pShape->txBody->bodyPr = new PPTX::Logic::BodyPr();
pShape->txBody->bodyPr->vert = pShape->oTextBoxBodyPr->vert; if (L"" != sTextInset && ((L"" == sTextInsetMode) || (L"custom" == sTextInsetMode)))
} {
PPTX::CStringTrimmer oTrimmer;
oTrimmer.m_Separator = (wchar_t)',';
oTrimmer.LoadFromString(sTextInset);
double dTextMarginLeft = oTrimmer.GetParameter(0, 0.1);
double dTextMarginTop = oTrimmer.GetParameter(1, 0.05);
double dTextMarginRight = oTrimmer.GetParameter(2, 0.1);
double dTextMarginBottom = oTrimmer.GetParameter(3, 0.05);
pShape->oTextBoxBodyPr->lIns = (int)(12700 * dTextMarginLeft);
pShape->oTextBoxBodyPr->tIns = (int)(12700 * dTextMarginTop);
pShape->oTextBoxBodyPr->rIns = (int)(12700 * dTextMarginRight);
pShape->oTextBoxBodyPr->bIns = (int)(12700 * dTextMarginBottom);
}
if (!sTextboxStyle.empty())
{//todooo прописать все остальное
PPTX::CCSS oCSSParser;
oCSSParser.LoadFromString2(sTextboxStyle);
if (oCSSParser.m_mapSettings.size() > 0)
{
std::map<std::wstring, std::wstring>::iterator pPair = oCSSParser.m_mapSettings.find(L"layout-flow");
pPair = oCSSParser.m_mapSettings.find(L"mso-rotate"); if (pPair != oCSSParser.m_mapSettings.end())
if (pPair != oCSSParser.m_mapSettings.end())
{
try
{ {
pShape->oTextBoxBodyPr->rot = _wtoi(pPair->second.c_str()) * 60000; //для docx, xlsx if (pPair->second == L"vertical")
if (pShape->txBody.IsInit() == false) //для pptx {
pShape->txBody = new PPTX::Logic::TxBody(); pShape->oTextBoxBodyPr->vert = new PPTX::Limit::TextVerticalType();
pShape->oTextBoxBodyPr->vert->set(L"vert");
}
}
pPair = oCSSParser.m_mapSettings.find(L"mso-layout-flow-alt");
if (pPair != oCSSParser.m_mapSettings.end())
{
if (pPair->second == L"bottom-to-top")
{
if (pShape->oTextBoxBodyPr->vert.IsInit() == false)
pShape->oTextBoxBodyPr->vert = new PPTX::Limit::TextVerticalType();
pShape->oTextBoxBodyPr->vert->set(L"vert270");
}
}
if (pShape->oTextBoxBodyPr->vert.IsInit())
{
if (pShape->txBody.IsInit() == false)
pShape->txBody = new PPTX::Logic::TxBody();
if (!pShape->txBody->bodyPr.IsInit()) if (!pShape->txBody->bodyPr.IsInit())
pShape->txBody->bodyPr = new PPTX::Logic::BodyPr(); pShape->txBody->bodyPr = new PPTX::Logic::BodyPr();
pShape->txBody->bodyPr->rot = pShape->oTextBoxBodyPr->rot; pShape->txBody->bodyPr->vert = pShape->oTextBoxBodyPr->vert;
}catch(...){} }
}
} pPair = oCSSParser.m_mapSettings.find(L"mso-rotate");
} if (pPair != oCSSParser.m_mapSettings.end())
} {
try
{
pShape->oTextBoxBodyPr->rot = _wtoi(pPair->second.c_str()) * 60000; //для docx, xlsx
if (pShape->txBody.IsInit() == false) //для pptx
pShape->txBody = new PPTX::Logic::TxBody();
XmlUtils::CXmlNode oNodeTextData; if (!pShape->txBody->bodyPr.IsInit())
if (oNodeShape.GetNode(L"p:textdata", oNodeTextData)) pShape->txBody->bodyPr = new PPTX::Logic::BodyPr();
{
std::wstring sId = oNodeTextData.GetAttribute(L"id"); pShape->txBody->bodyPr->rot = pShape->oTextBoxBodyPr->rot;
}catch(...){}
}
if (sId.length() > 0 && m_pBinaryWriter->m_pCurrentContainer->IsInit()) }
}
}
XmlUtils::CXmlNode oNodeTextData;
if (oNodeShape.GetNode(L"p:textdata", oNodeTextData))
{ {
OOX::RId rId(sId); std::wstring sId = oNodeTextData.GetAttribute(L"id");
smart_ptr<PPTX::LegacyDiagramText> pExt = (*m_pBinaryWriter->m_pCurrentContainer)->GetLegacyDiagramText(rId);
if (pExt.IsInit()) if (sId.length() > 0 && m_pBinaryWriter->m_pCurrentContainer->IsInit())
{ {
if (pShape->txBody.IsInit() == false) OOX::RId rId(sId);
pShape->txBody = new PPTX::Logic::TxBody(); smart_ptr<PPTX::LegacyDiagramText> pExt = (*m_pBinaryWriter->m_pCurrentContainer)->GetLegacyDiagramText(rId);
if (pShape->txBody.IsInit())
{
PPTX::Logic::Paragraph p;
PPTX::Logic::Run *r = new PPTX::Logic::Run();
r->SetText(pExt->m_Text);
if (pExt->m_arrRPr.size() > 0) if (pExt.IsInit())
{
if (pShape->txBody.IsInit() == false)
pShape->txBody = new PPTX::Logic::TxBody();
if (pShape->txBody.IsInit())
{ {
r->rPr = pExt->m_arrRPr[0]; PPTX::Logic::Paragraph p;
} PPTX::Logic::Run *r = new PPTX::Logic::Run();
r->SetText(pExt->m_Text);
PPTX::Logic::RunElem elm;
p.RunElems.push_back(elm);
if (pExt->m_arrPPr.size() > 0) if (pExt->m_arrRPr.size() > 0)
{ {
p.pPr = pExt->m_arrPPr[0]; r->rPr = pExt->m_arrRPr[0];
} }
p.RunElems.back().InitRun(r);
PPTX::Logic::RunElem elm;
p.RunElems.push_back(elm);
pShape->txBody->Paragrs.push_back(p); if (pExt->m_arrPPr.size() > 0)
{
p.pPr = pExt->m_arrPPr[0];
}
p.RunElems.back().InitRun(r);
pShape->txBody->Paragrs.push_back(p);
}
} }
} }
} }
} if (bTextBox)
{
pShape->nvSpPr.cNvSpPr.txBox = true;
std::wstring strStyle = oNodeShape.GetAttribute(L"style"); }
if (L"" != strStyleAdvenced) }
strStyle += strStyleAdvenced; //-------------------------------------------------------------------------------------------------------------------
XmlUtils::CXmlNode oNodeG;
oNodeG.FromXmlString(strXmlPPTX);
pSpPr->Geometry = oNodeG;
std::wstring strStyle = oNodeShape.GetAttribute(L"style") + strStyleAdvenced;
PPTX::CCSS oCSSParser; PPTX::CCSS oCSSParser;
oCSSParser.LoadFromString2(strStyle); oCSSParser.LoadFromString2(strStyle);
...@@ -2657,9 +2693,8 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -2657,9 +2693,8 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
CSpTreeElemProps oProps; CSpTreeElemProps oProps;
oProps.IsTop = bIsTop; oProps.IsTop = bIsTop;
std::wstring strMainPos = GetDrawingMainProps(oNodeShape, oCSSParser, oProps); std::wstring strMainPos = GetDrawingMainProps(oNodeShape, oCSSParser, oProps);
/////////////////////////////////////////text options //-------------------------------------------------------------------------------------------------------------------
if (pShape && oCSSParser.m_mapSettings.size() > 0)
if (oCSSParser.m_mapSettings.size() > 0)
{ {
std::map<std::wstring, std::wstring>::iterator pPair = oCSSParser.m_mapSettings.find(L"v-text-anchor"); std::map<std::wstring, std::wstring>::iterator pPair = oCSSParser.m_mapSettings.find(L"v-text-anchor");
...@@ -2694,16 +2729,16 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -2694,16 +2729,16 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
if (m_oxfrm_override.IsInit()) if (m_oxfrm_override.IsInit())
{ {
pShape->spPr.xfrm = m_oxfrm_override; pSpPr->xfrm = m_oxfrm_override;
} }
else else
{ {
//oProps.X выставлять не надо, они учтены в pMainProps //oProps.X выставлять не надо, они учтены в pMainProps
pShape->spPr.xfrm = new PPTX::Logic::Xfrm(); pSpPr->xfrm = new PPTX::Logic::Xfrm();
pShape->spPr.xfrm->offX = 0; pSpPr->xfrm->offX = 0;
pShape->spPr.xfrm->offY = 0; pSpPr->xfrm->offY = 0;
pShape->spPr.xfrm->extX = oProps.Width; pSpPr->xfrm->extX = oProps.Width;
pShape->spPr.xfrm->extY = oProps.Height; pSpPr->xfrm->extY = oProps.Height;
} }
std::map<std::wstring, std::wstring>::iterator pPair; std::map<std::wstring, std::wstring>::iterator pPair;
...@@ -2712,20 +2747,20 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -2712,20 +2747,20 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
if (oCSSParser.m_mapSettings.end() != pPair) if (oCSSParser.m_mapSettings.end() != pPair)
{ {
if (pPair->second == L"x") if (pPair->second == L"x")
pShape->spPr.xfrm->flipH = true; pSpPr->xfrm->flipH = true;
else if (pPair->second == L"y") else if (pPair->second == L"y")
pShape->spPr.xfrm->flipV = true; pSpPr->xfrm->flipV = true;
else if ((pPair->second == L"xy") || (pPair->second == L"yx") || (pPair->second == L"x y") || (pPair->second == L"y x")) else if ((pPair->second == L"xy") || (pPair->second == L"yx") || (pPair->second == L"x y") || (pPair->second == L"y x"))
{ {
pShape->spPr.xfrm->flipH = true; pSpPr->xfrm->flipH = true;
pShape->spPr.xfrm->flipV = true; pSpPr->xfrm->flipV = true;
} }
} }
pPair = oCSSParser.m_mapSettings.find(L"rotation"); pPair = oCSSParser.m_mapSettings.find(L"rotation");
if (oCSSParser.m_mapSettings.end() != pPair) if (oCSSParser.m_mapSettings.end() != pPair)
{ {
pShape->spPr.xfrm->rot = NS_DWC_Common::getRotateAngle(pPair->second, pShape->spPr.xfrm->flipH, pShape->spPr.xfrm->flipV); pSpPr->xfrm->rot = NS_DWC_Common::getRotateAngle(pPair->second, pSpPr->xfrm->flipH, pSpPr->xfrm->flipV);
} }
} }
else else
...@@ -2736,11 +2771,11 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -2736,11 +2771,11 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
m_pBinaryWriter->m_lCxCurShape = 0; m_pBinaryWriter->m_lCxCurShape = 0;
m_pBinaryWriter->m_lCyCurShape = 0; m_pBinaryWriter->m_lCyCurShape = 0;
pShape->spPr.xfrm = new PPTX::Logic::Xfrm(); pSpPr->xfrm = new PPTX::Logic::Xfrm();
pShape->spPr.xfrm->offX = oProps.X; pSpPr->xfrm->offX = oProps.X;
pShape->spPr.xfrm->offY = oProps.Y; pSpPr->xfrm->offY = oProps.Y;
pShape->spPr.xfrm->extX = oProps.Width; pSpPr->xfrm->extX = oProps.Width;
pShape->spPr.xfrm->extY = oProps.Height; pSpPr->xfrm->extY = oProps.Height;
std::map<std::wstring, std::wstring>::iterator pPair; std::map<std::wstring, std::wstring>::iterator pPair;
...@@ -2748,40 +2783,42 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C ...@@ -2748,40 +2783,42 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
if (oCSSParser.m_mapSettings.end() != pPair) if (oCSSParser.m_mapSettings.end() != pPair)
{ {
if (pPair->second == L"x") if (pPair->second == L"x")
pShape->spPr.xfrm->flipH = true; pSpPr->xfrm->flipH = true;
else if (pPair->second == L"y") else if (pPair->second == L"y")
pShape->spPr.xfrm->flipV = true; pSpPr->xfrm->flipV = true;
else if ((pPair->second == L"xy") || (pPair->second == L"yx") || (pPair->second == L"x y") || (pPair->second == L"y x")) else if ((pPair->second == L"xy") || (pPair->second == L"yx") || (pPair->second == L"x y") || (pPair->second == L"y x"))
{ {
pShape->spPr.xfrm->flipH = true; pSpPr->xfrm->flipH = true;
pShape->spPr.xfrm->flipV = true; pSpPr->xfrm->flipV = true;
} }
} }
pPair = oCSSParser.m_mapSettings.find(L"rotation"); pPair = oCSSParser.m_mapSettings.find(L"rotation");
if (oCSSParser.m_mapSettings.end() != pPair) if (oCSSParser.m_mapSettings.end() != pPair)
{ {
pShape->spPr.xfrm->rot = NS_DWC_Common::getRotateAngle(pPair->second, pShape->spPr.xfrm->flipH, pShape->spPr.xfrm->flipV); pSpPr->xfrm->rot = NS_DWC_Common::getRotateAngle(pPair->second, pSpPr->xfrm->flipH, pSpPr->xfrm->flipV);
} }
} }
if (!bIsTop) if (!bIsTop)
{ {
pShape->nvSpPr.cNvPr.id = m_lNextId; pCNvPr->id = m_lNextId;
m_lNextId++; m_lNextId++;
} }
else else
{ {
pShape->nvSpPr.cNvPr.id = -1; pCNvPr->id = -1;
}
if (pShape)
{
pShape->signatureLine = pPPTShape->m_oSignatureLine;
} }
pShape->signatureLine = pPPTShape->m_oSignatureLine;
elem->InitElem(pShape);
if (!pPPTShape->IsWordArt()) if (!pPPTShape->IsWordArt())
CheckPenShape(elem, oNodeShape, pPPTShape->m_eType, pPPTShape); CheckPenShape(elem, oNodeShape, pPPTShape);
CheckBrushShape(elem, oNodeShape, pPPTShape->m_eType, pPPTShape); CheckBrushShape(elem, oNodeShape, pPPTShape);
} }
} }
...@@ -2904,7 +2941,8 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils: ...@@ -2904,7 +2941,8 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
pTree->grpSpPr.xfrm->chOffX = lCoordOriginX; pTree->grpSpPr.xfrm->chOffX = lCoordOriginX;
pTree->grpSpPr.xfrm->chOffY = lCoordOriginY; pTree->grpSpPr.xfrm->chOffY = lCoordOriginY;
pTree->grpSpPr.xfrm->chExtX = lCoordSizeW; pTree->grpSpPr.xfrm->chExtX = lCoordSizeW;
pTree->grpSpPr.xfrm->chExtY = lCoordSizeH; } pTree->grpSpPr.xfrm->chExtY = lCoordSizeH;
}
else else
{ {
pTree->grpSpPr.xfrm = new PPTX::Logic::Xfrm(); pTree->grpSpPr.xfrm = new PPTX::Logic::Xfrm();
...@@ -3484,8 +3522,16 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P ...@@ -3484,8 +3522,16 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
{ {
oWriter.WriteString(L"<wp:wrapNone/>"); oWriter.WriteString(L"<wp:wrapNone/>");
} }
bool bHidden = false;
pPair = oCssStyles.m_mapSettings.find(L"visibility");
if (oCssStyles.m_mapSettings.end() != pPair)
{
if (L"hidden" == pPair->second)
bHidden = true;
}
std::wstring strId = L"<wp:docPr id=\"" + std::to_wstring(m_lNextId) + L"\" name=\"\"/>"; std::wstring strId = L"<wp:docPr id=\"" + std::to_wstring(m_lNextId) + L"\" name=\"\"" + (bHidden ? L" hidden=\"true\"" : L"") + L"/>";
m_lNextId++; m_lNextId++;
oWriter.WriteString(strId); oWriter.WriteString(strId);
...@@ -3728,13 +3774,21 @@ void CDrawingConverter::SendMainProps(const std::wstring& strMainProps, std::wst ...@@ -3728,13 +3774,21 @@ void CDrawingConverter::SendMainProps(const std::wstring& strMainProps, std::wst
**pMainProps = strMainProps; **pMainProps = strMainProps;
} }
void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape) void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape)
{ {
if (!oElem)return; if (!oElem) return;
PPTX::Logic::Shape* pShape = dynamic_cast<PPTX::Logic::Shape*> (oElem->GetElem().operator ->());
PPTX::Logic::Pic* pPicture = dynamic_cast<PPTX::Logic::Pic*> (oElem->GetElem().operator ->());
PPTX::Logic::Shape* pShape = (PPTX::Logic::Shape*)dynamic_cast<PPTX::Logic::Shape*>(oElem->GetElem().operator ->()); PPTX::Logic::SpPr *pSpPr = NULL;
int R = 255; if (pShape) pSpPr = &pShape->spPr;
if (pPicture) pSpPr = &pPicture->spPr;
if (!pSpPr) return;
int R = 255;
int G = 255; int G = 255;
int B = 255; int B = 255;
...@@ -3749,8 +3803,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3749,8 +3803,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B); pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.Fill.Fill = pSolid; pSpPr->Fill.Fill = pSolid;
} }
else if (!pPPTShape->IsWordArt()) else if (!pPPTShape->IsWordArt())
{ {
...@@ -3760,8 +3814,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3760,8 +3814,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(R, G, B); pSolid->Color.Color->SetRGB(R, G, B);
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.Fill.Fill = pSolid; pSpPr->Fill.Fill = pSolid;
} }
nullable_string sFilled; nullable_string sFilled;
...@@ -3773,8 +3827,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3773,8 +3827,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill(); PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a"; pNoFill->m_namespace = L"a";
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::noFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pShape->spPr.Fill.Fill = pNoFill; pSpPr->Fill.Fill = pNoFill;
} }
} }
else if (!pPPTShape->m_bIsFilled) else if (!pPPTShape->m_bIsFilled)
...@@ -3782,8 +3836,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3782,8 +3836,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill(); PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a"; pNoFill->m_namespace = L"a";
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::noFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pShape->spPr.Fill.Fill = pNoFill; pSpPr->Fill.Fill = pNoFill;
} }
nullable_string sOpacity; nullable_string sOpacity;
...@@ -3792,13 +3846,13 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3792,13 +3846,13 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
{ {
BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity); BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
if (pShape->spPr.Fill.is<PPTX::Logic::SolidFill>()) if (pSpPr->Fill.is<PPTX::Logic::SolidFill>())
{ {
PPTX::Logic::ColorModifier oMod; PPTX::Logic::ColorModifier oMod;
oMod.name = L"alpha"; oMod.name = L"alpha";
int nA = (int)(lAlpha * 100000.0 / 255.0); int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA; oMod.val = nA;
pShape->spPr.Fill.as<PPTX::Logic::SolidFill>().Color.Color->Modifiers.push_back(oMod); pSpPr->Fill.as<PPTX::Logic::SolidFill>().Color.Color->Modifiers.push_back(oMod);
} }
} }
...@@ -3822,8 +3876,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3822,8 +3876,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B); pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.Fill.Fill = pSolid; pSpPr->Fill.Fill = pSolid;
if (!sFillColor.is_init()) if (!sFillColor.is_init())
sFillColor = sColor; sFillColor = sColor;
...@@ -3844,8 +3898,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3844,8 +3898,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
pBlipFill->tile = new PPTX::Logic::Tile(); pBlipFill->tile = new PPTX::Logic::Tile();
} }
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::blipFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pShape->spPr.Fill.Fill = pBlipFill; pSpPr->Fill.Fill = pBlipFill;
} }
nullable_string sRotate; nullable_string sRotate;
oNodeFill.ReadAttributeBase(L"rotate", sRotate); oNodeFill.ReadAttributeBase(L"rotate", sRotate);
...@@ -3926,23 +3980,23 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3926,23 +3980,23 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
if (*sRotate == L"r") pGradFill->lin->ang = 180 * 60000; if (*sRotate == L"r") pGradFill->lin->ang = 180 * 60000;
} }
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::gradFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::gradFill;
pShape->spPr.Fill.Fill = pGradFill; pSpPr->Fill.Fill = pGradFill;
} }
if (sOpacity.is_init()) if (sOpacity.is_init())
{ {
BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity); BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
if (pShape->spPr.Fill.is<PPTX::Logic::SolidFill>()) if (pSpPr->Fill.is<PPTX::Logic::SolidFill>())
{ {
PPTX::Logic::ColorModifier oMod; PPTX::Logic::ColorModifier oMod;
oMod.name = L"alpha"; oMod.name = L"alpha";
int nA = (int)(lAlpha * 100000.0 / 255.0); int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA; oMod.val = nA;
pShape->spPr.Fill.as<PPTX::Logic::SolidFill>().Color.Color->Modifiers.push_back(oMod); pSpPr->Fill.as<PPTX::Logic::SolidFill>().Color.Color->Modifiers.push_back(oMod);
} }
else if (pShape->spPr.Fill.is<PPTX::Logic::BlipFill>()) else if (pSpPr->Fill.is<PPTX::Logic::BlipFill>())
{ {
PPTX::Logic::AlphaModFix* pAlphaMod = new PPTX::Logic::AlphaModFix(); PPTX::Logic::AlphaModFix* pAlphaMod = new PPTX::Logic::AlphaModFix();
int nA = (int)(lAlpha * 100000.0 / 255.0); int nA = (int)(lAlpha * 100000.0 / 255.0);
...@@ -3951,7 +4005,7 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3951,7 +4005,7 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
PPTX::Logic::UniEffect oEff; PPTX::Logic::UniEffect oEff;
oEff.InitPointer(pAlphaMod); oEff.InitPointer(pAlphaMod);
pShape->spPr.Fill.as<PPTX::Logic::BlipFill>().blip->Effects.push_back(oEff); pSpPr->Fill.as<PPTX::Logic::BlipFill>().blip->Effects.push_back(oEff);
} }
} }
} }
...@@ -3989,9 +4043,6 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -3989,9 +4043,6 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
} }
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::blipFill;
pShape->spPr.Fill.Fill = pBlipFill;
std::wstring strCropT = oNodeFillID.GetAttribute(L"croptop"); std::wstring strCropT = oNodeFillID.GetAttribute(L"croptop");
std::wstring strCropL = oNodeFillID.GetAttribute(L"cropleft"); std::wstring strCropL = oNodeFillID.GetAttribute(L"cropleft");
std::wstring strCropR = oNodeFillID.GetAttribute(L"cropright"); std::wstring strCropR = oNodeFillID.GetAttribute(L"cropright");
...@@ -4027,20 +4078,32 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -4027,20 +4078,32 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
else else
pBlipFill->srcRect->b = str0; pBlipFill->srcRect->b = str0;
} }
if (pShape)
{
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
if (pPicture)
{
pSpPr->Fill.m_type = PPTX::Logic::UniFill::notInit;
pPicture->blipFill = *pBlipFill;
}
} }
} }
} }
// default params // default params
if (!pShape->spPr.Fill.Fill.is_init()) if (!pSpPr->Fill.Fill.is_init())
{ {
if (pPPTShape->IsWordArt()) if (pPPTShape->IsWordArt())
{ {
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill(); PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a"; pNoFill->m_namespace = L"a";
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::noFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pShape->spPr.Fill.Fill = pNoFill; pSpPr->Fill.Fill = pNoFill;
} }
else else
{ {
...@@ -4049,8 +4112,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -4049,8 +4112,8 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(0xFF, 0xFF, 0xFF); pSolid->Color.Color->SetRGB(0xFF, 0xFF, 0xFF);
pShape->spPr.Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.Fill.Fill = pSolid; pSpPr->Fill.Fill = pSolid;
if (sOpacity.is_init()) if (sOpacity.is_init())
{ {
...@@ -4064,11 +4127,19 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils ...@@ -4064,11 +4127,19 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
} }
} }
} }
void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape) void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape)
{ {
if (!oElem)return; if (!oElem)return;
PPTX::Logic::Shape* pShape = (PPTX::Logic::Shape*)dynamic_cast<PPTX::Logic::Shape*>(oElem->GetElem().operator ->()); PPTX::Logic::Shape* pShape = dynamic_cast<PPTX::Logic::Shape*> (oElem->GetElem().operator ->());
PPTX::Logic::Pic* pPicture = dynamic_cast<PPTX::Logic::Pic*> (oElem->GetElem().operator ->());
PPTX::Logic::SpPr *pSpPr = NULL;
if (pShape) pSpPr = &pShape->spPr;
if (pPicture) pSpPr = &pPicture->spPr;
if (!pSpPr) return;
// attributes // attributes
nullable_string sStrokeColor; nullable_string sStrokeColor;
...@@ -4077,24 +4148,24 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils:: ...@@ -4077,24 +4148,24 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::
{ {
NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sStrokeColor); NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sStrokeColor);
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill(); PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a"; pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B); pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
pShape->spPr.ln->Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.ln->Fill.Fill = pSolid; pSpPr->ln->Fill.Fill = pSolid;
} }
nullable_string sStrokeWeight; nullable_string sStrokeWeight;
oNode.ReadAttributeBase(L"strokeweight", sStrokeWeight); oNode.ReadAttributeBase(L"strokeweight", sStrokeWeight);
if (sStrokeWeight.is_init()) if (sStrokeWeight.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (sStrokeWeight->length() > 0 && sStrokeWeight->at(0) == wchar_t('.')) if (sStrokeWeight->length() > 0 && sStrokeWeight->at(0) == wchar_t('.'))
{ {
...@@ -4104,7 +4175,7 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils:: ...@@ -4104,7 +4175,7 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::
SimpleTypes::CPoint oPoint; SimpleTypes::CPoint oPoint;
int size = (int)(g_emu_koef * oPoint.FromString(*sStrokeWeight)); int size = (int)(g_emu_koef * oPoint.FromString(*sStrokeWeight));
pShape->spPr.ln->w = size; pSpPr->ln->w = size;
pPPTShape->m_bIsStroked = true; pPPTShape->m_bIsStroked = true;
} }
...@@ -4114,20 +4185,20 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils:: ...@@ -4114,20 +4185,20 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::
{ {
if (*sStroked == L"false" || *sStroked == L"f") if (*sStroked == L"false" || *sStroked == L"f")
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
pShape->spPr.ln->Fill.m_type = PPTX::Logic::UniFill::noFill; pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::noFill;
pShape->spPr.ln->Fill.Fill = new PPTX::Logic::NoFill(); pSpPr->ln->Fill.Fill = new PPTX::Logic::NoFill();
} }
} }
else if (!pPPTShape->m_bIsStroked) else if (!pPPTShape->m_bIsStroked)
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
pShape->spPr.ln->Fill.m_type = PPTX::Logic::UniFill::noFill; pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::noFill;
pShape->spPr.ln->Fill.Fill = new PPTX::Logic::NoFill(); pSpPr->ln->Fill.Fill = new PPTX::Logic::NoFill();
} }
XmlUtils::CXmlNode oNodeStroke = oNode.ReadNode(L"v:stroke"); XmlUtils::CXmlNode oNodeStroke = oNode.ReadNode(L"v:stroke");
...@@ -4139,229 +4210,181 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils:: ...@@ -4139,229 +4210,181 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::
{ {
NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sStrokeColor); NSPresentationEditor::CColor color = NS_DWC_Common::getColorFromString(*sStrokeColor);
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill(); PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a"; pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(color.R, color.G, color.B); pSolid->Color.Color->SetRGB(color.R, color.G, color.B);
pShape->spPr.ln->Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.ln->Fill.Fill = pSolid; pSpPr->ln->Fill.Fill = pSolid;
} }
nullable_string sStrokeDashStyle; nullable_string sStrokeDashStyle;
oNodeStroke.ReadAttributeBase(L"dashstyle", sStrokeDashStyle); oNodeStroke.ReadAttributeBase(L"dashstyle", sStrokeDashStyle);
if (sStrokeDashStyle.is_init()) if (sStrokeDashStyle.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
pShape->spPr.ln->prstDash = new PPTX::Logic::PrstDash(); pSpPr->ln->prstDash = new PPTX::Logic::PrstDash();
if (*sStrokeDashStyle == L"solid") if (*sStrokeDashStyle == L"solid") pSpPr->ln->prstDash->val = L"solid";
pShape->spPr.ln->prstDash->val = L"solid"; else if (*sStrokeDashStyle == L"shortdash") pSpPr->ln->prstDash->val = L"sysDash";
else if (*sStrokeDashStyle == L"shortdash") else if (*sStrokeDashStyle == L"shortdot") pSpPr->ln->prstDash->val = L"sysDot";
pShape->spPr.ln->prstDash->val = L"sysDash"; else if (*sStrokeDashStyle == L"shortdashdot") pSpPr->ln->prstDash->val = L"sysDashDot";
else if (*sStrokeDashStyle == L"shortdot") else if (*sStrokeDashStyle == L"shortdashdotdot")pSpPr->ln->prstDash->val = L"sysDashDotDot";
pShape->spPr.ln->prstDash->val = L"sysDot"; else if (*sStrokeDashStyle == L"dot") pSpPr->ln->prstDash->val = L"dot";
else if (*sStrokeDashStyle == L"shortdashdot") else if (*sStrokeDashStyle == L"dash") pSpPr->ln->prstDash->val = L"dash";
pShape->spPr.ln->prstDash->val = L"sysDashDot"; else if (*sStrokeDashStyle == L"longdash") pSpPr->ln->prstDash->val = L"lgDash";
else if (*sStrokeDashStyle == L"shortdashdotdot") else if (*sStrokeDashStyle == L"dashdot") pSpPr->ln->prstDash->val = L"dashDot";
pShape->spPr.ln->prstDash->val = L"sysDashDotDot"; else if (*sStrokeDashStyle == L"longdashdot") pSpPr->ln->prstDash->val = L"lgDashDot";
else if (*sStrokeDashStyle == L"dot") else if (*sStrokeDashStyle == L"longdashdotdot")pSpPr->ln->prstDash->val = L"lgDashDotDot";
pShape->spPr.ln->prstDash->val = L"dot"; else pSpPr->ln->prstDash->val = L"solid";
else if (*sStrokeDashStyle == L"dash")
pShape->spPr.ln->prstDash->val = L"dash";
else if (*sStrokeDashStyle == L"longdash")
pShape->spPr.ln->prstDash->val = L"lgDash";
else if (*sStrokeDashStyle == L"dashdot")
pShape->spPr.ln->prstDash->val = L"dashDot";
else if (*sStrokeDashStyle == L"longdashdot")
pShape->spPr.ln->prstDash->val = L"lgDashDot";
else if (*sStrokeDashStyle == L"longdashdotdot")
pShape->spPr.ln->prstDash->val = L"lgDashDotDot";
else
pShape->spPr.ln->prstDash->val = L"solid";
} }
nullable_string sEndArraw; nullable_string sEndArraw;
oNodeStroke.ReadAttributeBase(L"endarrow", sEndArraw); oNodeStroke.ReadAttributeBase(L"endarrow", sEndArraw);
if (sEndArraw.is_init()) if (sEndArraw.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
pShape->spPr.ln->tailEnd = new PPTX::Logic::LineEnd(); pSpPr->ln->tailEnd = new PPTX::Logic::LineEnd();
if (*sEndArraw == L"none") if (*sEndArraw == L"none") pSpPr->ln->tailEnd->type = L"none";
pShape->spPr.ln->tailEnd->type = L"none"; else if (*sEndArraw == L"block") pSpPr->ln->tailEnd->type = L"triangle";
else if (*sEndArraw == L"block") else if (*sEndArraw == L"classic") pSpPr->ln->tailEnd->type = L"stealth";
pShape->spPr.ln->tailEnd->type = L"triangle"; else if (*sEndArraw == L"diamond") pSpPr->ln->tailEnd->type = L"diamond";
else if (*sEndArraw == L"classic") else if (*sEndArraw == L"oval") pSpPr->ln->tailEnd->type = L"oval";
pShape->spPr.ln->tailEnd->type = L"stealth"; else if (*sEndArraw == L"open") pSpPr->ln->tailEnd->type = L"arrow";
else if (*sEndArraw == L"diamond") else pSpPr->ln->tailEnd->type = L"none";
pShape->spPr.ln->tailEnd->type = L"diamond";
else if (*sEndArraw == L"oval")
pShape->spPr.ln->tailEnd->type = L"oval";
else if (*sEndArraw == L"open")
pShape->spPr.ln->tailEnd->type = L"arrow";
else
pShape->spPr.ln->tailEnd->type = L"none";
} }
nullable_string sEndArrawLen; nullable_string sEndArrawLen;
oNodeStroke.ReadAttributeBase(L"endarrowlength", sEndArrawLen); oNodeStroke.ReadAttributeBase(L"endarrowlength", sEndArrawLen);
if (sEndArrawLen.is_init()) if (sEndArrawLen.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (!pShape->spPr.ln->tailEnd.is_init()) if (!pSpPr->ln->tailEnd.is_init())
pShape->spPr.ln->tailEnd = new PPTX::Logic::LineEnd(); pSpPr->ln->tailEnd = new PPTX::Logic::LineEnd();
if (*sEndArrawLen == L"short") if (*sEndArrawLen == L"short") pSpPr->ln->tailEnd->len = L"sm";
pShape->spPr.ln->tailEnd->len = L"sm"; else if (*sEndArrawLen == L"medium") pSpPr->ln->tailEnd->len = L"med";
else if (*sEndArrawLen == L"medium") else if (*sEndArrawLen == L"long") pSpPr->ln->tailEnd->len = L"lg";
pShape->spPr.ln->tailEnd->len = L"med"; else pSpPr->ln->tailEnd->len = L"med";
else if (*sEndArrawLen == L"long")
pShape->spPr.ln->tailEnd->len = L"lg";
else
pShape->spPr.ln->tailEnd->len = L"med";
} }
nullable_string sEndArrawWidth; nullable_string sEndArrawWidth;
oNodeStroke.ReadAttributeBase(L"endarrowwidth", sEndArrawWidth); oNodeStroke.ReadAttributeBase(L"endarrowwidth", sEndArrawWidth);
if (sEndArrawWidth.is_init()) if (sEndArrawWidth.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (!pShape->spPr.ln->tailEnd.is_init()) if (!pSpPr->ln->tailEnd.is_init())
pShape->spPr.ln->tailEnd = new PPTX::Logic::LineEnd(); pSpPr->ln->tailEnd = new PPTX::Logic::LineEnd();
if (*sEndArrawWidth == L"narrow") if (*sEndArrawWidth == L"narrow") pSpPr->ln->tailEnd->w = L"sm";
pShape->spPr.ln->tailEnd->w = L"sm"; else if (*sEndArrawWidth == L"medium") pSpPr->ln->tailEnd->w = L"med";
else if (*sEndArrawWidth == L"medium") else if (*sEndArrawWidth == L"wide") pSpPr->ln->tailEnd->w = L"lg";
pShape->spPr.ln->tailEnd->w = L"med"; else pSpPr->ln->tailEnd->w = L"med";
else if (*sEndArrawWidth == L"wide")
pShape->spPr.ln->tailEnd->w = L"lg";
else
pShape->spPr.ln->tailEnd->w = L"med";
} }
nullable_string sStartArraw; nullable_string sStartArraw;
oNodeStroke.ReadAttributeBase(L"startarrow", sStartArraw); oNodeStroke.ReadAttributeBase(L"startarrow", sStartArraw);
if (sStartArraw.is_init()) if (sStartArraw.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
pShape->spPr.ln->headEnd = new PPTX::Logic::LineEnd(); pSpPr->ln->headEnd = new PPTX::Logic::LineEnd();
if (*sStartArraw == L"none") if (*sStartArraw == L"none") pSpPr->ln->headEnd->type = L"none";
pShape->spPr.ln->headEnd->type = L"none"; else if (*sStartArraw == L"block") pSpPr->ln->headEnd->type = L"triangle";
else if (*sStartArraw == L"block") else if (*sStartArraw == L"classic")pSpPr->ln->headEnd->type = L"stealth";
pShape->spPr.ln->headEnd->type = L"triangle"; else if (*sStartArraw == L"diamond")pSpPr->ln->headEnd->type = L"diamond";
else if (*sStartArraw == L"classic") else if (*sStartArraw == L"oval") pSpPr->ln->headEnd->type = L"oval";
pShape->spPr.ln->headEnd->type = L"stealth"; else if (*sStartArraw == L"open") pSpPr->ln->headEnd->type = L"arrow";
else if (*sStartArraw == L"diamond") else pSpPr->ln->headEnd->type = L"none";
pShape->spPr.ln->headEnd->type = L"diamond";
else if (*sStartArraw == L"oval")
pShape->spPr.ln->headEnd->type = L"oval";
else if (*sStartArraw == L"open")
pShape->spPr.ln->headEnd->type = L"arrow";
else
pShape->spPr.ln->headEnd->type = L"none";
} }
nullable_string sStartArrawLen; nullable_string sStartArrawLen;
oNodeStroke.ReadAttributeBase(L"startarrowlength", sStartArrawLen); oNodeStroke.ReadAttributeBase(L"startarrowlength", sStartArrawLen);
if (sStartArrawLen.is_init()) if (sStartArrawLen.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (!pShape->spPr.ln->headEnd.is_init()) if (!pSpPr->ln->headEnd.is_init())
pShape->spPr.ln->headEnd = new PPTX::Logic::LineEnd(); pSpPr->ln->headEnd = new PPTX::Logic::LineEnd();
if (*sStartArrawLen == L"short") if (*sStartArrawLen == L"short") pSpPr->ln->headEnd->len = L"sm";
pShape->spPr.ln->headEnd->len = L"sm"; else if (*sStartArrawLen == L"medium") pSpPr->ln->headEnd->len = L"med";
else if (*sStartArrawLen == L"medium") else if (*sStartArrawLen == L"long") pSpPr->ln->headEnd->len = L"lg";
pShape->spPr.ln->headEnd->len = L"med"; else pSpPr->ln->headEnd->len = L"med";
else if (*sStartArrawLen == L"long")
pShape->spPr.ln->headEnd->len = L"lg";
else
pShape->spPr.ln->headEnd->len = L"med";
} }
nullable_string sStartArrawWidth; nullable_string sStartArrawWidth;
oNodeStroke.ReadAttributeBase(L"startarrowwidth", sStartArrawWidth); oNodeStroke.ReadAttributeBase(L"startarrowwidth", sStartArrawWidth);
if (sStartArrawWidth.is_init()) if (sStartArrawWidth.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (!pShape->spPr.ln->headEnd.is_init()) if (!pSpPr->ln->headEnd.is_init())
pShape->spPr.ln->headEnd = new PPTX::Logic::LineEnd(); pSpPr->ln->headEnd = new PPTX::Logic::LineEnd();
if (*sStartArrawWidth == L"narrow") if (*sStartArrawWidth == L"narrow") pSpPr->ln->headEnd->w = L"sm";
pShape->spPr.ln->headEnd->w = L"sm"; else if (*sStartArrawWidth == L"medium") pSpPr->ln->headEnd->w = L"med";
else if (*sStartArrawWidth == L"medium") else if (*sStartArrawWidth == L"wide") pSpPr->ln->headEnd->w = L"lg";
pShape->spPr.ln->headEnd->w = L"med"; else pSpPr->ln->headEnd->w = L"med";
else if (*sStartArrawWidth == L"wide")
pShape->spPr.ln->headEnd->w = L"lg";
else
pShape->spPr.ln->headEnd->w = L"med";
} }
nullable_string sEndCap; nullable_string sEndCap;
oNodeStroke.ReadAttributeBase(L"endcap", sEndCap); oNodeStroke.ReadAttributeBase(L"endcap", sEndCap);
if (sEndCap.is_init()) if (sEndCap.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (*sEndCap == L"flat") if (*sEndCap == L"flat") pSpPr->ln->cap = L"flat";
pShape->spPr.ln->cap = L"flat"; else if (*sEndCap == L"round") pSpPr->ln->cap = L"rnd";
else if (*sEndCap == L"round") else if (*sEndCap == L"square") pSpPr->ln->cap = L"sq";
pShape->spPr.ln->cap = L"rnd";
else if (*sEndCap == L"square")
pShape->spPr.ln->cap = L"sq";
} }
nullable_string sLineJoin; nullable_string sLineJoin;
oNodeStroke.ReadAttributeBase(L"joinstyle", sLineJoin); oNodeStroke.ReadAttributeBase(L"joinstyle", sLineJoin);
if (sLineJoin.is_init()) if (sLineJoin.is_init())
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (*sLineJoin == L"bevel") if (*sLineJoin == L"bevel") pSpPr->ln->Join.type = PPTX::Logic::JoinBevel;
pShape->spPr.ln->Join.type = PPTX::Logic::JoinBevel; else if (*sLineJoin == L"miter") pSpPr->ln->Join.type = PPTX::Logic::JoinMiter;
else if (*sLineJoin == L"miter") else if (*sLineJoin == L"round") pSpPr->ln->Join.type = PPTX::Logic::JoinRound;
pShape->spPr.ln->Join.type = PPTX::Logic::JoinMiter;
else if (*sLineJoin == L"round")
pShape->spPr.ln->Join.type = PPTX::Logic::JoinRound;
} }
} }
// default params // default params
if (eType != PPTShapes::sptCFrame) if (pShape) // not Picture
{ {
if (!pShape->spPr.ln.is_init()) if (!pSpPr->ln.is_init())
pShape->spPr.ln = new PPTX::Logic::Ln(); pSpPr->ln = new PPTX::Logic::Ln();
if (!pShape->spPr.ln->Fill.Fill.is_init()) if (!pSpPr->ln->Fill.Fill.is_init())
{ {
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill(); PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a"; pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr(); pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(0, 0, 0); pSolid->Color.Color->SetRGB(0, 0, 0);
pShape->spPr.ln->Fill.m_type = PPTX::Logic::UniFill::solidFill; pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pShape->spPr.ln->Fill.Fill = pSolid; pSpPr->ln->Fill.Fill = pSolid;
} }
} }
} }
......
...@@ -276,8 +276,8 @@ namespace NSBinPptxRW ...@@ -276,8 +276,8 @@ namespace NSBinPptxRW
std::wstring GetVMLShapeXml (CPPTShape* pPPTShape); std::wstring GetVMLShapeXml (CPPTShape* pPPTShape);
std::wstring GetVMLShapeXml (PPTX::Logic::SpTreeElem& oElem); std::wstring GetVMLShapeXml (PPTX::Logic::SpTreeElem& oElem);
void CheckBrushShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape); void CheckBrushShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
void CheckPenShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape); void CheckPenShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
void LoadCoordSize (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape); void LoadCoordSize (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);
void LoadCoordPos (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape); void LoadCoordPos (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);
......
...@@ -591,7 +591,7 @@ namespace NSPresentationEditor ...@@ -591,7 +591,7 @@ namespace NSPresentationEditor
#else #else
std::wstring ConvertPPTtoPPTX(CPPTShape* pPPTShape, const NSGuidesVML::CFormParam& pCoef, bool bIsNamespace = false) std::wstring ConvertPPTtoPPTX(CPPTShape* pPPTShape, const NSGuidesVML::CFormParam& pCoef, bool bIsNamespace = false)
{ {
if (pPPTShape->m_eType == PPTShapes::sptCRect || pPPTShape->m_eType == PPTShapes::sptCFrame) if (pPPTShape->m_eType == PPTShapes::sptCRect || pPPTShape->m_eType == PPTShapes::sptCFrame || pPPTShape->m_eType == PPTShapes::sptCTextBox)
{ {
if (bIsNamespace) if (bIsNamespace)
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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