Commit bf33aed8 authored by ElenaSubbotina's avatar ElenaSubbotina

fix convert oox group shape to vml group shape

parent 5869c7a0
...@@ -395,7 +395,6 @@ public: ...@@ -395,7 +395,6 @@ public:
SetPen (root); SetPen (root);
SetBrush (root); SetBrush (root);
//return m_pShape->LoadFromXML(xml);
return ((CPPTShape*)m_pShape)->LoadFromXML(root); return ((CPPTShape*)m_pShape)->LoadFromXML(root);
} }
#endif #endif
......
...@@ -532,13 +532,14 @@ namespace PPTX ...@@ -532,13 +532,14 @@ namespace PPTX
return (long) nvPicPr.cNvPr.id; return (long) nvPicPr.cNvPr.id;
} }
void Pic::toXmlWriterVML(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap) void Pic::toXmlWriterVML(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap, bool in_group)
{ {
smart_ptr<PPTX::Theme> oTheme = _oTheme.smart_dynamic_cast<PPTX::Theme>(); smart_ptr<PPTX::Theme> oTheme = _oTheme.smart_dynamic_cast<PPTX::Theme>();
smart_ptr<PPTX::Logic::ClrMap> oClrMap = oTheme.smart_dynamic_cast<PPTX::Logic::ClrMap>(); smart_ptr<PPTX::Logic::ClrMap> oClrMap = oTheme.smart_dynamic_cast<PPTX::Logic::ClrMap>();
bool bOle = oleObject.IsInit() && oleObject->isValid(); bool bOle = oleObject.IsInit() && oleObject->isValid();
std::wstring sOleNodeName; std::wstring sOleNodeName;
if (XMLWRITER_DOC_TYPE_XLSX != pWriter->m_lDocType) if (XMLWRITER_DOC_TYPE_XLSX != pWriter->m_lDocType)
{ {
if(bOle && oleObject->m_oDxaOrig.IsInit() && oleObject->m_oDyaOrig.IsInit()) if(bOle && oleObject->m_oDxaOrig.IsInit() && oleObject->m_oDyaOrig.IsInit())
...@@ -546,8 +547,8 @@ namespace PPTX ...@@ -546,8 +547,8 @@ namespace PPTX
sOleNodeName = L"w:object"; sOleNodeName = L"w:object";
pWriter->StartNode(sOleNodeName); pWriter->StartNode(sOleNodeName);
pWriter->StartAttributes(); pWriter->StartAttributes();
pWriter->WriteAttribute(_T("w:dxaOrig"), oleObject->m_oDxaOrig); pWriter->WriteAttribute(L"w:dxaOrig", oleObject->m_oDxaOrig);
pWriter->WriteAttribute(_T("w:dyaOrig"), oleObject->m_oDyaOrig); pWriter->WriteAttribute(L"w:dyaOrig", oleObject->m_oDyaOrig);
pWriter->EndAttributes(); pWriter->EndAttributes();
} }
else else
...@@ -559,38 +560,40 @@ namespace PPTX ...@@ -559,38 +560,40 @@ namespace PPTX
} }
} }
int dL = 0;
int dT = 0;
int dW = 0;
int dH = 0;
int nShapeId = pWriter->m_lObjectIdVML; int nShapeId = pWriter->m_lObjectIdVML;
std::wstring strId = L"_x0000_i" + std::to_wstring(nShapeId); std::wstring strId = L"_x0000_i" + std::to_wstring(nShapeId);
std::wstring strSpid = L"_x" + std::to_wstring(0xFFFF & (pWriter->m_lObjectIdVML >> 16)) + L"_s" + std::to_wstring(0xFFFF & pWriter->m_lObjectIdVML); std::wstring strSpid = L"_x" + std::to_wstring(0xFFFF & (pWriter->m_lObjectIdVML >> 16)) + L"_s" + std::to_wstring(0xFFFF & pWriter->m_lObjectIdVML);
std::wstring strObjectid = L"_152504" + std::to_wstring(pWriter->m_lObjectIdVML); std::wstring strObjectid = L"_152504" + std::to_wstring(pWriter->m_lObjectIdVML);
pWriter->m_lObjectIdVML++; pWriter->m_lObjectIdVML++;
int dL = 0, dT = 0, dW = 0, dH = 0;
if (spPr.xfrm.is_init())
{
if (spPr.xfrm->offX.is_init()) dL = *spPr.xfrm->offX;
if (spPr.xfrm->offY.is_init()) dT = *spPr.xfrm->offY;
if (spPr.xfrm->extX.is_init()) dW = *spPr.xfrm->extX;
if (spPr.xfrm->extY.is_init()) dH = *spPr.xfrm->extY;
}
NSBinPptxRW::CXmlWriter oStylesWriter; NSBinPptxRW::CXmlWriter oStylesWriter;
if(pWriter->m_strStyleMain.empty()) if(pWriter->m_strStyleMain.empty())
{ {
if (spPr.xfrm.is_init()) oStylesWriter.WriteAttributeCSS (L"position", L"absolute");
if (in_group)
{ {
if (spPr.xfrm->offX.is_init()) oStylesWriter.WriteAttributeCSS_int(L"left", dL / 100);
dL = (*spPr.xfrm->offX) / 12700.; oStylesWriter.WriteAttributeCSS_int(L"top", dT / 100);
if (spPr.xfrm->offY.is_init()) oStylesWriter.WriteAttributeCSS_int(L"width", dW / 100);
dT = (*spPr.xfrm->offY) / 12700.; oStylesWriter.WriteAttributeCSS_int(L"height", dH / 100);
if (spPr.xfrm->extX.is_init()) }
dW = (*spPr.xfrm->extX) / 12700.; else
if (spPr.xfrm->extY.is_init()) {
dH = (*spPr.xfrm->extY) / 12700.; oStylesWriter.WriteAttributeCSS_int_pt(L"left", dL / 12700);
oStylesWriter.WriteAttributeCSS_int_pt(L"top", dT / 12700);
oStylesWriter.WriteAttributeCSS_int_pt(L"width", dW / 12700);
oStylesWriter.WriteAttributeCSS_int_pt(L"height", dH / 12700);
} }
oStylesWriter.WriteAttributeCSS (_T("position"), _T("absolute"));
oStylesWriter.WriteAttributeCSS_int_pt (_T("left"), dL);
oStylesWriter.WriteAttributeCSS_int_pt (_T("top"), dT);
oStylesWriter.WriteAttributeCSS_int_pt (_T("width"), dW);
oStylesWriter.WriteAttributeCSS_int_pt (_T("height"), dH);
} }
if (spPr.xfrm.is_init()) if (spPr.xfrm.is_init())
...@@ -598,21 +601,21 @@ namespace PPTX ...@@ -598,21 +601,21 @@ namespace PPTX
if (spPr.xfrm->rot.is_init()) if (spPr.xfrm->rot.is_init())
{ {
int nRot = (int)((double)(*(spPr.xfrm->rot)) / 60000.0); int nRot = (int)((double)(*(spPr.xfrm->rot)) / 60000.0);
oStylesWriter.WriteAttributeCSS_int(_T("rotation"), nRot); oStylesWriter.WriteAttributeCSS_int(L"rotation", nRot);
} }
bool bIsFH = spPr.xfrm->flipH.get_value_or(false); bool bIsFH = spPr.xfrm->flipH.get_value_or(false);
bool bIsFV = spPr.xfrm->flipV.get_value_or(false); bool bIsFV = spPr.xfrm->flipV.get_value_or(false);
if (bIsFH && bIsFV) if (bIsFH && bIsFV)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("xy")); oStylesWriter.WriteAttributeCSS(L"flip", L"xy");
} }
else if (bIsFH) else if (bIsFH)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("x")); oStylesWriter.WriteAttributeCSS(L"flip", L"x");
} }
else if (bIsFV) else if (bIsFV)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("y")); oStylesWriter.WriteAttributeCSS(L"flip", L"y");
} }
} }
...@@ -631,32 +634,38 @@ namespace PPTX ...@@ -631,32 +634,38 @@ namespace PPTX
spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH); spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH);
pWriter->StartNode(_T("v:shape")); pWriter->StartNode(L"v:shape");
if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType) if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType)
{ {
pWriter->WriteAttribute(_T("id"), strSpid); pWriter->WriteAttribute(L"id", strSpid);
} }
else else
{ {
pWriter->WriteAttribute(_T("id"), strId); pWriter->WriteAttribute(L"id", strId);
pWriter->WriteAttribute(_T("o:spid"), strSpid); pWriter->WriteAttribute(L"o:spid", strSpid);
} }
pWriter->StartAttributes(); pWriter->StartAttributes();
if (oStylesWriter.GetSize() == 0) if (oStylesWriter.GetSize() == 0)
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain); pWriter->WriteAttribute(L"style", pWriter->m_strStyleMain);
} }
else else
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain + oStylesWriter.GetXmlString()); pWriter->WriteAttribute(L"style", pWriter->m_strStyleMain + oStylesWriter.GetXmlString());
} }
if(!bOle) if(!bOle)
{ {
pWriter->WriteAttribute(_T("coordsize"), (std::wstring)_T("100000,100000")); oStylesWriter.ClearNoAttack();
pWriter->WriteAttribute(_T("path"), strPath); oStylesWriter.m_oWriter.AddSize(30);
oStylesWriter.m_oWriter.AddIntNoCheck(dW / 100);
oStylesWriter.m_oWriter.AddCharNoCheck(WCHAR(','));
oStylesWriter.m_oWriter.AddIntNoCheck(dH / 100);
pWriter->WriteAttribute(L"coordsize", oStylesWriter.GetXmlString());
pWriter->WriteAttribute(L"path", strPath);
} }
if (!pWriter->m_strAttributesMain.empty()) if (!pWriter->m_strAttributesMain.empty())
...@@ -666,12 +675,12 @@ namespace PPTX ...@@ -666,12 +675,12 @@ namespace PPTX
} }
if(bOle) if(bOle)
{ {
pWriter->WriteAttribute(_T("filled"), (std::wstring)L"f"); pWriter->WriteAttribute(L"filled", L"f");
} }
std::wstring strNodeVal = _T(""); std::wstring strNodeVal;
if (!spPr.ln.is_init()) if (!spPr.ln.is_init())
{ {
pWriter->WriteAttribute(_T("stroked"), (std::wstring)_T("false")); pWriter->WriteAttribute(L"stroked", L"false");
} }
else else
{ {
...@@ -683,76 +692,76 @@ namespace PPTX ...@@ -683,76 +692,76 @@ namespace PPTX
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->StartNode(_T("v:path")); pWriter->StartNode(L"v:path");
pWriter->StartAttributes(); pWriter->StartAttributes();
pWriter->WriteAttribute(_T("textboxrect"), strTextRect); pWriter->WriteAttribute(L"textboxrect", strTextRect);
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->EndNode(_T("v:path")); pWriter->EndNode(L"v:path");
if (blipFill.blip.is_init() && blipFill.blip->embed.is_init()) if (blipFill.blip.is_init() && blipFill.blip->embed.is_init())
{ {
pWriter->StartNode(_T("v:imagedata")); pWriter->StartNode(L"v:imagedata");
pWriter->StartAttributes(); pWriter->StartAttributes();
if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType) if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType)
{ {
pWriter->WriteAttribute(_T("o:relid"), blipFill.blip->embed->ToString()); pWriter->WriteAttribute(L"o:relid", blipFill.blip->embed->ToString());
} }
else else
{ {
pWriter->WriteAttribute(_T("r:id"), blipFill.blip->embed->ToString()); pWriter->WriteAttribute(L"r:id", blipFill.blip->embed->ToString());
} }
pWriter->WriteAttribute(_T("o:title"), std::wstring(_T(""))); pWriter->WriteAttribute(L"o:title", L"");
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->EndNode(_T("v:imagedata")); pWriter->EndNode(L"v:imagedata");
} }
pWriter->EndNode(_T("v:shape")); pWriter->EndNode(L"v:shape");
} }
else else
{ {
pWriter->StartNode(_T("v:rect")); pWriter->StartNode(L"v:rect");
pWriter->StartAttributes(); pWriter->StartAttributes();
if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType) if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType)
{ {
pWriter->WriteAttribute(_T("id"), strSpid); pWriter->WriteAttribute(L"id", strSpid);
} }
else else
{ {
pWriter->WriteAttribute(_T("id"), strId); pWriter->WriteAttribute(L"id", strId);
pWriter->WriteAttribute(_T("o:spid"), strSpid); pWriter->WriteAttribute(L"o:spid", strSpid);
} }
if (oStylesWriter.GetSize() == 0) if (oStylesWriter.GetSize() == 0)
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain); pWriter->WriteAttribute(L"style", pWriter->m_strStyleMain);
} }
else else
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain + oStylesWriter.GetXmlString()); pWriter->WriteAttribute(L"style", pWriter->m_strStyleMain + oStylesWriter.GetXmlString());
} }
if(bOle) if(bOle)
{ {
pWriter->WriteAttribute(_T("filled"), L"f"); pWriter->WriteAttribute(L"filled", L"f");
pWriter->WriteAttribute(_T("stroked"), L"f"); pWriter->WriteAttribute(L"stroked", L"f");
} }
pWriter->EndAttributes(); pWriter->EndAttributes();
if (blipFill.blip.is_init() && blipFill.blip->embed.is_init()) if (blipFill.blip.is_init() && blipFill.blip->embed.is_init())
{ {
pWriter->StartNode(_T("v:imagedata")); pWriter->StartNode(L"v:imagedata");
pWriter->StartAttributes(); pWriter->StartAttributes();
pWriter->WriteAttribute(_T("r:id"), blipFill.blip->embed->ToString()); pWriter->WriteAttribute(L"r:id", blipFill.blip->embed->ToString());
pWriter->WriteAttribute(_T("o:title"), std::wstring(_T(""))); pWriter->WriteAttribute(L"o:title", L"");
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->EndNode(_T("v:imagedata")); pWriter->EndNode(L"v:imagedata");
} }
pWriter->EndNode(_T("v:rect")); pWriter->EndNode(L"v:rect");
} }
pWriter->m_strStyleMain = _T(""); pWriter->m_strStyleMain.clear();
if(bOle) if(bOle)
{ {
...@@ -783,12 +792,12 @@ namespace PPTX ...@@ -783,12 +792,12 @@ namespace PPTX
int imgW = node.GetAttributeInt(std::wstring(L"imgW"), 0); int imgW = node.GetAttributeInt(std::wstring(L"imgW"), 0);
if(imgW > 0) if(imgW > 0)
{ {
oleObject->m_oDxaOrig = Emu_To_Twips(imgW); oleObject->m_oDxaOrig = (int)Emu_To_Twips(imgW);
} }
int imgH = node.GetAttributeInt(std::wstring(L"imgH"), 0); int imgH = node.GetAttributeInt(std::wstring(L"imgH"), 0);
if(imgH > 0) if(imgH > 0)
{ {
oleObject->m_oDyaOrig = Emu_To_Twips(imgH); oleObject->m_oDyaOrig = (int)Emu_To_Twips(imgH);
} }
if(oleObject->m_oId.IsInit()) if(oleObject->m_oId.IsInit())
{ {
......
...@@ -399,7 +399,7 @@ namespace PPTX ...@@ -399,7 +399,7 @@ namespace PPTX
pReader->Seek(_end_rec); pReader->Seek(_end_rec);
} }
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap); void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, bool in_group = false);
void fromXMLOle(XmlUtils::CXmlNode& node); void fromXMLOle(XmlUtils::CXmlNode& node);
public: public:
......
...@@ -569,19 +569,33 @@ namespace PPTX ...@@ -569,19 +569,33 @@ namespace PPTX
} }
} }
void Shape::toXmlWriterVML(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& oClrMap) void Shape::toXmlWriterVML(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& oClrMap, bool in_group)
{ {
std::wstring strPath = _T(""); std::wstring strPath, strTextRect;
std::wstring strTextRect = _T(""); bool bOle = false;
OOX::Vml::SptType vmlPrst = OOX::Vml::sptNotPrimitive;
LONG lW = 43200, lH = 43200;
int dL = 0, dT = 0, dW = 0, dH = 0;
if (spPr.Geometry.is<PrstGeom>())
{
const PPTX::Logic::PrstGeom & lpGeom = spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> ooxPrst = SimpleTypes::CShapeType<>(lpGeom.prst.get());
vmlPrst = Spt2ShapeType( ooxPrst.GetValue());
}
LONG lW = 43200;
LONG lH = 43200;
if (spPr.xfrm.is_init()) if (spPr.xfrm.is_init())
{ {
if (spPr.xfrm->offX.is_init()) dL = *spPr.xfrm->offX;
if (spPr.xfrm->offY.is_init()) dT = *spPr.xfrm->offY;
if (spPr.xfrm->extX.is_init()) dW = *spPr.xfrm->extX;
if (spPr.xfrm->extY.is_init()) dH = *spPr.xfrm->extY;
lW = spPr.xfrm->extX.get_value_or(43200); lW = spPr.xfrm->extX.get_value_or(43200);
lH = spPr.xfrm->extY.get_value_or(43200); lH = spPr.xfrm->extY.get_value_or(43200);
} }
bool bOle = false;
spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH); spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH);
...@@ -597,8 +611,6 @@ namespace PPTX ...@@ -597,8 +611,6 @@ namespace PPTX
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, bOle); CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, bOle);
CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, bOle); CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, bOle);
if (!pWriter->m_strStyleMain.empty())
{
pWriter->StartNode(L"v:shape"); pWriter->StartNode(L"v:shape");
pWriter->StartAttributes(); pWriter->StartAttributes();
...@@ -606,161 +618,48 @@ namespace PPTX ...@@ -606,161 +618,48 @@ namespace PPTX
pWriter->WriteAttribute(L"id", strId); pWriter->WriteAttribute(L"id", strId);
pWriter->WriteAttribute(L"o:spid", strSpid); pWriter->WriteAttribute(L"o:spid", strSpid);
if (spPr.Geometry.is<PrstGeom>())
{
const PPTX::Logic::PrstGeom & lpGeom = spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> ooxPrst = SimpleTypes::CShapeType<>(lpGeom.prst.get());
OOX::Vml::SptType vmlPrst = Spt2ShapeType( ooxPrst.GetValue());
if (vmlPrst != OOX::Vml::sptNotPrimitive) if (vmlPrst != OOX::Vml::sptNotPrimitive)
pWriter->WriteAttribute(L"o:spt", (int)vmlPrst); pWriter->WriteAttribute(L"o:spt", (int)vmlPrst);
}
NSBinPptxRW::CXmlWriter oStylesWriter; NSBinPptxRW::CXmlWriter oStylesWriter;
if (spPr.xfrm.is_init()) if (pWriter->m_strStyleMain.empty())
{
if (spPr.xfrm->rot.is_init())
{
int nRot = (int)((double)(*(spPr.xfrm->rot)) / 60000.0);
oStylesWriter.WriteAttributeCSS_int(_T("rotation"), nRot);
}
bool bIsFH = spPr.xfrm->flipH.get_value_or(false);
bool bIsFV = spPr.xfrm->flipV.get_value_or(false);
if (bIsFH && bIsFV)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("xy")); oStylesWriter.WriteAttributeCSS(L"position", L"absolute");
} if (in_group)
else if (bIsFH)
{
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("x"));
}
else if (bIsFV)
{
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("y"));
}
}
if (txBody.is_init())
{
if (txBody->bodyPr.anchor.is_init())
{
std::wstring _strAnchor = txBody->bodyPr.anchor->get();
if (_strAnchor == _T("t"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("top"));
else if (_strAnchor == _T("b"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("bottom"));
else if (_strAnchor == _T("ctr"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("middle"));
}
}
else if (TextBoxBodyPr.is_init())
{
if (TextBoxBodyPr->anchor.is_init())
{
std::wstring _strAnchor = TextBoxBodyPr->anchor->get();
if (_strAnchor == _T("t"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("top"));
else if (_strAnchor == _T("b"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("bottom"));
else if (_strAnchor == _T("ctr"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("middle"));
}
}
if (oStylesWriter.GetSize() == 0)
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain); oStylesWriter.WriteAttributeCSS_int(L"left", dL / 100);
oStylesWriter.WriteAttributeCSS_int(L"top", dT / 100);
oStylesWriter.WriteAttributeCSS_int(L"width", dW / 100);
oStylesWriter.WriteAttributeCSS_int(L"height", dH / 100);
} }
else else
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain + oStylesWriter.GetXmlString()); oStylesWriter.WriteAttributeCSS_int_pt(L"left", dL / 12700);
} oStylesWriter.WriteAttributeCSS_int_pt(L"top", dT / 12700);
if(!bOle) oStylesWriter.WriteAttributeCSS_int_pt(L"width", dW / 12700);
{ oStylesWriter.WriteAttributeCSS_int_pt(L"height", dH / 12700);
pWriter->WriteAttribute(_T("coordsize"), (std::wstring)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath);
}
if (!pWriter->m_strAttributesMain.empty())
{
pWriter->WriteString(pWriter->m_strAttributesMain);
pWriter->m_strAttributesMain.clear();
}
pWriter->WriteString(strFillAttr);
pWriter->WriteString(strStrokeAttr);
pWriter->EndAttributes();
pWriter->StartNode(_T("v:path"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("textboxrect"), strTextRect);
pWriter->EndAttributes();
pWriter->EndNode(_T("v:path"));
pWriter->WriteString(strFillNode);
pWriter->WriteString(strStrokeNode);
pWriter->WriteString(pWriter->m_strNodes);
pWriter->m_strNodes = _T("");
if (TextBoxShape.is_init())
{
pWriter->StartNode(_T("v:textbox"));
pWriter->EndAttributes();
pWriter->WriteString(*TextBoxShape);
pWriter->EndNode(_T("v:textbox"));
}
pWriter->EndNode(_T("v:shape"));
pWriter->m_strStyleMain = _T("");
} }
else
{
int dL = 0;
int dT = 0;
int dW = 0;
int dH = 0;
NSBinPptxRW::CXmlWriter oStylesWriter;
if (spPr.xfrm.is_init())
{
if (spPr.xfrm->offX.is_init())
dL = (*spPr.xfrm->offX) / 12700.;
if (spPr.xfrm->offY.is_init())
dT = (*spPr.xfrm->offY) / 12700.;
if (spPr.xfrm->extX.is_init())
dW = (*spPr.xfrm->extX) / 12700.;
if (spPr.xfrm->extY.is_init())
dH = (*spPr.xfrm->extY / 12700.);
} }
oStylesWriter.WriteAttributeCSS(L"position", L"absolute");
oStylesWriter.WriteAttributeCSS_int_pt(L"left", dL);
oStylesWriter.WriteAttributeCSS_int_pt(L"top", dT);
oStylesWriter.WriteAttributeCSS_int_pt(L"width", dW);
oStylesWriter.WriteAttributeCSS_int_pt(L"height", dH);
if (spPr.xfrm.is_init()) if (spPr.xfrm.is_init())
{ {
if (spPr.xfrm->rot.is_init()) if (spPr.xfrm->rot.is_init())
{ {
int nRot = (int)((double)(*(spPr.xfrm->rot)) / 60000.0); int nRot = (int)((double)(*(spPr.xfrm->rot)) / 60000.0);
oStylesWriter.WriteAttributeCSS_int(_T("rotation"), nRot); oStylesWriter.WriteAttributeCSS_int(L"rotation", nRot);
} }
bool bIsFH = spPr.xfrm->flipH.get_value_or(false); bool bIsFH = spPr.xfrm->flipH.get_value_or(false);
bool bIsFV = spPr.xfrm->flipV.get_value_or(false); bool bIsFV = spPr.xfrm->flipV.get_value_or(false);
if (bIsFH && bIsFV) if (bIsFH && bIsFV)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("xy")); oStylesWriter.WriteAttributeCSS(L"flip", L"xy");
} }
else if (bIsFH) else if (bIsFH)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("x")); oStylesWriter.WriteAttributeCSS(L"flip", L"x");
} }
else if (bIsFV) else if (bIsFV)
{ {
oStylesWriter.WriteAttributeCSS(_T("flip"), _T("y")); oStylesWriter.WriteAttributeCSS(L"flip", L"y");
} }
} }
...@@ -769,12 +668,12 @@ namespace PPTX ...@@ -769,12 +668,12 @@ namespace PPTX
if (txBody->bodyPr.anchor.is_init()) if (txBody->bodyPr.anchor.is_init())
{ {
std::wstring _strAnchor = txBody->bodyPr.anchor->get(); std::wstring _strAnchor = txBody->bodyPr.anchor->get();
if (_strAnchor == _T("t")) if (_strAnchor == L"t")
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("top")); oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"top");
else if (_strAnchor == _T("b")) else if (_strAnchor == L"b")
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("bottom")); oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"bottom");
else if (_strAnchor == _T("ctr")) else if (_strAnchor == L"ctr")
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("middle")); oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"middle");
} }
} }
else if (TextBoxBodyPr.is_init()) else if (TextBoxBodyPr.is_init())
...@@ -782,38 +681,27 @@ namespace PPTX ...@@ -782,38 +681,27 @@ namespace PPTX
if (TextBoxBodyPr->anchor.is_init()) if (TextBoxBodyPr->anchor.is_init())
{ {
std::wstring _strAnchor = TextBoxBodyPr->anchor->get(); std::wstring _strAnchor = TextBoxBodyPr->anchor->get();
if (_strAnchor == _T("t")) if (_strAnchor == L"t")
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("top")); oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"top");
else if (_strAnchor == _T("b")) else if (_strAnchor == L"b")
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("bottom")); oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"bottom");
else if (_strAnchor == _T("ctr")) else if (_strAnchor == _T("ctr"))
oStylesWriter.WriteAttributeCSS(_T("v-text-anchor"), _T("middle")); oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"middle");
} }
} }
pWriter->StartNode(_T("v:shape")); pWriter->WriteAttribute(L"style", pWriter->m_strStyleMain + oStylesWriter.GetXmlString());
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("id"), strId);
pWriter->WriteAttribute(_T("o:spid"), strSpid);
if (spPr.Geometry.is<PrstGeom>())
{
const PPTX::Logic::PrstGeom & lpGeom = spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> ooxPrst = SimpleTypes::CShapeType<>(lpGeom.prst.get());
OOX::Vml::SptType vmlPrst = Spt2ShapeType( ooxPrst.GetValue());
if (vmlPrst != OOX::Vml::sptNotPrimitive)
pWriter->WriteAttribute(L"o:spt", (int)vmlPrst);
}
pWriter->WriteAttribute(_T("style"), oStylesWriter.GetXmlString());
if(!bOle) if(!bOle)
{ {
pWriter->WriteAttribute(_T("coordsize"), (std::wstring)_T("100000,100000")); oStylesWriter.ClearNoAttack();
pWriter->WriteAttribute(_T("path"), strPath); oStylesWriter.m_oWriter.AddSize(30);
oStylesWriter.m_oWriter.AddIntNoCheck(dW / 100);
oStylesWriter.m_oWriter.AddCharNoCheck(WCHAR(','));
oStylesWriter.m_oWriter.AddIntNoCheck(dH / 100);
pWriter->WriteAttribute(L"coordsize", oStylesWriter.GetXmlString());
pWriter->WriteAttribute(L"path", strPath);
} }
if (!pWriter->m_strAttributesMain.empty()) if (!pWriter->m_strAttributesMain.empty())
...@@ -827,33 +715,36 @@ namespace PPTX ...@@ -827,33 +715,36 @@ namespace PPTX
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->StartNode(_T("v:path")); pWriter->StartNode(L"v:path");
pWriter->StartAttributes(); pWriter->StartAttributes();
pWriter->WriteAttribute(_T("textboxrect"), strTextRect); pWriter->WriteAttribute(L"textboxrect", strTextRect);
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->EndNode(_T("v:path")); pWriter->EndNode(L"v:path");
pWriter->WriteString(strFillNode); pWriter->WriteString(strFillNode);
pWriter->WriteString(strStrokeNode); pWriter->WriteString(strStrokeNode);
pWriter->WriteString(pWriter->m_strNodes);
pWriter->m_strNodes.clear();
if (TextBoxShape.is_init()) if (TextBoxShape.is_init())
{ {
pWriter->StartNode(_T("v:textbox")); pWriter->StartNode(L"v:textbox");
pWriter->EndAttributes(); pWriter->EndAttributes();
pWriter->WriteString(*TextBoxShape); pWriter->WriteString(*TextBoxShape);
pWriter->EndNode(_T("v:textbox")); pWriter->EndNode(L"v:textbox");
} }
pWriter->EndNode(_T("v:shape")); pWriter->EndNode(L"v:shape");
}
pWriter->m_strStyleMain.clear();
} }
void Shape::toXmlWriterVMLBackground(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& oClrMap) void Shape::toXmlWriterVMLBackground(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& oClrMap)
{ {
std::wstring strFillAttr = _T(""); std::wstring strFillAttr, strFillNode;
std::wstring strFillNode = _T("");
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false); CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false);
pWriter->StartNode(_T("v:background")); pWriter->StartNode(L"v:background");
pWriter->StartAttributes(); pWriter->StartAttributes();
...@@ -871,7 +762,7 @@ namespace PPTX ...@@ -871,7 +762,7 @@ namespace PPTX
pWriter->WriteString(strFillNode); pWriter->WriteString(strFillNode);
pWriter->EndNode(_T("v:background")); pWriter->EndNode(L"v:background");
} }
} // namespace Logic } // namespace Logic
} // namespace PPTX } // namespace PPTX
...@@ -136,7 +136,7 @@ namespace PPTX ...@@ -136,7 +136,7 @@ namespace PPTX
pWriter->EndRecord(); pWriter->EndRecord();
} }
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap); void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, bool in_group = false);
void toXmlWriterVMLBackground(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& oClrMap); void toXmlWriterVMLBackground(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& oClrMap);
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
......
...@@ -41,7 +41,7 @@ namespace PPTX ...@@ -41,7 +41,7 @@ namespace PPTX
{ {
namespace Logic namespace Logic
{ {
void SpTree::toXmlWriterVML(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap) void SpTree::toXmlWriterVML(NSBinPptxRW::CXmlWriter *pWriter, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap, bool in_group)
{ {
smart_ptr<PPTX::Theme> oTheme = _oTheme.smart_dynamic_cast<PPTX::Theme>(); smart_ptr<PPTX::Theme> oTheme = _oTheme.smart_dynamic_cast<PPTX::Theme>();
smart_ptr<PPTX::Logic::ClrMap> oClrMap = oTheme.smart_dynamic_cast<PPTX::Logic::ClrMap>(); smart_ptr<PPTX::Logic::ClrMap> oClrMap = oTheme.smart_dynamic_cast<PPTX::Logic::ClrMap>();
...@@ -95,28 +95,31 @@ namespace PPTX ...@@ -95,28 +95,31 @@ namespace PPTX
} }
else else
{ {
int dL = 0; int dL = 0, dT = 0, dW = 0, dH = 0;
int dT = 0;
int dW = 0;
int dH = 0;
if (grpSpPr.xfrm.is_init()) if (grpSpPr.xfrm.is_init())
{ {
if (grpSpPr.xfrm->offX.is_init()) if (grpSpPr.xfrm->offX.is_init()) dL = *grpSpPr.xfrm->offX;
dL = (*grpSpPr.xfrm->offX) / 12700.; if (grpSpPr.xfrm->offY.is_init()) dT = *grpSpPr.xfrm->offY;
if (grpSpPr.xfrm->offY.is_init()) if (grpSpPr.xfrm->extX.is_init()) dW = *grpSpPr.xfrm->extX;
dT = (*grpSpPr.xfrm->offY) / 12700.; if (grpSpPr.xfrm->extY.is_init()) dH = *grpSpPr.xfrm->extY;
if (grpSpPr.xfrm->extX.is_init())
dW = (*grpSpPr.xfrm->extX) / 12700.;
if (grpSpPr.xfrm->extY.is_init())
dH = (*grpSpPr.xfrm->extY) / 12700.;
} }
oStylesWriter.ClearNoAttack(); oStylesWriter.ClearNoAttack();
oStylesWriter.WriteAttributeCSS(L"position", L"absolute"); oStylesWriter.WriteAttributeCSS(L"position", L"absolute");
oStylesWriter.WriteAttributeCSS_int_pt(L"left", dL); if (in_group)
oStylesWriter.WriteAttributeCSS_int_pt(L"top", dT); {
oStylesWriter.WriteAttributeCSS_int_pt(L"width", dW); oStylesWriter.WriteAttributeCSS_int(L"left", dL / 100.);
oStylesWriter.WriteAttributeCSS_int_pt(L"height", dH); oStylesWriter.WriteAttributeCSS_int(L"top", dT / 100.);
oStylesWriter.WriteAttributeCSS_int(L"width", dW / 100.);
oStylesWriter.WriteAttributeCSS_int(L"height", dH / 100.);
}
else
{
oStylesWriter.WriteAttributeCSS_int_pt(L"left", dL / 12700.);
oStylesWriter.WriteAttributeCSS_int_pt(L"top", dT / 12700.);
oStylesWriter.WriteAttributeCSS_int_pt(L"width", dW / 12700.);
oStylesWriter.WriteAttributeCSS_int_pt(L"height", dH / 12700.);
}
if (grpSpPr.xfrm.is_init()) if (grpSpPr.xfrm.is_init())
{ {
...@@ -150,33 +153,27 @@ namespace PPTX ...@@ -150,33 +153,27 @@ namespace PPTX
pWriter->m_strAttributesMain.clear(); pWriter->m_strAttributesMain.clear();
} }
int dL = 0; int dL = 0, dT = 0, dW = 0, dH = 0;
int dT = 0;
int dW = 0;
int dH = 0;
if (grpSpPr.xfrm.is_init()) if (grpSpPr.xfrm.is_init())
{ {
if (grpSpPr.xfrm->chOffX.is_init()) if (grpSpPr.xfrm->chOffX.is_init()) dL = *grpSpPr.xfrm->chOffX;
dL = (*grpSpPr.xfrm->chOffX) / 12700.; if (grpSpPr.xfrm->chOffY.is_init()) dT = *grpSpPr.xfrm->chOffY;
if (grpSpPr.xfrm->chOffY.is_init()) if (grpSpPr.xfrm->chExtX.is_init()) dW = *grpSpPr.xfrm->chExtX;
dT = (*grpSpPr.xfrm->chOffY) / 12700.; if (grpSpPr.xfrm->chExtY.is_init()) dH = *grpSpPr.xfrm->chExtY;
if (grpSpPr.xfrm->chExtX.is_init())
dW = (*grpSpPr.xfrm->chExtX) / 12700.;
if (grpSpPr.xfrm->chExtY.is_init())
dH = (*grpSpPr.xfrm->chExtY) / 12700.;
} }
oStylesWriter.ClearNoAttack(); oStylesWriter.ClearNoAttack();
oStylesWriter.m_oWriter.AddSize(30); oStylesWriter.m_oWriter.AddSize(30);
oStylesWriter.m_oWriter.AddIntNoCheck(dL); oStylesWriter.m_oWriter.AddIntNoCheck(dL / 100.);
oStylesWriter.m_oWriter.AddCharNoCheck(WCHAR(',')); oStylesWriter.m_oWriter.AddCharNoCheck(WCHAR(','));
oStylesWriter.m_oWriter.AddIntNoCheck(dT); oStylesWriter.m_oWriter.AddIntNoCheck(dT / 100.);
pWriter->WriteAttribute(_T("coordorigin"), oStylesWriter.GetXmlString()); pWriter->WriteAttribute(_T("coordorigin"), oStylesWriter.GetXmlString());
oStylesWriter.ClearNoAttack(); oStylesWriter.ClearNoAttack();
oStylesWriter.m_oWriter.AddSize(30); oStylesWriter.m_oWriter.AddSize(30);
oStylesWriter.m_oWriter.AddIntNoCheck(dW); oStylesWriter.m_oWriter.AddIntNoCheck(dW / 100.);
oStylesWriter.m_oWriter.AddCharNoCheck(WCHAR(',')); oStylesWriter.m_oWriter.AddCharNoCheck(WCHAR(','));
oStylesWriter.m_oWriter.AddIntNoCheck(dH); oStylesWriter.m_oWriter.AddIntNoCheck(dH / 100.);
pWriter->WriteAttribute(_T("coordsize"), oStylesWriter.GetXmlString()); pWriter->WriteAttribute(_T("coordsize"), oStylesWriter.GetXmlString());
pWriter->EndAttributes(); pWriter->EndAttributes();
...@@ -186,15 +183,15 @@ namespace PPTX ...@@ -186,15 +183,15 @@ namespace PPTX
{ {
if (SpTreeElems[i].is<PPTX::Logic::Shape>()) if (SpTreeElems[i].is<PPTX::Logic::Shape>())
{ {
SpTreeElems[i].as<PPTX::Logic::Shape>().toXmlWriterVML(pWriter, _oTheme, _oClrMap); SpTreeElems[i].as<PPTX::Logic::Shape>().toXmlWriterVML(pWriter, _oTheme, _oClrMap, true);
} }
else if (SpTreeElems[i].is<PPTX::Logic::Pic>()) else if (SpTreeElems[i].is<PPTX::Logic::Pic>())
{ {
SpTreeElems[i].as<PPTX::Logic::Pic>().toXmlWriterVML(pWriter, _oTheme, _oClrMap); SpTreeElems[i].as<PPTX::Logic::Pic>().toXmlWriterVML(pWriter, _oTheme, _oClrMap, true);
} }
else if (SpTreeElems[i].is<PPTX::Logic::SpTree>()) else if (SpTreeElems[i].is<PPTX::Logic::SpTree>())
{ {
SpTreeElems[i].as<PPTX::Logic::SpTree>().toXmlWriterVML(pWriter, _oTheme, _oClrMap); SpTreeElems[i].as<PPTX::Logic::SpTree>().toXmlWriterVML(pWriter, _oTheme, _oClrMap, true);
} }
} }
......
...@@ -121,7 +121,7 @@ namespace PPTX ...@@ -121,7 +121,7 @@ namespace PPTX
return XmlUtils::CreateNode(m_name, oValue); return XmlUtils::CreateNode(m_name, oValue);
} }
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap); void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, bool in_group = false);
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{ {
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "OOXDrawingGraphicReader.h" #include "OOXDrawingGraphicReader.h"
#include "../../../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h" #include "../../../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Theme.h"
bool OOXPictureGraphicReader::Parse( ReaderParameter oParam , RtfShape& oOutput) bool OOXPictureGraphicReader::Parse( ReaderParameter oParam , RtfShape& oOutput)
{ {
...@@ -89,6 +90,16 @@ OOX::Logic::CPicture * OOXDrawingGraphicReader::Parse( ReaderParameter oParam , ...@@ -89,6 +90,16 @@ OOX::Logic::CPicture * OOXDrawingGraphicReader::Parse( ReaderParameter oParam ,
{ {
NSBinPptxRW::CDrawingConverter drawingConverter; NSBinPptxRW::CDrawingConverter drawingConverter;
OOX::CTheme *pTheme = oParam.oDocx->GetTheme();
if (pTheme)
{
NSCommon::smart_ptr<PPTX::Theme> theme(new PPTX::Theme());
PPTX::FileMap map;
theme->read(pTheme->m_oReadPath, map);
(*drawingConverter.m_pTheme) = theme.smart_dynamic_cast<PPTX::WrapperFile>();
}
drawingConverter.SetRelsPath(oParam.oDocx->m_pDocument->m_oReadPath.GetPath()); drawingConverter.SetRelsPath(oParam.oDocx->m_pDocument->m_oReadPath.GetPath());
std::wstring sVmlXml = drawingConverter.ConvertObjectToVml(m_sXml); std::wstring sVmlXml = drawingConverter.ConvertObjectToVml(m_sXml);
......
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