Commit 7be543c3 authored by ElenaSubbotina's avatar ElenaSubbotina

pptx format .. extended reading xml

parent ccb47b0b
......@@ -52,7 +52,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(BodyPr)
PPTX_LOGIC_BASE2(BodyPr)
BodyPr(std::wstring ns = L"a")
{
m_namespace = ns;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
......
......@@ -42,8 +42,13 @@ namespace PPTX
class CNvCxnSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CNvCxnSpPr)
WritingElement_AdditionConstructors(CNvCxnSpPr)
CNvCxnSpPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
CNvCxnSpPr& operator=(const CNvCxnSpPr& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -68,9 +73,58 @@ namespace PPTX
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"a:cxnSpLocks")
{
ReadAttributesLocks(oReader);
}
else if (strName == L"a:stCxn")
{
ReadAttributes(oReader, stCxn_id, stCxn_idx);
}
else if (strName == L"a:endCxn")
{
ReadAttributes(oReader, endCxn_id, endCxn_idx);
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & id, nullable_int & idx )
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("id"), id)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("idx"), idx)
WritingElement_ReadAttributes_End( oReader )
}
void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNode l_Locks;
if (node.GetNode(_T("a:cxnSpLocks"), l_Locks))
{
......@@ -132,17 +186,17 @@ namespace PPTX
if (_T("") != oAttr3.m_strValue)
oValue.m_strValue += XmlUtils::CreateNode(_T("a:endCxn"), oAttr3);
return XmlUtils::CreateNode(_T("p:cNvCxnSpPr"), oValue);
return XmlUtils::CreateNode(m_namespace + L":cNvCxnSpPr", oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->StartNode(_T("wps:cNvCxnSpPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:cNvCxnSpPr"));
else
pWriter->StartNode(_T("p:cNvCxnSpPr"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
pWriter->StartNode(namespace_ + L":cNvCxnSpPr");
pWriter->EndAttributes();
......@@ -181,12 +235,7 @@ namespace PPTX
pWriter->EndNode(_T("a:endCxn"));
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("wps:cNvCxnSpPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:cNvCxnSpPr"));
else
pWriter->EndNode(_T("p:cNvCxnSpPr"));
pWriter->EndNode(namespace_ + L":cNvCxnSpPr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -299,7 +348,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
std::wstring m_namespace;
nullable_bool noAdjustHandles;
nullable_bool noChangeArrowheads;
nullable_bool noChangeAspect;
......
......@@ -42,7 +42,12 @@ namespace PPTX
class CNvGraphicFramePr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CNvGraphicFramePr)
WritingElement_AdditionConstructors(CNvGraphicFramePr)
CNvGraphicFramePr(std::wstring ns = L"p")
{
m_namespace = ns;
}
CNvGraphicFramePr& operator=(const CNvGraphicFramePr& oSrc)
{
......@@ -56,12 +61,43 @@ namespace PPTX
noResize = oSrc.noResize;
noSelect = oSrc.noSelect;
m_namespace = oSrc.m_namespace;
return *this;
}
void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = oReader.GetName();
public:
if (strName == L"a:graphicFrameLocks")
{
ReadAttributesLocks(oReader);
}
}
}
void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("noChangeAspect"), noChangeAspect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noDrilldown"), noDrilldown)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNode oNode;
if (node.GetNode(_T("a:graphicFrameLocks"), oNode))
{
......@@ -84,18 +120,17 @@ namespace PPTX
oAttr.Write(_T("noResize"), noResize);
oAttr.Write(_T("noSelect"), noSelect);
if (_T("") == oAttr.m_strValue)
return _T("<p:cNvGraphicFramePr/>");
return _T("<p:cNvGraphicFramePr>") + XmlUtils::CreateNode(_T("a:graphicFrameLocks"), oAttr) + _T("</p:cNvGraphicFramePr>");
return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr>", XmlUtils::CreateNode(_T("a:graphicFrameLocks"), oAttr));
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:cNvGraphicFramePr"));
else
pWriter->StartNode(_T("p:cNvGraphicFramePr"));
namespace_ = L"xdr";
pWriter->StartNode(namespace_ + L":cNvGraphicFramePr");
pWriter->EndAttributes();
......@@ -114,10 +149,7 @@ namespace PPTX
pWriter->EndNode(_T("a:graphicFrameLocks"));
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:cNvGraphicFramePr"));
else
pWriter->EndNode(_T("p:cNvGraphicFramePr"));
pWriter->EndNode(namespace_ + L":cNvGraphicFramePr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -182,8 +214,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
std::wstring m_namespace;
public:
nullable_bool noChangeAspect;
nullable_bool noDrilldown;
nullable_bool noGrp;
......
......@@ -35,7 +35,6 @@ namespace PPTX
{
namespace Logic
{
CNvGrpSpPr& CNvGrpSpPr::operator=(const CNvGrpSpPr& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -54,6 +53,8 @@ namespace PPTX
void CNvGrpSpPr::fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNode oNode;
if (node.GetNode(_T("a:grpSpLocks"), oNode))
{
......@@ -66,8 +67,36 @@ namespace PPTX
oNode.ReadAttributeBase(L"noUngrp", noUngrp);
}
}
void CNvGrpSpPr::ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("noChangeAspect"), noChangeAspect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noUngrp"), noUngrp)
WritingElement_ReadAttributes_End( oReader )
}
void CNvGrpSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = oReader.GetName();
if (strName == L"a:grpSpLocks")
{
ReadAttributesLocks(oReader);
}
}
}
std::wstring CNvGrpSpPr::toXML() const
{
XmlUtils::CAttribute oAttr;
......@@ -79,10 +108,7 @@ namespace PPTX
oAttr.Write(_T("noSelect"), noSelect);
oAttr.Write(_T("noUngrp"), noUngrp);
if (_T("") == oAttr.m_strValue)
return _T("<p:cNvGrpSpPr/>");
return _T("<p:cNvGrpSpPr>") + XmlUtils::CreateNode(_T("a:grpSpLocks"), oAttr) + _T("</p:cNvGrpSpPr>");
return XmlUtils::CreateNode(m_namespace + L":cNvGrpSpPr", XmlUtils::CreateNode(_T("a:grpSpLocks"), oAttr));
}
} // namespace Logic
......
......@@ -42,18 +42,26 @@ namespace PPTX
class CNvGrpSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CNvGrpSpPr)
WritingElement_AdditionConstructors(CNvGrpSpPr)
CNvGrpSpPr& operator=(const CNvGrpSpPr& oSrc);
CNvGrpSpPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
CNvGrpSpPr& operator=(const CNvGrpSpPr& oSrc);
public:
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring ns = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
ns = L"xdr";
if (!noChangeAspect.is_init() &&
!noGrp.is_init() &&
!noMove.is_init() &&
......@@ -62,17 +70,11 @@ namespace PPTX
!noSelect.is_init() &&
!noUngrp.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->WriteString(_T("<xdr:cNvGrpSpPr/>"));
else
pWriter->WriteString(_T("<p:cNvGrpSpPr/>"));
pWriter->WriteString(L"<" + ns + L":cNvGrpSpPr/>");
return;
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->WriteString(_T("<xdr:cNvGrpSpPr>"));
else
pWriter->WriteString(_T("<p:cNvGrpSpPr>"));
pWriter->WriteString(L"<" + ns + L":cNvGrpSpPr>");
pWriter->StartNode(_T("a:grpSpLocks"));
......@@ -88,10 +90,7 @@ namespace PPTX
pWriter->EndNode(_T("a:grpSpLocks"));
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->WriteString(_T("</xdr:cNvGrpSpPr>"));
else
pWriter->WriteString(_T("</p:cNvGrpSpPr>"));
pWriter->WriteString(L"</" + ns + L":cNvGrpSpPr>");
}
void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const
......@@ -192,8 +191,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
std::wstring m_namespace;
public:
nullable_bool noChangeAspect;
nullable_bool noGrp;
nullable_bool noMove;
......@@ -202,6 +201,7 @@ namespace PPTX
nullable_bool noSelect;
nullable_bool noUngrp;
protected:
void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader);
virtual void FillParentPointersForChilds(){};
};
} // namespace Logic
......
......@@ -44,7 +44,12 @@ namespace PPTX
{
public:
PPTX_LOGIC_BASE(CNvPicPr)
WritingElement_AdditionConstructors(CNvPicPr)
CNvPicPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
CNvPicPr& operator=(const CNvPicPr& oSrc)
{
......@@ -65,10 +70,52 @@ namespace PPTX
noRot = oSrc.noRot;
noSelect = oSrc.noSelect;
m_namespace = oSrc.m_namespace;
return *this;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("preferRelativeResize"), preferRelativeResize )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
public:
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("a:picLocks") == strName)
{
ReadAttributesLocks(oReader);
}
}
}
void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noCrop"), noCrop)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"preferRelativeResize", preferRelativeResize);
......@@ -118,12 +165,12 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->StartNode(_T("pic:cNvPicPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:cNvPicPr"));
else
pWriter->StartNode(_T("p:cNvPicPr"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
pWriter->StartNode(namespace_ + L":cNvPicPr");
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("preferRelativeResize"), preferRelativeResize);
......@@ -157,13 +204,7 @@ namespace PPTX
pWriter->EndAttributes();
pWriter->EndNode(_T("a:picLocks"));
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("pic:cNvPicPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:cNvPicPr"));
else
pWriter->EndNode(_T("p:cNvPicPr"));
pWriter->EndNode(namespace_ + L":cNvPicPr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -262,8 +303,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
std::wstring m_namespace;
public:
nullable_bool preferRelativeResize;
nullable_bool noAdjustHandles;
......
......@@ -44,15 +44,54 @@ namespace PPTX
class CNvPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CNvPr)
WritingElement_AdditionConstructors(CNvPr)
CNvPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
virtual OOX::EElementType getType () const
{
return OOX::et_p_cNvPr;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
nullable_int id_;
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("id"), id_)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("name"), name)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("descr"), descr)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("hidden"), hidden)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("title"), title)
WritingElement_ReadAttributes_End( oReader )
id = id_.get_value_or(0);
Normalize();
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:hlinkClick")
hlinkClick = oReader;
else if (sName == L"a:hlinkHover")
hlinkHover = oReader;
}
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
id = node.ReadAttributeInt(L"id");
name = node.GetAttribute(L"name");
......@@ -79,18 +118,16 @@ namespace PPTX
oValue.WriteNullable(hlinkClick);
oValue.WriteNullable(hlinkHover);
return XmlUtils::CreateNode(_T("p:cNvPr"), oAttr, oValue);
return XmlUtils::CreateNode(m_namespace + L":cNvPr", oAttr, oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring namespace_;
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
namespace_= _T("pic");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
namespace_= _T("xdr");
else
namespace_= _T("p");
toXmlWriter2(namespace_, pWriter);
......@@ -196,7 +233,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
std::wstring m_namespace;
int id;
std::wstring name;
nullable_string descr;
......
......@@ -42,7 +42,12 @@ namespace PPTX
class CNvSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CNvSpPr)
WritingElement_AdditionConstructors(CNvSpPr)
CNvSpPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
CNvSpPr& operator=(const CNvSpPr& oSrc)
{
......@@ -65,9 +70,52 @@ namespace PPTX
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = oReader.GetName();
if (strName == L"a:spLocks")
{
ReadAttributesLocks(oReader);
}
}
}
void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noTextEdit"), noTextEdit)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints)
WritingElement_ReadAttributes_End( oReader )
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("txBox"), txBox)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
node.ReadAttributeBase(L"txBox", txBox);
XmlUtils::CXmlNode l_Locks;
......@@ -105,16 +153,18 @@ namespace PPTX
oAttr2.Write(_T("noTextEdit"), noTextEdit);
if (_T("") == oAttr2.m_strValue)
return XmlUtils::CreateNode(_T("p:cNvSpPr"), oAttr1);
return XmlUtils::CreateNode(m_namespace + L":cNvSpPr", oAttr1);
return XmlUtils::CreateNode(_T("p:cNvSpPr"), oAttr1, XmlUtils::CreateNode(_T("a:spLocks"), oAttr2));
return XmlUtils::CreateNode(m_namespace + L":cNvSpPr", oAttr1, XmlUtils::CreateNode(_T("a:spLocks"), oAttr2));
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:cNvSpPr"));
else
pWriter->StartNode(_T("p:cNvSpPr"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
pWriter->StartNode(namespace_ + L":cNvSpPr");
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("txBox"), txBox);
......@@ -151,10 +201,7 @@ namespace PPTX
pWriter->EndNode(_T("a:spLocks"));
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:cNvSpPr"));
else
pWriter->EndNode(_T("p:cNvSpPr"));
pWriter->EndNode(namespace_ + L":cNvSpPr");
}
void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const
......@@ -296,7 +343,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
std::wstring m_namespace;
nullable_bool txBox;
nullable_bool noAdjustHandles;
nullable_bool noChangeArrowheads;
......
......@@ -45,9 +45,12 @@ namespace PPTX
class CSld : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CSld)
WritingElement_AdditionConstructors(CSld)
PPTX_LOGIC_BASE2(CSld)
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"name", attrName);
......
......@@ -45,15 +45,43 @@ namespace PPTX
class Cell3D : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Cell3D)
WritingElement_AdditionConstructors(Cell3D)
public:
Cell3D()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("bevel") == strName)
bevel = oReader;
else if (_T("lightRig") == strName)
lightRig = oReader;
}
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("prstMaterial"), prstMaterial )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"prstMaterial", prstMaterial);
bevel = node.ReadNodeNoNS(_T("bevel"));
lightRig = node.ReadNode(_T("a:lightRig"));
lightRig = node.ReadNodeNoNS(_T("lightRig"));
FillParentPointersForChilds();
}
......
......@@ -41,28 +41,58 @@ namespace PPTX
{
namespace Logic
{
CxnSp::CxnSp()
CxnSp::CxnSp(std::wstring ns)
{
m_namespace = ns;
}
CxnSp::~CxnSp()
{
}
CxnSp::CxnSp(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const CxnSp& CxnSp::operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
CxnSp::CxnSp(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const CxnSp& CxnSp::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void CxnSp::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("nvCxnSpPr") == strName)
nvCxnSpPr = oReader;
else if (_T("spPr") == strName)
spPr = oReader;
else if (_T("style") == strName)
style = oReader;
}
FillParentPointersForChilds();
}
void CxnSp::fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
......@@ -93,7 +123,7 @@ namespace PPTX
oValue.Write(spPr);
oValue.WriteNullable(style);
return XmlUtils::CreateNode(_T("<p:cxnSp>"), oValue);
return XmlUtils::CreateNode(m_namespace + L":cxnSp", oValue);
}
void CxnSp::FillParentPointersForChilds()
......
......@@ -46,13 +46,23 @@ namespace PPTX
class CxnSp : public WrapperWritingElement
{
public:
CxnSp();
CxnSp(std::wstring ns = L"p");
virtual ~CxnSp();
explicit CxnSp(XmlUtils::CXmlNode& node);
const CxnSp& operator =(XmlUtils::CXmlNode& node);
public:
explicit CxnSp(XmlUtils::CXmlLiteReader& oReader);
const CxnSp& operator =(XmlUtils::CXmlLiteReader& oReader);
virtual OOX::EElementType getType () const
{
return OOX::et_a_CxnSp;
}
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
virtual void GetRect(Aggplus::RECT& pRect)const;
......@@ -72,12 +82,12 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->StartNode(_T("wps:cxnSp"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:cxnSp"));
else
pWriter->StartNode(_T("p:cxnSp"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
pWriter->StartNode(namespace_ + L":cxnSp");
pWriter->EndAttributes();
......@@ -87,19 +97,13 @@ namespace PPTX
if (style.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
style->m_ns = _T("wps");
style->m_namespace = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
style->m_ns = _T("xdr");
style->m_namespace = _T("xdr");
pWriter->Write(style);
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("wps:cxnSp"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:cxnSp"));
else
pWriter->EndNode(_T("p:cxnSp"));
pWriter->EndNode(namespace_ + L":cxnSp");
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
......@@ -123,8 +127,7 @@ namespace PPTX
}
case 2:
{
style = new ShapeStyle();
style->m_ns = _T("p");
style = new ShapeStyle(L"p");
style->fromPPTY(pReader);
break;
}
......@@ -138,7 +141,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
std::wstring m_namespace;
NvCxnSpPr nvCxnSpPr;
SpPr spPr;
nullable<ShapeStyle> style;
......
......@@ -127,8 +127,7 @@ namespace PPTX
}
case 1:
{
bodyPr = BodyPr();
bodyPr->m_namespace = _T("a");
bodyPr = BodyPr(L"a");
bodyPr->fromPPTY(pReader);
break;
}
......@@ -140,8 +139,7 @@ namespace PPTX
}
case 3:
{
style = new ShapeStyle();
style->m_ns = _T("a");
style = new ShapeStyle(L"a");
style->fromPPTY(pReader);
break;
}
......
......@@ -52,9 +52,48 @@ namespace PPTX
class Ext : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Ext)
WritingElement_AdditionConstructors(Ext)
public:
Ext()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"media")
{
ReadAttributes(oReader);
//std::wstring xmkl = media.GetXml();
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring strName1 = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName1 == L"trim")
{
ReadAttributes(oReader);
}
}
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("st"), st)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("end"), end)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("r:embed"), link)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode media;
......@@ -95,11 +134,9 @@ namespace PPTX
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
}
public:
OOX::RId link;
// trim
// trim
nullable_double st;
nullable_double end;
......
......@@ -46,8 +46,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(Blip)
PPTX_LOGIC_BASE2(Blip)
Blip(std::wstring ns = L"a")
{
m_namespace = ns;
}
Blip& operator=(const Blip& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -179,10 +182,9 @@ namespace PPTX
nullable_limit<Limit::BlipCompression> cstate;
nullable<OOX::RId> embed;
nullable<OOX::RId> link;
//private:
public:
std::wstring m_namespace;
//internal
std::wstring oleRid;
std::wstring oleFilepathBin;
std::wstring oleFilepathImg;
......
......@@ -50,7 +50,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(BlipFill)
PPTX_LOGIC_BASE2(BlipFill)
BlipFill(std::wstring ns = L"p")
{
m_namespace = ns;
}
BlipFill& operator=(const BlipFill& oSrc)
{
......
......@@ -49,8 +49,12 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(GradFill)
PPTX_LOGIC_BASE2(GradFill)
GradFill(std::wstring ns = L"a")
{
m_namespace = ns;
}
GradFill& operator=(const GradFill& oSrc)
{
parentFile = oSrc.parentFile;
......
......@@ -44,8 +44,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(NoFill)
PPTX_LOGIC_BASE2(NoFill)
NoFill(std::wstring ns = L"a")
{
m_namespace = ns;
}
NoFill& operator=(const NoFill& oSrc)
{
parentFile = oSrc.parentFile;
......
......@@ -45,8 +45,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(PattFill)
PPTX_LOGIC_BASE2(PattFill)
PattFill(std::wstring ns = L"a")
{
m_namespace = ns;
}
PattFill& operator=(const PattFill& oSrc)
{
parentFile = oSrc.parentFile;
......
......@@ -45,8 +45,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(SolidFill)
PPTX_LOGIC_BASE2(SolidFill)
SolidFill(std::wstring ns = L"a")
{
m_namespace = ns;
}
SolidFill& operator=(const SolidFill& oSrc)
{
parentFile = oSrc.parentFile;
......
......@@ -44,9 +44,32 @@ namespace PPTX
class FontRef : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(FontRef)
WritingElement_AdditionConstructors(FontRef)
public:
FontRef()
{
}
virtual OOX::EElementType getType () const
{
return OOX::et_Unknown;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = oReader.GetName();
ReadAttributes( oReader );
Color.fromXMLParent(oReader);
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("idx"), idx )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_name = node.GetName();
......
......@@ -61,6 +61,139 @@ namespace PPTX
fromXML(node);
return *this;
}
GraphicFrame::GraphicFrame(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const GraphicFrame& GraphicFrame::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void GraphicFrame::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
fromXML2(oReader);
}
FillParentPointersForChilds();
}
void GraphicFrame::ReadAttributes3(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("spid"), spid )
WritingElement_ReadAttributes_End( oReader )
}
void GraphicFrame::fromXML2(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
std::wstring strNamespace = XmlUtils::GetNamespace(oReader.GetName());
if (L"xfrm" == strName && strNamespace != L"xdr")
xfrm = oReader;
else if (L"nvGraphicFramePr" == strName)
nvGraphicFramePr.fromXML( oReader );
else if (L"graphic" == strName)
{
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName1 = oReader.GetName();
if (strName1 == L"a:graphicData")
{
fromXML3(oReader);
}
}
}
}
bool GraphicFrame::fromXML3(XmlUtils::CXmlLiteReader& oReader)
{
bool result = false;
if ( oReader.IsEmptyNode() )
return result;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"tbl")
{
table = oReader;
result = true;
}
else if (strName == L"oleObj")
{
ReadAttributes3(oReader);
int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{
std::wstring strName1 = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName1 == L"pic")
{
result = true;
pic = oReader;
//pic->fromXMLOle(oNode2);
if (xfrm.IsInit())
xfrm->Merge(pic->spPr.xfrm);
}
}
}
else if (strName == L"relIds")
{
smartArt = oReader;
result = true;
}
else if (strName == L"chart")
{
chartRec = oReader;
result = true;
}
else if (strName == L"legacyDrawing")
{
ReadAttributes3(oReader);
result = true;
}
else if (strName == L"AlternateContent")
{
int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{
std::wstring strName1 = oReader.GetName();
if (strName1 == L"mc:Choice")
{
result = fromXML3(oReader);
if (result)
break;
}
else if (strName1 == L"mc:Fallback")
{
result = fromXML3(oReader);
if (result)
break;
}
}
}
else
{
element = oReader;
if (element.IsInit())
result = true;
}
}
return result;
}
void GraphicFrame::fromXML(XmlUtils::CXmlNode& node)
{
......@@ -228,7 +361,7 @@ namespace PPTX
if (smartArt.is_init() && !table.is_init() && !chartRec.is_init() && !spid.is_init())
{
smartArt->LoadDrawing(pWriter);
//smartArt->LoadDrawing(pWriter);
if (smartArt->m_diag.is_init())
{
smartArt->m_diag->nvGrpSpPr.cNvPr = nvGraphicFramePr.cNvPr;
......
......@@ -51,27 +51,42 @@ namespace PPTX
public:
GraphicFrame();
virtual ~GraphicFrame();
virtual OOX::EElementType getType () const
{
return OOX::et_a_GraphicFrame;
}
explicit GraphicFrame(XmlUtils::CXmlLiteReader& oReader);
const GraphicFrame& operator =(XmlUtils::CXmlLiteReader& oReader);
explicit GraphicFrame(XmlUtils::CXmlNode& node);
const GraphicFrame& operator =(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void fromXML2(XmlUtils::CXmlLiteReader& oReader);
bool fromXML3(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributes3(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
virtual void GetRect(Aggplus::RECT& pRect)const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
NvGraphicFramePr nvGraphicFramePr;
nullable<Xfrm> xfrm;
nullable_string spid;
nullable<Table> table;
nullable<SmartArt> smartArt;
nullable<ChartRec> chartRec;
nullable<Pic> pic;
nullable<SpTreeElem> element;
std::wstring GetVmlXmlBySpid(std::wstring & rels) const;
protected:
......
......@@ -48,8 +48,11 @@ namespace PPTX
class GrpSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(GrpSpPr)
WritingElement_AdditionConstructors(GrpSpPr)
GrpSpPr()
{
}
GrpSpPr& operator=(const GrpSpPr& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -66,7 +69,9 @@ namespace PPTX
{
return OOX::et_p_groupSpPr;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"bwMode", bwMode);
......
......@@ -42,7 +42,11 @@ namespace PPTX
class AudioCD : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(AudioCD)
WritingElement_AdditionConstructors(AudioCD)
AudioCD()
{
}
AudioCD& operator=(const AudioCD& oSrc)
{
......@@ -57,8 +61,10 @@ namespace PPTX
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
//todooo
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oMem;
......
......@@ -42,9 +42,12 @@ namespace PPTX
{
class MediaFile : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(MediaFile)
public:
WritingElement_AdditionConstructors(MediaFile)
MediaFile()
{
}
MediaFile& operator=(const MediaFile& oSrc)
{
......@@ -57,15 +60,25 @@ namespace PPTX
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
name = XmlUtils::GetNameNoNS(oReader.GetName());
ReadAttributes(oReader);
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
name = XmlUtils::GetNameNoNS(node.GetName());
link = node.GetAttribute(_T("r:link"));
node.ReadAttributeBase(L"contentType", contentType);
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:link"), link)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("contentType"), contentType)
WritingElement_ReadAttributes_End( oReader )
}
virtual std::wstring toXML() const
{
XmlUtils::CAttribute oAttr;
......@@ -75,7 +88,7 @@ namespace PPTX
return XmlUtils::CreateNode(_T("a:") + name, oAttr);
}
public:
std::wstring name;
std::wstring name;
OOX::RId link;
nullable_string contentType;
protected:
......
......@@ -46,7 +46,12 @@ namespace PPTX
class NvCxnSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(NvCxnSpPr)
WritingElement_AdditionConstructors(NvCxnSpPr)
NvCxnSpPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
NvCxnSpPr& operator=(const NvCxnSpPr& oSrc)
{
......@@ -60,12 +65,33 @@ namespace PPTX
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"cNvPr")
cNvPr = oReader;
else if(strName == L"cNvCxnSpPr")
cNvCxnSpPr = oReader;
else if(strName == L"nvPr")
nvPr = oReader;
}
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
cNvPr = node.ReadNode(_T("p:cNvPr"));
cNvCxnSpPr = node.ReadNode(_T("p:cNvCxnSpPr"));
nvPr = node.ReadNode(_T("p:nvPr"));
m_namespace = XmlUtils::GetNamespace(node.GetName());
cNvPr = node.ReadNodeNoNS(_T("cNvPr"));
cNvCxnSpPr = node.ReadNodeNoNS(_T("cNvCxnSpPr"));
nvPr = node.ReadNodeNoNS(_T("nvPr"));
FillParentPointersForChilds();
}
......@@ -77,26 +103,16 @@ namespace PPTX
oValue.Write(cNvCxnSpPr);
oValue.Write(nvPr);
return XmlUtils::CreateNode(_T("<p:nvCxnSpPr>"), oValue);
return XmlUtils::CreateNode(m_namespace + L":nvCxnSpPr", oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring namespace_;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
pWriter->StartNode(_T("wps:nvCxnSpPr"));
namespace_ = _T("wps");
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
{
pWriter->StartNode(_T("xdr:nvCxnSpPr"));
namespace_ = _T("xdr");
}
else
{
pWriter->StartNode(_T("p:nvCxnSpPr"));
namespace_ = _T("p");
}
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
pWriter->StartNode(namespace_ + L":nvCxnSpPr");
pWriter->EndAttributes();
......@@ -104,12 +120,7 @@ namespace PPTX
cNvCxnSpPr.toXmlWriter(pWriter);
nvPr.toXmlWriter2(namespace_, pWriter);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("wps:nvCxnSpPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:nvCxnSpPr"));
else
pWriter->EndNode(_T("p:nvCxnSpPr"));
pWriter->EndNode(namespace_ + L":nvCxnSpPr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -151,10 +162,11 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
CNvPr cNvPr;
CNvCxnSpPr cNvCxnSpPr;
NvPr nvPr;
std::wstring m_namespace;
CNvPr cNvPr;
CNvCxnSpPr cNvCxnSpPr;
NvPr nvPr;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -46,8 +46,12 @@ namespace PPTX
class NvGraphicFramePr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(NvGraphicFramePr)
WritingElement_AdditionConstructors(NvGraphicFramePr)
NvGraphicFramePr(std::wstring ns = L"p")
{
m_namespace = ns;
}
NvGraphicFramePr& operator=(const NvGraphicFramePr& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -57,18 +61,42 @@ namespace PPTX
cNvGraphicFramePr = oSrc.cNvGraphicFramePr;
nvPr = oSrc.nvPr;
m_namespace = oSrc.m_namespace;
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
cNvPr = node.ReadNode(_T("p:cNvPr"));
cNvGraphicFramePr = node.ReadNode(_T("p:cNvGraphicFramePr"));
nvPr = node.ReadNode(_T("p:nvPr"));
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (sName == L"cNvPr")
cNvPr.fromXML( oReader);
else if (sName == L"cNvGraphicFramePr")
cNvGraphicFramePr.fromXML( oReader);
else if (sName == L"nvPr")
nvPr.fromXML( oReader);
}
FillParentPointersForChilds();
}
virtual std::wstring toXML() const
{
......@@ -77,7 +105,7 @@ namespace PPTX
oValue.Write(cNvGraphicFramePr);
oValue.Write(nvPr);
return XmlUtils::CreateNode(_T("p:nvGraphicFramePr"), oValue);
return XmlUtils::CreateNode(m_namespace + L":nvGraphicFramePr", oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
......@@ -150,7 +178,8 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
std::wstring m_namespace;
CNvPr cNvPr;
CNvGraphicFramePr cNvGraphicFramePr;
NvPr nvPr;
......
......@@ -38,45 +38,45 @@ namespace PPTX
void NvGrpSpPr::fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
cNvPr = node.ReadNode(_T("p:cNvPr"));
cNvGrpSpPr = node.ReadNode(_T("p:cNvGrpSpPr"));
nvPr = node.ReadNode(_T("p:nvPr"));
FillParentPointersForChilds();
/*
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName());
if (_T("cNvPr") == strName)
cNvPr = oNode;
else if (_T("cNvGrpSpPr") == strName)
cNvGrpSpPr = oNode;
else if (_T("nvPr") == strName)
nvPr = oNode;
}
}
FillParentPointersForChilds();
from header (old)*/
}
}
void NvGrpSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (sName == L"cNvPr")
cNvPr = oReader;
else if (sName == L"cNvGrpSpPr")
cNvGrpSpPr = oReader;
else if (sName == L"nvPr")
nvPr = oReader;
}
FillParentPointersForChilds();
}
std::wstring NvGrpSpPr::toXML() const
{
XmlUtils::CNodeValue oValue;
oValue.Write(cNvPr);
oValue.Write(cNvGrpSpPr);
oValue.Write(nvPr);
return XmlUtils::CreateNode(_T("p:nvGrpSpPr"), oValue);
return XmlUtils::CreateNode(m_namespace + L":nvGrpSpPr", oValue);
}
void NvGrpSpPr::FillParentPointersForChilds()
......
......@@ -46,7 +46,12 @@ namespace PPTX
class NvGrpSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(NvGrpSpPr)
WritingElement_AdditionConstructors(NvGrpSpPr)
NvGrpSpPr()
{
m_namespace = L"p";
}
NvGrpSpPr& operator=(const NvGrpSpPr& oSrc)
{
......@@ -62,49 +67,18 @@ namespace PPTX
{
return OOX::et_p_NvGrpSpPr;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual void fromXML(XmlUtils::CXmlNode& node);
//{
// XmlUtils::CXmlNodes oNodes;
// if (node.GetNodes(_T("*"), oNodes))
// {
// int nCount = oNodes.GetCount();
// for (int i = 0; i < nCount; ++i)
// {
// XmlUtils::CXmlNode oNode;
// oNodes.GetAt(i, oNode);
//virtual void fromXML(XmlUtils::CXmlNode& node);
virtual std::wstring toXML() const;
// std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName());
// if (_T("cNvPr") == strName)
// cNvPr = oNode;
// else if (_T("cNvGrpSpPr") == strName)
// cNvGrpSpPr = oNode;
// else if (_T("nvPr") == strName)
// nvPr = oNode;
// }
// }
// FillParentPointersForChilds();
//}
//virtual std::wstring toXML() const;
//{
// XmlUtils::CNodeValue oValue;
// oValue.Write(cNvPr);
// oValue.Write(cNvGrpSpPr);
// oValue.Write(nvPr);
// return XmlUtils::CreateNode(_T("p:nvGrpSpPr"), oValue);
//}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:nvGrpSpPr"));
else
pWriter->StartNode(_T("p:nvGrpSpPr"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
pWriter->StartNode(namespace_ + L":nvGrpSpPr");
pWriter->EndAttributes();
......@@ -112,12 +86,11 @@ namespace PPTX
cNvGrpSpPr.toXmlWriter(pWriter);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX)
{
nvPr.toXmlWriter(pWriter);
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:nvGrpSpPr"));
else
pWriter->EndNode(_T("p:nvGrpSpPr"));
pWriter->EndNode(namespace_ + L":nvGrpSpPr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -159,17 +132,14 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
std::wstring m_namespace;
CNvPr cNvPr;
CNvGrpSpPr cNvGrpSpPr;
NvPr nvPr;
protected:
virtual void FillParentPointersForChilds();
//{
// cNvPr.SetParentPointer(this);
// cNvGrpSpPr.SetParentPointer(this);
// nvPr.SetParentPointer(this);
//}
};
} // namespace Logic
} // namespace PPTX
......
......@@ -46,8 +46,12 @@ namespace PPTX
class NvPicPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(NvPicPr)
WritingElement_AdditionConstructors(NvPicPr)
NvPicPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
NvPicPr& operator=(const NvPicPr& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -57,12 +61,35 @@ namespace PPTX
cNvPicPr = oSrc.cNvPicPr;
nvPr = oSrc.nvPr;
m_namespace = oSrc.m_namespace;
return *this;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("cNvPr") == strName)
cNvPr.fromXML( oReader);
else if (_T("cNvPicPr") == strName)
cNvPicPr.fromXML( oReader);
else if (_T("nvPr") == strName)
nvPr.fromXML( oReader);
}
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
......@@ -93,17 +120,17 @@ namespace PPTX
oValue.Write(cNvPicPr);
oValue.Write(nvPr);
return XmlUtils::CreateNode(_T("p:nvPicPr"), oValue);
return XmlUtils::CreateNode(m_namespace + L":nvPicPr", oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->StartNode(_T("pic:nvPicPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:nvPicPr"));
else
pWriter->StartNode(_T("p:nvPicPr"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
pWriter->StartNode(namespace_ + L":nvPicPr");
pWriter->EndAttributes();
......@@ -113,12 +140,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX)
nvPr.toXmlWriter(pWriter);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("pic:nvPicPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:nvPicPr"));
else
pWriter->EndNode(_T("p:nvPicPr"));
pWriter->EndNode(namespace_ + L":nvPicPr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -159,11 +181,11 @@ namespace PPTX
pReader->Seek(_end_rec);
}
std::wstring m_namespace;
public:
CNvPr cNvPr;
CNvPicPr cNvPicPr;
NvPr nvPr;
CNvPr cNvPr;
CNvPicPr cNvPicPr;
NvPr nvPr;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -44,8 +44,11 @@ namespace PPTX
class NvPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(NvPr)
WritingElement_AdditionConstructors(NvPr)
NvPr()
{
}
NvPr& operator=(const NvPr& oSrc)
{
isPhoto = oSrc.isPhoto;
......@@ -58,14 +61,53 @@ namespace PPTX
return *this;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
ReadAttributes(oReader);
public:
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"ph")
ph = oReader;
else if (strName == L"extLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
Ext element;
element.fromXML(oReader);
extLst.push_back (element);
}
}
else
{
media.fromXML(oReader);
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("isPhoto"), isPhoto)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("userDrawn"), userDrawn)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
node.ReadAttributeBase(L"isPhoto", isPhoto);
node.ReadAttributeBase(L"userDrawn", userDrawn);
ph = node.ReadNode(_T("p:ph"));
ph = node.ReadNode(_T("p:ph"));
media.GetMediaFrom(node);
XmlUtils::CXmlNode list;
......@@ -191,17 +233,16 @@ namespace PPTX
pReader->Seek(_end_rec);
}
std::wstring m_namespace;
// Attributes
nullable_bool isPhoto;
nullable_bool userDrawn;
public:
// Attributes
nullable_bool isPhoto;
nullable_bool userDrawn;
//Childs
nullable<Ph> ph;
UniMedia media;
//custDataLst
std::vector<Ext> extLst;
//Childs
nullable<Ph> ph;
UniMedia media;
//custDataLst
std::vector<Ext> extLst;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -46,7 +46,12 @@ namespace PPTX
class NvSpPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(NvSpPr)
WritingElement_AdditionConstructors(NvSpPr)
NvSpPr(std::wstring ns = L"p")
{
m_namespace = ns;
}
NvSpPr& operator=(const NvSpPr& oSrc)
{
......@@ -58,10 +63,32 @@ namespace PPTX
nvPr = oSrc.nvPr;
return *this;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
public:
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("cNvPr") == strName)
cNvPr = oReader;
else if (_T("cNvSpPr") == strName)
cNvSpPr = oReader;
else if (_T("nvPr") == strName)
nvPr = oReader;
}
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
......@@ -91,15 +118,17 @@ namespace PPTX
oValue.Write(cNvSpPr);
oValue.Write(nvPr);
return XmlUtils::CreateNode(_T("p:nvSpPr"), oValue);
return XmlUtils::CreateNode(m_namespace + L":nvSpPr", oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:nvSpPr"));
else
pWriter->StartNode(_T("p:nvSpPr"));
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
pWriter->StartNode( namespace_ + L":nvSpPr");
pWriter->EndAttributes();
......@@ -109,10 +138,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX)
nvPr.toXmlWriter(pWriter);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:nvSpPr"));
else
pWriter->EndNode(_T("p:nvSpPr"));
pWriter->EndNode( namespace_ + L":nvSpPr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -154,10 +180,11 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
CNvPr cNvPr;
CNvSpPr cNvSpPr;
NvPr nvPr;
std::wstring m_namespace;
CNvPr cNvPr;
CNvSpPr cNvSpPr;
NvPr nvPr;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -44,9 +44,26 @@ namespace PPTX
class Ph : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Ph)
WritingElement_AdditionConstructors(Ph)
public:
Ph()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hasCustomPrompt"), hasCustomPrompt)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("idx"), idx)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("orient"), orient)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sz"), sz)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("type"), type)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"hasCustomPrompt", hasCustomPrompt);
......
......@@ -261,31 +261,59 @@ namespace PPTX
return sRes;
}
Pic::Pic()
Pic::Pic(std::wstring ns)
{
m_namespace = ns;
}
Pic::~Pic()
{
}
Pic::Pic(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const Pic& Pic::operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
Pic::Pic(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const Pic& Pic::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void Pic::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("nvPicPr") == strName)
nvPicPr = oReader;
else if (_T("blipFill") == strName)
blipFill = oReader;
else if (_T("spPr") == strName)
spPr = oReader;
else if (_T("style") == strName)
style = oReader;
}
FillParentPointersForChilds();
}
void Pic::fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
......@@ -327,7 +355,6 @@ namespace PPTX
FillParentPointersForChilds();
}
std::wstring Pic::toXML() const
{
XmlUtils::CNodeValue oValue;
......@@ -336,7 +363,7 @@ namespace PPTX
oValue.Write(spPr);
oValue.WriteNullable(style);
return XmlUtils::CreateNode(_T("p:pic"), oValue);
return XmlUtils::CreateNode(m_namespace + L":pic", oValue);
}
void Pic::FillParentPointersForChilds()
......
......@@ -215,13 +215,23 @@ namespace PPTX
class Pic : public WrapperWritingElement
{
public:
Pic();
Pic(std::wstring ns = L"p");
virtual ~Pic();
virtual OOX::EElementType getType () const
{
return OOX::et_a_Pic;
}
explicit Pic(XmlUtils::CXmlNode& node);
const Pic& operator =(XmlUtils::CXmlNode& node);
explicit Pic(XmlUtils::CXmlLiteReader& oReader);
const Pic& operator =(XmlUtils::CXmlLiteReader& oReader);
public:
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
virtual void GetRect(Aggplus::RECT& pRect)const;
virtual std::wstring GetFullPicName()const;
......@@ -255,16 +265,14 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring namespace_ = m_namespace;
bool bOle = false;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:pic"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
pWriter->StartNode(_T("pic:pic"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:pic"), (std::wstring)_T("http://schemas.openxmlformats.org/drawingml/2006/picture"));
}
else
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
if(oleObject.IsInit() && oleObject->isValid())
{
......@@ -301,19 +309,19 @@ namespace PPTX
pWriter->WriteString(L"<p:embed/>");
}
pWriter->StartNode(_T("p:pic"));
}
pWriter->StartNode(namespace_ + L":pic");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:pic"), (std::wstring)_T("http://schemas.openxmlformats.org/drawingml/2006/picture"));
}
pWriter->EndAttributes();
nvPicPr.toXmlWriter(pWriter);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
blipFill.m_namespace = _T("xdr");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
blipFill.m_namespace = _T("pic");
else
blipFill.m_namespace = _T("p");
blipFill.m_namespace = namespace_;
if (blipFill.blip.is_init())
blipFill.blip->m_namespace = _T("a");
......@@ -325,11 +333,10 @@ namespace PPTX
pWriter->Write(style);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:pic"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("pic:pic"));
else
pWriter->EndNode(namespace_ + L":pic");
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
pWriter->EndNode(_T("p:pic"));
if(bOle)
......@@ -337,7 +344,6 @@ namespace PPTX
pWriter->WriteString(L"</p:oleObj></a:graphicData></a:graphic></p:graphicFrame>");
}
}
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
......@@ -367,8 +373,7 @@ namespace PPTX
}
case 3:
{
style = new ShapeStyle();
style->m_ns = _T("p");
style = new ShapeStyle(L"p");
style->fromPPTY(pReader);
break;
}
......@@ -401,13 +406,13 @@ namespace PPTX
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, bool in_group = false);
void fromXMLOle(XmlUtils::CXmlNode& node);
public:
NvPicPr nvPicPr;
BlipFill blipFill;
SpPr spPr;
nullable<ShapeStyle> style;
//internal
//internal
std::wstring m_namespace;
nullable<COLEObject> oleObject;
protected:
virtual void FillParentPointersForChilds();
......
......@@ -41,8 +41,9 @@ namespace PPTX
{
namespace Logic
{
Shape::Shape()
Shape::Shape(std::wstring name_)
{
m_name = name_;
}
Shape::~Shape()
......@@ -53,15 +54,61 @@ namespace PPTX
{
fromXML(node);
}
const Shape& Shape::operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
Shape::Shape(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const Shape& Shape::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void Shape::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = oReader.GetName();
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("nvSpPr") == strName)
nvSpPr = oReader;
else if (_T("spPr") == strName)
spPr = oReader;
else if (_T("style") == strName)
style = oReader;
else if (_T("txBody") == strName)
txBody = oReader;
else if (_T("txXfrm") == strName)
txXfrm = oReader;
else if (_T("txbx") == strName || _T("textbox") == strName)
txBody = oReader;
else if (_T("cNvPr") == strName)
nvSpPr.cNvPr = oReader;
else if (_T("cNvSpPr") == strName)
nvSpPr.cNvSpPr = oReader;
else if (_T("txSp") == strName)
txBody = oReader;
else if (_T("bodyPr") == strName)
TextBoxBodyPr = oReader;
}
FillParentPointersForChilds();
}
void Shape::fromXML(XmlUtils::CXmlNode& node)
{
m_name = node.GetName();
node.ReadAttributeBase(L"useBgFill", attrUseBgFill);
XmlUtils::CXmlNodes oNodes;
......@@ -112,7 +159,6 @@ namespace PPTX
FillParentPointersForChilds();
}
std::wstring Shape::toXML() const
{
XmlUtils::CAttribute oAttr;
......@@ -124,17 +170,17 @@ namespace PPTX
oValue.WriteNullable(style);
oValue.WriteNullable(txBody);
return XmlUtils::CreateNode(_T("p:sp"), oAttr, oValue);
return XmlUtils::CreateNode(m_name, oAttr, oValue);
}
void Shape::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->StartNode(_T("wps:wsp"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:sp"));
else
pWriter->StartNode(_T("p:sp"));
std::wstring name_ = m_name;
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";
pWriter->StartNode(name_);
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("useBgFill"), attrUseBgFill);
......@@ -142,7 +188,6 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
//nvSpPr.cNvPr.toXmlWriter2(_T("wps"), pWriter);
nvSpPr.cNvSpPr.toXmlWriter2(_T("wps"), pWriter);
}
else
......@@ -166,9 +211,9 @@ namespace PPTX
if (style.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
style->m_ns = _T("wps");
style->m_namespace = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
style->m_ns = _T("xdr");
style->m_namespace = _T("xdr");
pWriter->Write(style);
}
......@@ -208,12 +253,7 @@ namespace PPTX
}
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
pWriter->EndNode(_T("wps:wsp"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:sp"));
else
pWriter->EndNode(_T("p:sp"));
pWriter->EndNode(name_);
}
void Shape::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
......@@ -257,8 +297,7 @@ namespace PPTX
}
case 2:
{
style = new ShapeStyle();
style->m_ns = _T("p");
style = new ShapeStyle(L"p");
style->fromPPTY(pReader);
break;
}
......
......@@ -275,19 +275,31 @@ namespace PPTX
class Shape : public WrapperWritingElement
{
public:
Shape();
Shape(std::wstring name_ = L"p:sp");
virtual ~Shape();
explicit Shape(XmlUtils::CXmlNode& node);
const Shape& operator =(XmlUtils::CXmlNode& node);
explicit Shape(XmlUtils::CXmlLiteReader& oReader);
const Shape& operator =(XmlUtils::CXmlLiteReader& oReader);
virtual OOX::EElementType getType () const
{
return OOX::et_p_Shape;
return OOX::et_a_Shape;
}
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("useBgFill"), attrUseBgFill)
WritingElement_ReadAttributes_End( oReader )
}
std::wstring GetText()const{if(txBody.IsInit()) return txBody->GetText(); return _T(""); };
void GetShapeFullDescription(Shape& shape, int level = 0)const;
......@@ -312,6 +324,8 @@ namespace PPTX
virtual void toXmlWriter (NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void fromPPTY (NSBinPptxRW::CBinaryFileReader* pReader);
std::wstring m_name;
NvSpPr nvSpPr;
SpPr spPr;
nullable<ShapeStyle> style;
......@@ -324,7 +338,7 @@ namespace PPTX
bool isFontRefInSlide;
mutable nullable<TextParagraphPr> body[10];
// Attributes
// Attributes
nullable_bool attrUseBgFill;
protected:
virtual void FillParentPointersForChilds();
......
......@@ -44,8 +44,12 @@ namespace PPTX
class ShapeStyle : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(ShapeStyle)
WritingElement_AdditionConstructors(ShapeStyle)
ShapeStyle(std::wstring ns = L"a")
{
m_namespace = ns;
}
ShapeStyle& operator=(const ShapeStyle& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -56,7 +60,7 @@ namespace PPTX
effectRef = oSrc.effectRef;
fontRef = oSrc.fontRef;
m_ns = oSrc.m_ns;
m_namespace = oSrc.m_namespace;
return *this;
}
......@@ -64,10 +68,33 @@ namespace PPTX
{
return OOX::et_p_style;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("lnRef") == strName)
lnRef.fromXML(oReader);
else if (_T("fillRef") == strName)
fillRef.fromXML(oReader);
else if (_T("effectRef") == strName)
effectRef.fromXML(oReader);
else if (_T("fontRef") == strName)
fontRef.fromXML(oReader);
}
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_ns = XmlUtils::GetNamespace(node.GetName());
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
......@@ -106,12 +133,12 @@ namespace PPTX
oValue.Write(effectRef);
oValue.Write(fontRef);
return XmlUtils::CreateNode(m_ns + _T(":style"), oAttr, oValue);
return XmlUtils::CreateNode(m_namespace + _T(":style"), oAttr, oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(m_ns + _T(":style"));
pWriter->StartNode(m_namespace + _T(":style"));
pWriter->EndAttributes();
lnRef.toXmlWriter(pWriter);
......@@ -119,7 +146,7 @@ namespace PPTX
effectRef.toXmlWriter(pWriter);
fontRef.toXmlWriter(pWriter);
pWriter->EndNode(m_ns + _T(":style"));
pWriter->EndNode(m_namespace + _T(":style"));
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......@@ -177,7 +204,7 @@ namespace PPTX
StyleRef effectRef;
FontRef fontRef;
mutable std::wstring m_ns;
mutable std::wstring m_namespace;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -47,8 +47,11 @@ namespace PPTX
void SmartArt::LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter)
{
FileContainer* pRels = NULL;
if (pWriter->m_pCommonRels->is_init())
pRels = pWriter->m_pCommonRels->operator ->();
if (pWriter)
{
if (pWriter->m_pCommonRels->is_init())
pRels = pWriter->m_pCommonRels->operator ->();
}
smart_ptr<OOX::File> oFileData;
smart_ptr<OOX::File> oFileDrawing;
......
......@@ -42,7 +42,11 @@ namespace PPTX
class SmartArt : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(SmartArt)
WritingElement_AdditionConstructors(SmartArt)
SmartArt()
{
}
SmartArt& operator=(const SmartArt& oSrc)
{
......@@ -52,15 +56,22 @@ namespace PPTX
m_diag = oSrc.m_diag;
return *this;
}
public:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("r:dm"), id_data )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"r:dm", id_data);
FillParentPointersForChilds();
}
virtual std::wstring toXML() const
{
return _T("");
......@@ -86,48 +97,37 @@ namespace PPTX
pReader->SkipRecord();
}
public:
nullable<OOX::RId> id_data;
nullable<OOX::RId> id_data;
nullable<PPTX::Logic::SpTree> m_diag;
smart_ptr<PPTX::CCommonRels> m_oCommonRels;
protected:
virtual void FillParentPointersForChilds()
{
LoadDrawing();
if(m_diag.IsInit())
m_diag->SetParentPointer(this);
}
public:
void LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter);
void LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter = NULL);
};
class ChartRec : public WrapperWritingElement
{
public:
WritingElement_AdditionConstructors(ChartRec)
ChartRec()
{
m_bData = false;
m_lChartNumber = 0;
}
virtual ~ChartRec()
{
}
explicit ChartRec(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const ChartRec& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
ChartRec(const ChartRec& oSrc)
{
*this = oSrc;
}
ChartRec& operator=(const ChartRec& oSrc)
{
parentFile = oSrc.parentFile;
......@@ -135,8 +135,18 @@ namespace PPTX
return *this;
}
public:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("r:id"), id_data )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_bData = false;
ReadAttributes( oReader );
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_bData = false;
......@@ -144,8 +154,6 @@ namespace PPTX
node.ReadAttributeBase(L"r:id", id_data);
FillParentPointersForChilds();
}
virtual std::wstring toXML() const
{
return _T("");
......@@ -156,12 +164,10 @@ namespace PPTX
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
public:
nullable<OOX::RId> id_data;
nullable<OOX::RId> id_data;
LONG m_lChartNumber;
bool m_bData;
LONG m_lChartNumber;
bool m_bData;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -39,9 +39,9 @@ namespace PPTX
{
namespace Logic
{
SpPr::SpPr()
SpPr::SpPr(std::wstring ns)
{
m_namespace = ns;
Fill.m_type = UniFill::notInit;
}
SpPr::~SpPr()
......
......@@ -52,8 +52,9 @@ namespace PPTX
class SpPr : public WrapperWritingElement
{
public:
SpPr();
virtual ~SpPr();
SpPr(std::wstring ns = L"a");
virtual ~SpPr();
explicit SpPr(XmlUtils::CXmlNode& node);
const SpPr& operator =(XmlUtils::CXmlNode& node);
......
......@@ -49,7 +49,11 @@ namespace PPTX
class SpTree : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(SpTree)
WritingElement_AdditionConstructors(SpTree)
SpTree()
{
}
SpTree& operator=(const SpTree& oSrc)
{
......@@ -70,7 +74,43 @@ namespace PPTX
{
return OOX::et_p_ShapeTree;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = oReader.GetName();
SpTreeElems.clear();
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"nvGrpSpPr")
nvGrpSpPr.fromXML(oReader);
else if (strName == L"grpSpPr")
grpSpPr.fromXML(oReader);
else if (_T("cNvPr") == strName)
{
nvGrpSpPr.cNvPr = oReader;
}
else if (_T("cNvGrpSpPr") == strName)
{
nvGrpSpPr.cNvGrpSpPr = oReader;
}
else
{
SpTreeElem elem(oReader);
if (elem.is_init())
SpTreeElems.push_back(elem);
}
}
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_name = node.GetName();
......@@ -256,9 +296,8 @@ namespace PPTX
Logic::NvGrpSpPr nvGrpSpPr;
Logic::GrpSpPr grpSpPr;
std::vector<SpTreeElem> SpTreeElems;
//private:
public:
std::wstring m_name;
std::wstring m_name;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -180,7 +180,6 @@ namespace PPTX
}
*/
}
void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme,
NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle)
{
......@@ -213,30 +212,65 @@ namespace PPTX
strAttr += s;
}
}
SpTreeElem::SpTreeElem()
{
}
SpTreeElem::~SpTreeElem()
{
}
SpTreeElem::SpTreeElem(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const SpTreeElem& SpTreeElem::operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
SpTreeElem::SpTreeElem(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const SpTreeElem& SpTreeElem::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void SpTreeElem::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName());
if (name == _T("sp") || name == _T("wsp"))
m_elem.reset(new Logic::Shape(oReader));
else if (name == _T("pic"))
m_elem.reset(new Logic::Pic(oReader));
else if (name == _T("cxnSp"))
m_elem.reset(new Logic::CxnSp(oReader));
else if (name == _T("grpSp") || name == _T("wgp") || name == _T("spTree") || name == _T("lockedCanvas"))
m_elem.reset(new Logic::SpTree(oReader));
else if (name == _T("graphicFrame"))
m_elem.reset(new Logic::GraphicFrame(oReader));
else if (name == _T("AlternateContent"))
{
bool isEmpty = true;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = oReader.GetName();
if (strName == L"mc:Choice")
{
//GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires)
fromXML(oReader);
break;
}
else if (strName == L"mc:Fallback")
{
fromXML(oReader);
}
}
}
else m_elem.reset();
}
void SpTreeElem::fromXML(XmlUtils::CXmlNode& node)
{
std::wstring name = XmlUtils::GetNameNoNS(node.GetName());
......
......@@ -51,17 +51,28 @@ namespace PPTX
public:
SpTreeElem();
virtual ~SpTreeElem();
virtual OOX::EElementType getType () const
{
if (m_elem.IsInit())
return m_elem->getType();
return OOX::et_Unknown;
}
explicit SpTreeElem(XmlUtils::CXmlNode& node);
const SpTreeElem& operator =(XmlUtils::CXmlNode& node);
explicit SpTreeElem(XmlUtils::CXmlLiteReader& oReader);
const SpTreeElem& operator =(XmlUtils::CXmlLiteReader& oReader);
SpTreeElem& operator=(const SpTreeElem& oSrc)
{
m_elem = oSrc.m_elem;
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
virtual bool is_init() const {return (m_elem.IsInit());}
......
......@@ -44,9 +44,33 @@ namespace PPTX
class StyleRef : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(StyleRef)
WritingElement_AdditionConstructors(StyleRef)
public:
StyleRef()
{
}
virtual OOX::EElementType getType () const
{
return OOX::et_Unknown;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = oReader.GetName();
ReadAttributes( oReader );
Color.fromXMLParent(oReader);
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("idx"), idx )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_name = node.GetName();
......
......@@ -45,7 +45,11 @@ namespace PPTX
class Table : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Table)
WritingElement_AdditionConstructors(Table)
Table()
{
}
Table& operator=(const Table& oSrc)
{
......@@ -58,8 +62,6 @@ namespace PPTX
tableProperties = oSrc.tableProperties;
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oNode;
......@@ -72,7 +74,41 @@ namespace PPTX
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"tblGrid")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring strName1 = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName1 == L"gridCol")
{
TableCol col;
TableCols.push_back(col);
TableCols.back().fromXML(oReader);
}
}
}
else if (strName == L"tblPr")
tableProperties = oReader;
else if (strName == L"tr")
{
TableRow tr;
TableRows.push_back(tr);
TableRows.back().fromXML(oReader);
}
}
FillParentPointersForChilds();
}
virtual std::wstring toXML() const
{
XmlUtils::CNodeValue oValue;
......@@ -158,7 +194,6 @@ namespace PPTX
pWriter->EndNode(_T("a:tbl"));
}
public:
std::vector<TableCol> TableCols;
std::vector<TableRow> TableRows;
nullable<TableProperties> tableProperties;
......
......@@ -41,26 +41,62 @@ namespace PPTX
TableCell::TableCell()
{
}
TableCell::~TableCell()
{
}
TableCell::TableCell(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const TableCell& TableCell::operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
TableCell::TableCell(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const TableCell& TableCell::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void TableCell::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rowSpan"), RowSpan)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gridSpan"), GridSpan)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("hMerge"), HMerge)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("vMerge"), VMerge)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("id"), Id)
WritingElement_ReadAttributes_End( oReader )
}
void TableCell::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"txBody")
txBody = oReader;
else if (strName == L"tcPr")
CellProperties = oReader;
}
FillParentPointersForChilds();
}
void TableCell::fromXML(XmlUtils::CXmlNode& node)
{
txBody = node.ReadNodeNoNS(_T("txBody"));
CellProperties = node.ReadNode(_T("a:tcPr"));
node.ReadAttributeBase(L"rowSpan", RowSpan);
node.ReadAttributeBase(L"gridSpan", GridSpan);
node.ReadAttributeBase(L"hMerge", HMerge);
......
......@@ -47,11 +47,18 @@ namespace PPTX
public:
TableCell();
virtual ~TableCell();
explicit TableCell(XmlUtils::CXmlNode& node);
const TableCell& operator =(XmlUtils::CXmlNode& node);
public:
explicit TableCell(XmlUtils::CXmlLiteReader& oReader);
const TableCell& operator =(XmlUtils::CXmlLiteReader& oReader);
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
virtual void GetShapeProperties(ShapeProperties& props)const;
......
......@@ -48,7 +48,11 @@ namespace PPTX
class TableCellProperties : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(TableCellProperties)
WritingElement_AdditionConstructors(TableCellProperties)
TableCellProperties()
{
}
TableCellProperties& operator=(const TableCellProperties& oSrc)
{
......@@ -74,8 +78,49 @@ namespace PPTX
HorzOverflow = oSrc.HorzOverflow;
return *this;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
public:
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = oReader.GetName();
if (_T("a:lnL") == strName)
LnL = oReader;
else if (_T("a:lnR") == strName)
LnR = oReader;
else if (_T("a:lnT") == strName)
LnT = oReader;
else if (_T("a:lnB") == strName)
LnB = oReader;
else if (_T("a:cell3D") == strName)
cell3D = oReader;
else if (_T("a:lnBlToTr") == strName)
LnTlToBr = oReader;
else if (_T("a:lnBlToTr") == strName)
LnBlToTr = oReader;
else
Fill.fromXML(oReader);
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("marL"), MarL )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("marR"), MarR )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("marT"), MarT )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("marB"), MarB )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("vert"), Vert )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("anchor"), Anchor )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("anchorCtr"), AnchorCtr )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("horzOverflow"), HorzOverflow )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
LnL = node.ReadNode(_T("a:lnL"));
......
......@@ -42,7 +42,11 @@ namespace PPTX
class TableCol : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(TableCol)
WritingElement_AdditionConstructors(TableCol)
TableCol()
{
}
TableCol& operator=(const TableCol& oSrc)
{
......@@ -52,8 +56,16 @@ namespace PPTX
Width = oSrc.Width;
return *this;
}
public:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("w"), Width)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
Width = node.ReadAttributeInt(L"w");
......@@ -61,7 +73,7 @@ namespace PPTX
virtual std::wstring toXML() const
{
return L"<a:gridCol w=\"" + std::to_wstring(Width) + L"\"/>";
return L"<a:gridCol w=\"" + std::to_wstring(Width.get_value_or(0)) + L"\"/>";
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
......@@ -78,7 +90,7 @@ namespace PPTX
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteInt1(0, Width);
pWriter->WriteInt2(0, Width);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
}
......@@ -107,8 +119,7 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
int Width;
nullable_int Width;
protected:
virtual void FillParentPointersForChilds(){};
};
......
......@@ -44,7 +44,11 @@ namespace PPTX
class TableProperties : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(TableProperties)
WritingElement_AdditionConstructors(TableProperties)
TableProperties()
{
}
TableProperties& operator=(const TableProperties& oSrc)
{
......@@ -65,8 +69,52 @@ namespace PPTX
return *this;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
public:
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = oReader.GetName();
if (strName == L"a:tableStyleId")
{
TableStyleId = oReader.GetText2();
}
else if ( L"a:blipFill" == strName ||
L"a:gradFill" == strName ||
L"a:grpFill" == strName ||
L"a:noFill" == strName ||
L"a:pattFill" == strName ||
L"a:solidFill"== strName )
{
Fill.fromXML(oReader);
}
else if ( L"a:effectDag" == strName ||
L"a:effectLst" == strName ||
L"a:extLst" == strName )
{
Effects.fromXML(oReader);
}
}
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rtl"), Rtl)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("firstRow"), FirstRow)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("firstCol"), FirstCol)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lastRow"), LastRow)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lastCol"), LastCol)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("bandRow"), BandRow)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("bandCol"), BandCol)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
Fill.GetFillFrom(node);
......
......@@ -43,7 +43,11 @@ namespace PPTX
class TableRow : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(TableRow)
WritingElement_AdditionConstructors(TableRow)
TableRow()
{
}
TableRow& operator=(const TableRow& oSrc)
{
......@@ -56,7 +60,32 @@ namespace PPTX
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"tc")
{
TableCell c;
Cells.push_back(c);
Cells.back().fromXML(oReader);
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("h"), Height)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
Height = node.ReadAttributeInt(L"h");
......@@ -92,7 +121,7 @@ namespace PPTX
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteInt1(0, Height);
pWriter->WriteInt2(0, Height);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->WriteRecordArray(0, 1, Cells);
......@@ -146,8 +175,7 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
int Height;
nullable_int Height;
std::vector<TableCell> Cells;
protected:
virtual void FillParentPointersForChilds()
......
......@@ -45,9 +45,29 @@ namespace PPTX
class UniMedia : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(UniMedia)
WritingElement_AdditionConstructors(UniMedia)
public:
UniMedia()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName());
if (name == _T("audioCd"))
Media.reset(new Logic::AudioCD(oReader));
else if (name == _T("wavAudioFile"))
Media.reset(new Logic::WavAudioFile(oReader));
else if (name == _T("audioFile"))
Media.reset(new Logic::MediaFile(oReader));
else if (name == _T("videoFile"))
Media.reset(new Logic::MediaFile(oReader));
else if (name == _T("quickTimeFile"))
Media.reset(new Logic::MediaFile(oReader));
else Media.reset();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
std::wstring name = XmlUtils::GetNameNoNS(node.GetName());
......
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