Commit 24e55018 authored by Oleg Korshul's avatar Oleg Korshul

.

parent 2352ae5d
......@@ -99,7 +99,7 @@ public:
std::wstring GetRelsReference(const std::wstring& file)
{
COOXMLRelationships oRels(m_sFolder + file);
COOXMLRelationships oRels(m_sFolder + file, true);
if (L"/_rels/.rels" == file)
{
......
......@@ -67,12 +67,35 @@ public:
{
}
COOXMLRelationships(const std::wstring& file, std::map<std::wstring, bool>* check_need = NULL)
COOXMLRelationships(const std::string& xml, std::map<std::wstring, bool>* check_need = NULL)
{
XmlUtils::CXmlNode oNode;
if (!oNode.FromXmlFile(file))
if (!oNode.FromXmlStringA(xml))
return;
FromXmlNode(oNode, check_need);
}
COOXMLRelationships(const std::wstring& xml, const bool& is_file, std::map<std::wstring, bool>* check_need = NULL)
{
XmlUtils::CXmlNode oNode;
if (!is_file)
{
if (!oNode.FromXmlString(xml))
return;
}
else
{
if (!oNode.FromXmlFile(xml))
return;
}
FromXmlNode(oNode, check_need);
}
void FromXmlNode(XmlUtils::CXmlNode& oNode, std::map<std::wstring, bool>* check_need = NULL)
{
XmlUtils::CXmlNodes oNodes;
if (!oNode.GetNodes(L"Relationship", oNodes))
return;
......
......@@ -20,6 +20,8 @@ public:
public:
virtual std::string Transform(const std::string& sXml) = 0;
virtual void LoadFromXml(XmlUtils::CXmlNode& node) = 0;
static IXmlTransform* GetFromType(const std::string& alg);
};
class CXmlTransformRelationship : public IXmlTransform
......@@ -33,9 +35,9 @@ public:
m_algorithm = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
}
virtual std::string Transform(const std::wstring& sFile)
virtual std::string Transform(const std::string& xml)
{
COOXMLRelationships _rels(sFile, &m_arIds);
COOXMLRelationships _rels(xml, &m_arIds);
return U_TO_UTF8(_rels.GetXml());
}
......@@ -57,4 +59,86 @@ public:
}
};
class CXmlTransformC14N : public IXmlTransform
{
protected:
int m_mode;
bool m_comments;
public:
CXmlTransformC14N() : IXmlTransform()
{
m_mode = -1;
m_comments = false;
}
bool CheckC14NTransform(const std::string& alg)
{
m_mode = -1;
if ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315" == alg)
{
m_mode = XML_C14N_1_0;
m_comments = false;
}
else if ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" == alg)
{
m_mode = XML_C14N_1_0;
m_comments = true;
}
else if ("http://www.w3.org/2006/12/xml-c14n11" == alg)
{
m_mode = XML_C14N_1_1;
m_comments = false;
}
else if ("http://www.w3.org/2006/12/xml-c14n11#WithComments" == alg)
{
m_mode = XML_C14N_1_1;
m_comments = true;
}
else if ("http://www.w3.org/2001/10/xml-exc-c14n#" == alg)
{
m_mode = XML_C14N_EXCLUSIVE_1_0;
m_comments = false;
}
else if ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments" == alg)
{
m_mode = XML_C14N_EXCLUSIVE_1_0;
m_comments = true;
}
return (-1 != m_mode) ? true : false;
}
virtual std::string Transform(const std::string& xml)
{
// TODO
return xml;
}
virtual void LoadFromXml(XmlUtils::CXmlNode& node)
{
// none
XML_UNUSED(node);
}
};
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg)
{
if (true)
{
CXmlTransformRelationship* transform = new CXmlTransformRelationship();
if (transform->m_algorithm == alg)
return transform;
RELEASEOBJECT(transform);
}
if (true)
{
CXmlTransformC14N* transform = new CXmlTransformC14N();
if (transform->CheckC14NTransform(alg))
return transform;
RELEASEOBJECT(transform);
}
return NULL;
}
#endif //_XML_TRANSFORM_H_
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