Commit b3961994 authored by ElenaSubbotina's avatar ElenaSubbotina

Pptx ..

parent 927a8476
...@@ -1066,7 +1066,7 @@ namespace NSBinPptxRW ...@@ -1066,7 +1066,7 @@ namespace NSBinPptxRW
xfrm->chOffY = 0; xfrm->chOffY = 0;
xfrm->chExtX = 0; xfrm->chExtX = 0;
xfrm->chExtY = 0; xfrm->chExtY = 0;
m_oDefaultNote.cSld.spTree.m_name = _T("p:spTree");
m_oDefaultNote.cSld.spTree.grpSpPr.xfrm = xfrm; m_oDefaultNote.cSld.spTree.grpSpPr.xfrm = xfrm;
// shape comment !!! (TODO:) // shape comment !!! (TODO:)
......
...@@ -105,20 +105,25 @@ namespace PPTX ...@@ -105,20 +105,25 @@ namespace PPTX
Normalize(); Normalize();
} }
virtual std::wstring toXML() const
std::wstring toXML2(std::wstring node_name) const
{ {
XmlUtils::CAttribute oAttr; XmlUtils::CAttribute oAttr;
oAttr.Write(_T("id"), id); oAttr.Write(_T("id"), id);
oAttr.Write(_T("name"), name); oAttr.Write(_T("name"), XmlUtils::EncodeXmlString(name));
oAttr.Write(_T("descr"), descr); if (descr.IsInit()) oAttr.Write(_T("descr"), XmlUtils::EncodeXmlString(descr.get()));
oAttr.Write(_T("hidden"), hidden); oAttr.Write(_T("hidden"), hidden);
oAttr.Write(_T("title"), title); if (title.IsInit()) oAttr.Write(_T("title"), XmlUtils::EncodeXmlString(title.get()));
XmlUtils::CNodeValue oValue; XmlUtils::CNodeValue oValue;
oValue.WriteNullable(hlinkClick); oValue.WriteNullable(hlinkClick);
oValue.WriteNullable(hlinkHover); oValue.WriteNullable(hlinkHover);
return XmlUtils::CreateNode(m_namespace + L":cNvPr", oAttr, oValue); return XmlUtils::CreateNode(node_name.empty() ? (m_namespace + L":cNvPr") : node_name, oAttr, oValue);
}
virtual std::wstring toXML() const
{
return toXML2(L"");
} }
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
...@@ -133,9 +138,6 @@ namespace PPTX ...@@ -133,9 +138,6 @@ namespace PPTX
} }
void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const
{ {
//if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX && id == -1)
// return;
pWriter->StartNode(strNS + _T(":cNvPr")); pWriter->StartNode(strNS + _T(":cNvPr"));
int _id = id; int _id = id;
...@@ -153,11 +155,11 @@ namespace PPTX ...@@ -153,11 +155,11 @@ namespace PPTX
} }
pWriter->StartAttributes(); pWriter->StartAttributes();
pWriter->WriteAttribute (_T("id"), _id); pWriter->WriteAttribute (_T("id"), _id);
pWriter->WriteAttribute2(_T("name"), name); pWriter->WriteAttribute (_T("name"), XmlUtils::EncodeXmlString(name));
pWriter->WriteAttribute2(_T("descr"), descr); if (descr.IsInit()) pWriter->WriteAttribute (_T("descr"), XmlUtils::EncodeXmlString(descr.get()));
pWriter->WriteAttribute (_T("hidden"), hidden); pWriter->WriteAttribute (_T("hidden"), hidden);
pWriter->WriteAttribute (_T("title"), title); if (title.IsInit()) pWriter->WriteAttribute (_T("title"), XmlUtils::EncodeXmlString(title.get()));
pWriter->EndAttributes(); pWriter->EndAttributes();
......
...@@ -46,7 +46,10 @@ namespace PPTX ...@@ -46,7 +46,10 @@ namespace PPTX
{ {
public: public:
WritingElement_AdditionConstructors(CSld) WritingElement_AdditionConstructors(CSld)
PPTX_LOGIC_BASE2(CSld)
CSld() : spTree(L"p")
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{ {
...@@ -149,7 +152,6 @@ namespace PPTX ...@@ -149,7 +152,6 @@ namespace PPTX
} }
case 1: case 1:
{ {
spTree.m_name = _T("p:spTree");
spTree.fromPPTY(pReader); spTree.fromPPTY(pReader);
break; break;
} }
...@@ -164,7 +166,6 @@ namespace PPTX ...@@ -164,7 +166,6 @@ namespace PPTX
pReader->Seek(_end_rec); pReader->Seek(_end_rec);
} }
public:
nullable_string attrName; nullable_string attrName;
nullable<Bg> bg; nullable<Bg> bg;
......
...@@ -144,7 +144,7 @@ namespace PPTX ...@@ -144,7 +144,7 @@ namespace PPTX
public: public:
std::wstring GetODString()const std::wstring GetODString()const
{ {
return _T("<cxn ang=\"") + ang + _T("\"><pos x=\"") + x + _T("\" y=\"") + y + _T("\" /></cxn>"); return _T("<cxn ang=\"") + ang + _T("\"><pos x=\"") + x + _T("\" y=\"") + y + _T("\"/></cxn>");
} }
}; };
} // namespace Logic } // namespace Logic
......
...@@ -46,7 +46,11 @@ namespace PPTX ...@@ -46,7 +46,11 @@ namespace PPTX
class DefaultShapeDefinition : public WrapperWritingElement class DefaultShapeDefinition : public WrapperWritingElement
{ {
public: public:
PPTX_LOGIC_BASE(DefaultShapeDefinition) WritingElement_AdditionConstructors(DefaultShapeDefinition)
DefaultShapeDefinition()
{
}
DefaultShapeDefinition& operator=(const DefaultShapeDefinition& oSrc) DefaultShapeDefinition& operator=(const DefaultShapeDefinition& oSrc)
{ {
...@@ -61,11 +65,32 @@ namespace PPTX ...@@ -61,11 +65,32 @@ namespace PPTX
return *this; return *this;
} }
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = XmlUtils::GetNameNoNS(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("spPr") == strName)
spPr.fromXML(oReader);
else if (_T("bodyPr") == strName)
bodyPr = oReader;
else if (_T("lstStyle") == strName)
lstStyle.fromXML(oReader);
else if (_T("style") == strName)
style = oReader;
}
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
m_name = XmlUtils::GetNameNoNS(node.GetName()); m_name = XmlUtils::GetNameNoNS(node.GetName());
XmlUtils::CXmlNodes oNodes; XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes)) if (node.GetNodes(_T("*"), oNodes))
......
...@@ -35,16 +35,35 @@ ...@@ -35,16 +35,35 @@
#include "./../WrapperWritingElement.h" #include "./../WrapperWritingElement.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/RId.h" #include "../../../Common/DocxFormat/Source/DocxFormat/RId.h"
/*
<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">
<p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId2">
<p14:trim st="93333.0816" end="96583.4816"/>
</p14:media>
</p:ext>
*/
//<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">
//<p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId2">
//<p14:trim st="93333.0816" end="96583.4816"/>
//</p14:media>
//</p:ext>
//<ext uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
// <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
// <x14:sparklineGroup displayEmptyCellsAs="gap">
// <x14:colorSeries theme="5" tint="-0.499984740745262"/>
// <x14:colorNegative theme="6"/>
// <x14:colorAxis rgb="FF000000"/>
// <x14:colorMarkers theme="5" tint="-0.499984740745262"/>
// <x14:colorFirst theme="5" tint="0.39997558519241921"/>
// <x14:colorLast theme="5" tint="0.39997558519241921"/>
// <x14:colorHigh theme="5"/>
// <x14:colorLow theme="5"/>
// <x14:sparklines>
// <x14:sparkline>
// <xm:f>Лист1!D10:D12</xm:f>
// <xm:sqref>H12</xm:sqref>
// </x14:sparkline>
// </x14:sparklines>
// </x14:sparklineGroup>
// </x14:sparklineGroups>
//</ext>
namespace PPTX namespace PPTX
{ {
namespace Logic namespace Logic
......
...@@ -46,7 +46,9 @@ namespace PPTX ...@@ -46,7 +46,9 @@ namespace PPTX
{ {
public: public:
WritingElement_AdditionConstructors(Geometry) WritingElement_AdditionConstructors(Geometry)
PPTX_LOGIC_BASE2(Geometry) Geometry()
{
}
virtual OOX::EElementType getType() const virtual OOX::EElementType getType() const
{ {
......
...@@ -294,7 +294,23 @@ namespace PPTX ...@@ -294,7 +294,23 @@ namespace PPTX
FillParentPointersForChilds(); FillParentPointersForChilds();
} }
void GraphicFrame::toXmlWriter2(NSBinPptxRW::CXmlWriter* pWriter) const
{
nvGraphicFramePr.toXmlWriter(pWriter);
if (table.is_init())
{
pWriter->WriteString (L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/table\">");
table->toXmlWriter (pWriter);
pWriter->WriteString (L"</a:graphicData></a:graphic>");
}
else if (chartRec.is_init())
{
pWriter->WriteString(L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\">");
chartRec->toXmlWriter(pWriter);
pWriter->WriteString(L"</a:graphicData></a:graphic>");
}
}
void GraphicFrame::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const void GraphicFrame::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{ {
std::wstring namespace_ = m_namespace; std::wstring namespace_ = m_namespace;
...@@ -305,27 +321,13 @@ namespace PPTX ...@@ -305,27 +321,13 @@ namespace PPTX
pWriter->StartNode(namespace_ + L":graphicFrame"); pWriter->StartNode(namespace_ + L":graphicFrame");
pWriter->EndAttributes(); pWriter->EndAttributes();
nvGraphicFramePr.toXmlWriter(pWriter);
if (xfrm.IsInit()) if (xfrm.IsInit())
{ {
xfrm->m_ns = namespace_; xfrm->m_ns = namespace_;
xfrm->toXmlWriter(pWriter); xfrm->toXmlWriter(pWriter);
} }
toXmlWriter2(pWriter);
if (table.is_init())
{
pWriter->WriteString (L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/table\">");
table->toXmlWriter (pWriter);
pWriter->WriteString (L"</a:graphicData></a:graphic>");
}
else if (chartRec.is_init())
{
pWriter->WriteString(L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\">");
chartRec->toXmlWriter(pWriter);
pWriter->WriteString(L"</a:graphicData></a:graphic>");
}
pWriter->EndNode(namespace_ + L":graphicFrame"); pWriter->EndNode(namespace_ + L":graphicFrame");
} }
...@@ -527,24 +529,13 @@ namespace PPTX ...@@ -527,24 +529,13 @@ namespace PPTX
parentAs<Logic::SpTree>().NormalizeRect(pRect); parentAs<Logic::SpTree>().NormalizeRect(pRect);
} }
std::wstring GraphicFrame::toXML() const
std::wstring GraphicFrame::toXML2() const
{ {
std::wstring sXml; std::wstring sXml;
sXml += L"<" + m_namespace + L":graphicFrame macro=\"\">";
sXml += nvGraphicFramePr.toXML(); sXml += nvGraphicFramePr.toXML();
sXml += L"<" + m_namespace + L":xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/>"; if (table.IsInit())
sXml += L"</" + m_namespace + L":xfrm>";
if (xfrm.IsInit())
{
xfrm->m_ns = m_namespace;
sXml += xfrm->toXML();
}
if (table.IsInit())
{ {
sXml += L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/table\">"; sXml += L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/table\">";
sXml += table->toXML(); sXml += table->toXML();
...@@ -556,6 +547,26 @@ namespace PPTX ...@@ -556,6 +547,26 @@ namespace PPTX
sXml += chartRec->toXML(); sXml += chartRec->toXML();
sXml += L"</a:graphicData></a:graphic>"; sXml += L"</a:graphicData></a:graphic>";
} }
return sXml;
}
std::wstring GraphicFrame::toXML() const
{
std::wstring sXml;
sXml += L"<" + m_namespace + L":graphicFrame macro=\"\">";
if (xfrm.IsInit())
{
xfrm->m_ns = m_namespace;
sXml += xfrm->toXML();
}
else
{
sXml += L"<" + m_namespace + L":xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/>";
sXml += L"</" + m_namespace + L":xfrm>";
}
sXml += toXML2();
sXml += L"</" + m_namespace + L":graphicFrame>"; sXml += L"</" + m_namespace + L":graphicFrame>";
sXml += L"<" + m_namespace + L":clientData/>"; sXml += L"<" + m_namespace + L":clientData/>";
...@@ -578,19 +589,6 @@ namespace PPTX ...@@ -578,19 +589,6 @@ namespace PPTX
if (pic.is_init()) if (pic.is_init())
pic->SetParentPointer(this); pic->SetParentPointer(this);
} }
//OOX::CPath GraphicFrame::GetPathBySpid()const
//{
// OOX::CPath filename;
// if(parentFileIs<PPTX::Slide>())
// filename = parentFileAs<PPTX::Slide>().GetPathBySpid(spid.get_value_or(_T("")));
// else if(parentFileIs<PPTX::SlideLayout>())
// filename = parentFileAs<PPTX::SlideLayout>().GetPathBySpid(spid.get_value_or(_T("")));
// else if(parentFileIs<PPTX::SlideMaster>())
// filename = parentFileAs<PPTX::SlideMaster>().GetPathBySpid(spid.get_value_or(_T("")));
// return filename;
//}
std::wstring GraphicFrame::GetVmlXmlBySpid(std::wstring & rels)const std::wstring GraphicFrame::GetVmlXmlBySpid(std::wstring & rels)const
{ {
std::wstring xml; std::wstring xml;
......
...@@ -70,9 +70,12 @@ namespace PPTX ...@@ -70,9 +70,12 @@ namespace PPTX
void ReadAttributes3(XmlUtils::CXmlLiteReader& oReader); void ReadAttributes3(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const; virtual std::wstring toXML() const;
virtual void GetRect(Aggplus::RECT& pRect)const; std::wstring toXML2() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
void toXmlWriter2(NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void GetRect(Aggplus::RECT& pRect)const;
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
......
...@@ -50,8 +50,9 @@ namespace PPTX ...@@ -50,8 +50,9 @@ namespace PPTX
public: public:
WritingElement_AdditionConstructors(GrpSpPr) WritingElement_AdditionConstructors(GrpSpPr)
GrpSpPr() GrpSpPr(std::wstring ns = L"p")
{ {
m_namespace = ns;
} }
GrpSpPr& operator=(const GrpSpPr& oSrc) GrpSpPr& operator=(const GrpSpPr& oSrc)
{ {
...@@ -117,17 +118,16 @@ namespace PPTX ...@@ -117,17 +118,16 @@ namespace PPTX
oValue.Write(EffectList); oValue.Write(EffectList);
oValue.WriteNullable(scene3d); oValue.WriteNullable(scene3d);
return XmlUtils::CreateNode(_T("p:grpSpPr"), oAttr, oValue); return XmlUtils::CreateNode(m_namespace + L":grpSpPr", oAttr, oValue);
} }
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{ {
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) std::wstring namespace_ = m_namespace;
pWriter->StartNode(_T("wpg:grpSpPr")); if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wpg";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
pWriter->StartNode(_T("xdr:grpSpPr"));
else pWriter->StartNode(namespace_ + L":grpSpPr");
pWriter->StartNode(_T("p:grpSpPr"));
pWriter->StartAttributes(); pWriter->StartAttributes();
pWriter->WriteAttribute(_T("bwMode"), bwMode); pWriter->WriteAttribute(_T("bwMode"), bwMode);
...@@ -138,12 +138,7 @@ namespace PPTX ...@@ -138,12 +138,7 @@ namespace PPTX
EffectList.toXmlWriter(pWriter); EffectList.toXmlWriter(pWriter);
pWriter->Write(scene3d); pWriter->Write(scene3d);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) pWriter->EndNode(namespace_ + L":grpSpPr");
pWriter->EndNode(_T("wpg:grpSpPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:grpSpPr"));
else
pWriter->EndNode(_T("p:grpSpPr"));
} }
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
...@@ -215,8 +210,9 @@ namespace PPTX ...@@ -215,8 +210,9 @@ namespace PPTX
pReader->Seek(_end_rec); pReader->Seek(_end_rec);
} }
std::wstring m_namespace;
public:
nullable<Xfrm> xfrm; nullable<Xfrm> xfrm;
UniFill Fill; UniFill Fill;
EffectProperties EffectList; EffectProperties EffectList;
...@@ -226,12 +222,11 @@ namespace PPTX ...@@ -226,12 +222,11 @@ namespace PPTX
protected: protected:
virtual void FillParentPointersForChilds() virtual void FillParentPointersForChilds()
{ {
if(xfrm.IsInit())
xfrm->SetParentPointer(this);
Fill.SetParentPointer(this); Fill.SetParentPointer(this);
EffectList.SetParentPointer(this); EffectList.SetParentPointer(this);
if(scene3d.IsInit())
scene3d->SetParentPointer(this); if(xfrm.IsInit()) xfrm->SetParentPointer(this);
if(scene3d.IsInit()) scene3d->SetParentPointer(this);
} }
}; };
} // namespace Logic } // namespace Logic
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "./../Limit/PenAlign.h" #include "./../Limit/PenAlign.h"
#include "./../Limit/LineCap.h" #include "./../Limit/LineCap.h"
#include "./../Limit/CompoundLine.h" #include "./../Limit/CompoundLine.h"
#include "EffectProperties.h"
#include "UniFill.h" #include "UniFill.h"
#include "PrstDash.h" #include "PrstDash.h"
#include "LineEnd.h" #include "LineEnd.h"
...@@ -97,8 +99,8 @@ namespace PPTX ...@@ -97,8 +99,8 @@ namespace PPTX
prstDash = oReader; prstDash = oReader;
//m_eDashType = OOX::Drawing::linedashtypePreset; //m_eDashType = OOX::Drawing::linedashtypePreset;
} }
//else if ( _T("a:extLst") == sName ) else if ( _T("a:extLst") == sName )
// extLst = oReader; Effects.fromXML(oReader);
} }
FillParentPointersForChilds(); FillParentPointersForChilds();
} }
...@@ -344,15 +346,15 @@ namespace PPTX ...@@ -344,15 +346,15 @@ namespace PPTX
public: public:
// OOX::Drawing::ELineDashType m_eDashType; // Тип штриха // OOX::Drawing::ELineDashType m_eDashType; // Тип штриха
EffectProperties Effects;
UniFill Fill; UniFill Fill;
nullable<PrstDash> prstDash; nullable<PrstDash> prstDash;
//custDash (Custom Dash) ยง20.1.8.21 //custDash (Custom Dash) ยง20.1.8.21
LineJoin Join; LineJoin Join;
nullable<LineEnd> headEnd; nullable<LineEnd> headEnd;
nullable<LineEnd> tailEnd; nullable<LineEnd> tailEnd;
// nullable<ExtLst> extLst;
nullable_limit<Limit::PenAlign> algn; nullable_limit<Limit::PenAlign> algn;
nullable_limit<Limit::LineCap> cap; nullable_limit<Limit::LineCap> cap;
nullable_limit<Limit::CompoundLine> cmpd; nullable_limit<Limit::CompoundLine> cmpd;
......
...@@ -48,9 +48,9 @@ namespace PPTX ...@@ -48,9 +48,9 @@ namespace PPTX
public: public:
WritingElement_AdditionConstructors(NvGrpSpPr) WritingElement_AdditionConstructors(NvGrpSpPr)
NvGrpSpPr() NvGrpSpPr(std::wstring ns = L"p")
{ {
m_namespace = L"p"; m_namespace = ns;
} }
NvGrpSpPr& operator=(const NvGrpSpPr& oSrc) NvGrpSpPr& operator=(const NvGrpSpPr& oSrc)
...@@ -76,7 +76,9 @@ namespace PPTX ...@@ -76,7 +76,9 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{ {
std::wstring namespace_ = m_namespace; std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wpg";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
pWriter->StartNode(namespace_ + L":nvGrpSpPr"); pWriter->StartNode(namespace_ + L":nvGrpSpPr");
...@@ -132,7 +134,7 @@ namespace PPTX ...@@ -132,7 +134,7 @@ namespace PPTX
pReader->Seek(_end_rec); pReader->Seek(_end_rec);
} }
std::wstring m_namespace; std::wstring m_namespace;
CNvPr cNvPr; CNvPr cNvPr;
CNvGrpSpPr cNvGrpSpPr; CNvGrpSpPr cNvGrpSpPr;
......
...@@ -134,7 +134,7 @@ namespace PPTX ...@@ -134,7 +134,7 @@ namespace PPTX
virtual std::wstring GetODString()const virtual std::wstring GetODString()const
{ {
std::wstring str = L"<a:pt x=\"" + x + L"\" y=\"" + y + L"\" />"; std::wstring str = L"<pt x=\"" + x + L"\" y=\"" + y + L"\" />";
return _T("<lnTo>") + str + _T("</lnTo>"); return _T("<lnTo>") + str + _T("</lnTo>");
} }
}; };
......
...@@ -132,7 +132,7 @@ namespace PPTX ...@@ -132,7 +132,7 @@ namespace PPTX
public: public:
virtual std::wstring GetODString()const virtual std::wstring GetODString()const
{ {
std::wstring str = L"<a:pt x=\"" + x + L"\" y=\"" + y + L"\" />"; std::wstring str = L"<pt x=\"" + x + L"\" y=\"" + y + L"\" />";
return _T("<moveTo>") + str + _T("</moveTo>"); return _T("<moveTo>") + str + _T("</moveTo>");
} }
}; };
......
...@@ -161,8 +161,8 @@ namespace PPTX ...@@ -161,8 +161,8 @@ namespace PPTX
virtual std::wstring GetODString()const virtual std::wstring GetODString()const
{ {
std::wstring str1 = L"<a:pt x=\"" + x[0] + L"\" y=\"" + y[0] + L"\" />"; std::wstring str1 = L"<pt x=\"" + x[0] + L"\" y=\"" + y[0] + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x[1] + L"\" y=\"" + y[1] + L"\" />"; std::wstring str2 = L"<pt x=\"" + x[1] + L"\" y=\"" + y[1] + L"\" />";
return _T("<quadBezTo>") + str1 + str2 + _T("</quadBezTo>"); return _T("<quadBezTo>") + str1 + str2 + _T("</quadBezTo>");
} }
......
...@@ -113,12 +113,14 @@ namespace PPTX ...@@ -113,12 +113,14 @@ namespace PPTX
virtual bool is_init() const {return (Elem.IsInit());}; virtual bool is_init() const {return (Elem.IsInit());};
virtual std::wstring GetText() const{return Elem->GetText();} virtual std::wstring GetText() const{return Elem->GetText();}
smart_ptr<RunBase> GetElem()
{
return Elem;
}
template<class T> AVSINLINE const bool is() const { return Elem.is<T>(); } template<class T> AVSINLINE const bool is() const { return Elem.is<T>(); }
template<class T> AVSINLINE T& as() { return Elem.as<T>(); } template<class T> AVSINLINE T& as() { return Elem.as<T>(); }
template<class T> AVSINLINE const T& as() const { return Elem.as<T>(); } template<class T> AVSINLINE const T& as() const { return Elem.as<T>(); }
//public:
private: private:
smart_ptr<RunBase> Elem; smart_ptr<RunBase> Elem;
protected: protected:
......
...@@ -177,7 +177,7 @@ namespace PPTX ...@@ -177,7 +177,7 @@ namespace PPTX
{ {
std::wstring name_ = m_name; std::wstring name_ = m_name;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) name_ = L"wps:wsp"; if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) name_ = L"wps:wsp";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:sp"; else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:sp";
pWriter->StartNode(name_); pWriter->StartNode(name_);
...@@ -210,10 +210,8 @@ namespace PPTX ...@@ -210,10 +210,8 @@ namespace PPTX
if (style.is_init()) if (style.is_init())
{ {
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) style->m_namespace = _T("wps");
style->m_namespace = _T("wps"); else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) style->m_namespace = _T("xdr");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
style->m_namespace = _T("xdr");
pWriter->Write(style); pWriter->Write(style);
} }
......
...@@ -56,6 +56,12 @@ namespace PPTX ...@@ -56,6 +56,12 @@ namespace PPTX
m_diag = oSrc.m_diag; m_diag = oSrc.m_diag;
return *this; return *this;
} }
virtual OOX::EElementType getType () const
{
return OOX::et_dgm_DiagrammParts;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{ {
WritingElement_ReadAttributes_Start ( oReader ) WritingElement_ReadAttributes_Start ( oReader )
......
...@@ -51,8 +51,10 @@ namespace PPTX ...@@ -51,8 +51,10 @@ namespace PPTX
public: public:
WritingElement_AdditionConstructors(SpTree) WritingElement_AdditionConstructors(SpTree)
SpTree() SpTree(std::wstring ns = L"p") : nvGrpSpPr(ns), grpSpPr(ns)
{ {
m_namespace = ns;
m_lGroupIndex = 0;
} }
SpTree& operator=(const SpTree& oSrc) SpTree& operator=(const SpTree& oSrc)
...@@ -66,7 +68,8 @@ namespace PPTX ...@@ -66,7 +68,8 @@ namespace PPTX
for (size_t i=0; i < oSrc.SpTreeElems.size(); i++) for (size_t i=0; i < oSrc.SpTreeElems.size(); i++)
SpTreeElems.push_back(oSrc.SpTreeElems[i]); SpTreeElems.push_back(oSrc.SpTreeElems[i]);
m_name = oSrc.m_name; m_namespace = oSrc.m_namespace;
m_lGroupIndex = oSrc.m_lGroupIndex;
return *this; return *this;
} }
...@@ -76,7 +79,7 @@ namespace PPTX ...@@ -76,7 +79,7 @@ namespace PPTX
} }
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{ {
m_name = oReader.GetName(); m_namespace = XmlUtils::GetNamespace(oReader.GetName());
SpTreeElems.clear(); SpTreeElems.clear();
...@@ -104,7 +107,14 @@ namespace PPTX ...@@ -104,7 +107,14 @@ namespace PPTX
{ {
SpTreeElem elem(oReader); SpTreeElem elem(oReader);
if (elem.is_init()) if (elem.is_init())
{
if (elem.getType() == OOX::et_p_ShapeTree)
{
smart_ptr<SpTree> &e = elem.GetElem().smart_dynamic_cast<SpTree>();
e->m_lGroupIndex = m_lGroupIndex + 1;
}
SpTreeElems.push_back(elem); SpTreeElems.push_back(elem);
}
} }
} }
...@@ -113,7 +123,7 @@ namespace PPTX ...@@ -113,7 +123,7 @@ namespace PPTX
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
m_name = node.GetName(); m_namespace = XmlUtils::GetNamespace(node.GetName());
nvGrpSpPr = node.ReadNodeNoNS(_T("nvGrpSpPr")); nvGrpSpPr = node.ReadNodeNoNS(_T("nvGrpSpPr"));
grpSpPr = node.ReadNodeNoNS(_T("grpSpPr")); grpSpPr = node.ReadNodeNoNS(_T("grpSpPr"));
...@@ -143,7 +153,14 @@ namespace PPTX ...@@ -143,7 +153,14 @@ namespace PPTX
{ {
SpTreeElem elem(oNode); SpTreeElem elem(oNode);
if (elem.is_init()) if (elem.is_init())
{
if (elem.getType() == OOX::et_p_ShapeTree)
{
smart_ptr<SpTree> &e = elem.GetElem().smart_dynamic_cast<SpTree>();
e->m_lGroupIndex = m_lGroupIndex + 1;
}
SpTreeElems.push_back(elem); SpTreeElems.push_back(elem);
}
} }
} }
} }
...@@ -153,29 +170,45 @@ namespace PPTX ...@@ -153,29 +170,45 @@ namespace PPTX
virtual std::wstring toXML() const virtual std::wstring toXML() const
{ {
std::wstring name_;
if (m_namespace == L"wpg")
{
if (m_lGroupIndex == 0) name_ = L"wpg:wgp";
else name_ = L"wpg:grpSp";
}
else if (m_namespace == L"xdr") name_ = L"xdr:grpSp";
else
{
if (m_lGroupIndex == 0) name_ = L"p:spTree";
else name_ = L"p:grpSp";
}
XmlUtils::CNodeValue oValue; XmlUtils::CNodeValue oValue;
oValue.Write(nvGrpSpPr); oValue.Write(nvGrpSpPr);
oValue.Write(grpSpPr); oValue.Write(grpSpPr);
oValue.WriteArray(SpTreeElems); oValue.WriteArray(SpTreeElems);
return XmlUtils::CreateNode(m_name, oValue); return XmlUtils::CreateNode(name_, oValue);
} }
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, bool in_group = false); 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
{ {
std::wstring name_;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{ {
if (pWriter->m_lGroupIndex == 0) if (pWriter->m_lGroupIndex == 0) name_ = L"wpg:wgp";
pWriter->StartNode(_T("wpg:wgp")); else name_ = L"wpg:grpSp";
else
pWriter->StartNode(_T("wpg:grpSp"));
} }
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:grpSp";
pWriter->StartNode(_T("xdr:grpSp"));
else else
pWriter->StartNode(m_name); {
if (pWriter->m_lGroupIndex == 0) name_ = L"p:spTree";
else name_ = L"p:grpSp";
}
pWriter->StartNode(name_);
pWriter->EndAttributes(); pWriter->EndAttributes();
...@@ -196,18 +229,8 @@ namespace PPTX ...@@ -196,18 +229,8 @@ namespace PPTX
SpTreeElems[i].toXmlWriter(pWriter); SpTreeElems[i].toXmlWriter(pWriter);
pWriter->m_lGroupIndex--; pWriter->m_lGroupIndex--;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) pWriter->EndNode(name_);
{
if (pWriter->m_lGroupIndex == 0)
pWriter->EndNode(_T("wpg:wgp"));
else
pWriter->EndNode(_T("wpg:grpSp"));
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:grpSp"));
else
pWriter->EndNode(m_name);
} }
void NormalizeRect(Aggplus::RECT& rect)const void NormalizeRect(Aggplus::RECT& rect)const
...@@ -273,12 +296,16 @@ namespace PPTX ...@@ -273,12 +296,16 @@ namespace PPTX
if(nElemLength > 0) if(nElemLength > 0)
{ {
SpTreeElem elm; SpTreeElem elm;
SpTreeElems.push_back(elm); elm.fromPPTY(pReader);
SpTreeElems.back().fromPPTY(pReader);
if (!SpTreeElems.back().is_init()) if (SpTreeElems.back().is_init())
{ {
SpTreeElems.pop_back(); if (elm.getType() == OOX::et_p_ShapeTree)
{
smart_ptr<SpTree> &e = elm.GetElem().smart_dynamic_cast<SpTree>();
e->m_lGroupIndex = m_lGroupIndex + 1;
}
SpTreeElems.push_back(elm);
} }
} }
} }
...@@ -297,7 +324,8 @@ namespace PPTX ...@@ -297,7 +324,8 @@ namespace PPTX
Logic::GrpSpPr grpSpPr; Logic::GrpSpPr grpSpPr;
std::vector<SpTreeElem> SpTreeElems; std::vector<SpTreeElem> SpTreeElems;
std::wstring m_name; std::wstring m_namespace;
int m_lGroupIndex;
protected: protected:
virtual void FillParentPointersForChilds() virtual void FillParentPointersForChilds()
{ {
......
...@@ -352,9 +352,14 @@ namespace PPTX ...@@ -352,9 +352,14 @@ namespace PPTX
case SPTREE_TYPE_SPTREE: case SPTREE_TYPE_SPTREE:
{ {
Logic::SpTree* p = new Logic::SpTree(); Logic::SpTree* p = new Logic::SpTree();
p->m_name = _T("p:grpSp");
pReader->Seek(pReader->GetPos() - 5); // type back + len pReader->Seek(pReader->GetPos() - 5); // type back + len
p->fromPPTY(pReader); p->fromPPTY(pReader);
if (getType() == OOX::et_p_ShapeTree)
{
smart_ptr<PPTX::Logic::SpTree> &parent = GetElem().smart_dynamic_cast<PPTX::Logic::SpTree>();
p->m_lGroupIndex = parent->m_lGroupIndex + 1;
}
m_elem.reset(p); m_elem.reset(p);
break; break;
} }
......
...@@ -47,9 +47,9 @@ namespace PPTX ...@@ -47,9 +47,9 @@ namespace PPTX
class TxBody : public WrapperWritingElement class TxBody : public WrapperWritingElement
{ {
public: public:
TxBody() TxBody(std::wstring name = L"p:txBody")
{ {
m_name = _T("p:txBody"); m_name = name;
} }
virtual ~TxBody() {} virtual ~TxBody() {}
explicit TxBody(XmlUtils::CXmlNode& node) explicit TxBody(XmlUtils::CXmlNode& node)
...@@ -252,9 +252,11 @@ namespace PPTX ...@@ -252,9 +252,11 @@ namespace PPTX
} }
pReader->Seek(_end_rec); pReader->Seek(_end_rec);
if (!bodyPr.IsInit())
bodyPr = new Logic::BodyPr();
} }
public:
nullable<BodyPr> bodyPr; nullable<BodyPr> bodyPr;
nullable<TextListStyle> lstStyle; nullable<TextListStyle> lstStyle;
std::vector<Paragraph> Paragrs; std::vector<Paragraph> Paragrs;
......
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