This commit is contained in:
Elena.Subbotina
2023-03-29 10:44:09 +03:00
parent 5ed129e7ae
commit baaf79a5dd
10 changed files with 121 additions and 145 deletions

View File

@ -188,12 +188,11 @@ public:
XmlUtils::CXmlNode oNodeRels = m_pFolder->getNodeFromFile(*iter);
if (!oNodeRels.IsValid())
continue;
XmlUtils::CXmlNodes oNodesRels = oNodeRels.GetNodes(L"Relationship");
int nCount = oNodesRels.GetCount();
for (int nIndex = 0; nIndex < nCount; nIndex++)
std::vector<XmlUtils::CXmlNode> oNodesRels = oNodeRels.GetNodes(L"Relationship");
size_t nCount = oNodesRels.size();
for (size_t nIndex = 0; nIndex < nCount; nIndex++)
{
XmlUtils::CXmlNode oNodeRel;
oNodesRels.GetAt(nIndex, oNodeRel);
XmlUtils::CXmlNode & oNodeRel = oNodesRels[nIndex];
std::wstring sTarget = oNodeRel.GetAttribute(L"Target");
if (!sTarget.empty() && arSigFiles.find(sTarget) == arSigFiles.end() && m_pFolder->exists(folder + L"/" + sTarget))
@ -261,26 +260,24 @@ public:
{
XmlUtils::CXmlNode oNode = m_pFolder->getNodeFromFile(L"/[Content_Types].xml");
XmlUtils::CXmlNodes nodesDefaults;
std::vector<XmlUtils::CXmlNode> nodesDefaults;
oNode.GetNodes(L"Default", nodesDefaults);
XmlUtils::CXmlNodes nodesOverrides;
std::vector<XmlUtils::CXmlNode> nodesOverrides;
oNode.GetNodes(L"Override", nodesOverrides);
int nCount = nodesDefaults.GetCount();
for (int i = 0; i < nCount; ++i)
size_t nCount = nodesDefaults.size();
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode node;
nodesDefaults.GetAt(i, node);
XmlUtils::CXmlNode & node = nodesDefaults[i];
m_content_types.insert(std::pair<std::wstring, std::wstring>(node.GetAttribute("Extension"), node.GetAttribute("ContentType")));
}
nCount = nodesOverrides.GetCount();
for (int i = 0; i < nCount; ++i)
nCount = nodesOverrides.size();
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode node;
nodesOverrides.GetAt(i, node);
XmlUtils::CXmlNode & node = nodesOverrides[i];
m_content_types.insert(std::pair<std::wstring, std::wstring>(node.GetAttribute("PartName"), node.GetAttribute("ContentType")));
}
@ -393,13 +390,12 @@ public:
oBuilder.WriteNodeEnd(oNode.GetName(), true, false);
XmlUtils::CXmlNodes oNodes = oNode.GetNodes(L"*");
std::vector<XmlUtils::CXmlNode> oNodes = oNode.GetNodes(L"*");
int nCountNodes = oNodes.GetCount();
for (int nIndex = 0; nIndex < nCountNodes; ++nIndex)
size_t nCountNodes = oNodes.size();
for (size_t nIndex = 0; nIndex < nCountNodes; ++nIndex)
{
XmlUtils::CXmlNode oCurrentRecord;
oNodes.GetAt(nIndex, oCurrentRecord);
XmlUtils::CXmlNode & oCurrentRecord = oNodesnIndex[];
if (L"Default" == oCurrentRecord.GetName() && oCurrentRecord.GetAttributeA("Extension") == "sigs")
continue;

View File

@ -87,14 +87,14 @@ public:
if (oBuilder.GetCurSize() != 1)
ret.m_namespaces += oBuilder.GetData();
XmlUtils::CXmlNodes oNodes;
std::vector<XmlUtils::CXmlNode> oNodes;
if (stack.m_node.GetChilds(oNodes))
{
int nCount = oNodes.GetCount();
size_t nCount = oNodes.size();
for (int i = 0; i < nCount; i++)
for (size_t i = 0; i < nCount; i++)
{
oNodes.GetAt(i, ret.m_node);
ret.m_node = oNodes[i];
CXmlStackNamespaces _retRecursion = ret.GetByIdRec(ret, id, isNameUse);
if (_retRecursion.m_node.IsValid())
return _retRecursion;
@ -228,12 +228,11 @@ public:
if (!sDateW.empty())
m_sDate = U_TO_UTF8(sDateW);
XmlUtils::CXmlNodes nodesManifestRefs = nodeManifect.ReadNode(L"Manifest").GetNodes(L"Reference");
int nRefsCount = nodesManifestRefs.GetCount();
for (int i = 0; i < nRefsCount; i++)
std::vector<XmlUtils::CXmlNode> nodesManifestRefs = nodeManifect.ReadNode(L"Manifest").GetNodes(L"Reference");
size_t nRefsCount = nodesManifestRefs.size();
for (size_t i = 0; i < nRefsCount; i++)
{
XmlUtils::CXmlNode tmp;
nodesManifestRefs.GetAt(i, tmp);
XmlUtils::CXmlNode &tmp = nodesManifestRefs[i];
m_valid = CheckManifestReference(tmp);
if (OOXML_SIGNATURE_VALID != m_valid)
@ -241,13 +240,12 @@ public:
}
// 4) Objects
XmlUtils::CXmlNodes nodesReferences;
std::vector<XmlUtils::CXmlNode> nodesReferences;
m_node.ReadNode(L"SignedInfo").GetNodes(L"Reference", nodesReferences);
nRefsCount = nodesReferences.GetCount();
for (int i = 0; i < nRefsCount; i++)
nRefsCount = nodesReferences.size();
for (size_t i = 0; i < nRefsCount; i++)
{
XmlUtils::CXmlNode tmp;
nodesReferences.GetAt(i, tmp);
XmlUtils::CXmlNode &tmp = nodesReferences[i];
m_valid = CheckObjectReference(tmp);
if (OOXML_SIGNATURE_VALID != m_valid)
@ -295,12 +293,11 @@ public:
XmlUtils::CXmlNode GetObjectById(std::string sId)
{
XmlUtils::CXmlNodes oNodes = m_node.GetNodes(L"Object");
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; i++)
std::vector<XmlUtils::CXmlNode> oNodes = m_node.GetNodes(L"Object");
size_t nCount = oNodes.size();
for (size_t i = 0; i < nCount; i++)
{
XmlUtils::CXmlNode tmp;
oNodes.GetAt(i, tmp);
XmlUtils::CXmlNode &tmp = oNodes[i];
if (sId == tmp.GetAttributeA("Id"))
return tmp;
}
@ -310,12 +307,11 @@ public:
XmlUtils::CXmlNode GetObjectSignedProperties()
{
XmlUtils::CXmlNodes oNodes = m_node.GetNodes(L"Object");
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; i++)
std::vector<XmlUtils::CXmlNode> oNodes = m_node.GetNodes(L"Object");
size_t nCount = oNodes.size();
for (size_t i = 0; i < nCount; i++)
{
XmlUtils::CXmlNode tmp;
oNodes.GetAt(i, tmp);
XmlUtils::CXmlNode &tmp = oNodes[i];
XmlUtils::CXmlNode nodeQ = tmp.ReadNodeNoNS(L"QualifyingProperties");
if (nodeQ.IsValid())
@ -332,14 +328,13 @@ public:
if (node.GetName() == sName)
return node;
XmlUtils::CXmlNodes childs;
std::vector<XmlUtils::CXmlNode> childs;
if (node.GetChilds(childs))
{
int nCount = childs.GetCount();
for (int i = 0; i < nCount; i++)
size_t nCount = childs.size();
for (size_t i = 0; i < nCount; i++)
{
XmlUtils::CXmlNode child;
childs.GetAt(i, child);
XmlUtils::CXmlNode &child = childs[i];
XmlUtils::CXmlNode ret = FindFirstChild(child, sName);
if (ret.IsValid())
@ -600,13 +595,12 @@ public:
if (!oContentTypes.IsValid())
return;
XmlUtils::CXmlNodes oOverrides = oContentTypes.GetNodes(L"Override");
int nCount = oOverrides.GetCount();
std::vector<XmlUtils::CXmlNode> oOverrides = oContentTypes.GetNodes(L"Override");
size_t nCount = oOverrides.size();
for (int i = 0; i < nCount; i++)
for (size_t i = 0; i < nCount; i++)
{
XmlUtils::CXmlNode node;
oOverrides.GetAt(i, node);
XmlUtils::CXmlNode &node = oOverrides[i];
if (node.GetAttributeA("ContentType") != "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml")
continue;
@ -676,15 +670,14 @@ public:
XmlUtils::CXmlNode oContentTypes = m_pFolder->getNodeFromFile(L"[Content_Types].xml");
std::wstring sXml = L"<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n";
XmlUtils::CXmlNodes oNodes;
std::vector<XmlUtils::CXmlNode> oNodes;
if (oContentTypes.GetNodes(L"*", oNodes))
{
int nCount = oNodes.GetCount();
size_t nCount = oNodes.size();
for (int i = 0; i < nCount; ++i)
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
XmlUtils::CXmlNode &oNode = oNodes[i];
if (bIsRemoveAll)
{
@ -722,15 +715,14 @@ public:
return;
sXml = L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">";
XmlUtils::CXmlNodes oNodes;
std::vector<XmlUtils::CXmlNode> oNodes;
if (oRels.GetNodes(L"*", oNodes))
{
int nCount = oNodes.GetCount();
size_t nCount = oNodes.size();
for (int i = 0; i < nCount; ++i)
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
XmlUtils::CXmlNode &oNode = oNodes[i];
if (L"Relationship" == oNode.GetName() &&
L"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin" == oNode.GetAttribute(L"Type"))
@ -756,15 +748,14 @@ public:
return;
sXml = L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">";
XmlUtils::CXmlNodes oNodes;
std::vector<XmlUtils::CXmlNode> oNodes;
if (oRels.GetNodes(L"*", oNodes))
{
int nCount = oNodes.GetCount();
size_t nCount = oNodes.size();
for (int i = 0; i < nCount; ++i)
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
XmlUtils::CXmlNode &oNode = oNodes[i];
if (L"Relationship" == oNode.GetName() &&
L"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature" == oNode.GetAttribute(L"Type") &&

View File

@ -107,15 +107,14 @@ public:
void FromXmlNode(XmlUtils::CXmlNode& oNode, std::map<std::wstring, bool>* check_need = NULL)
{
XmlUtils::CXmlNodes oNodes;
std::vector<XmlUtils::CXmlNode> oNodes;
if (!oNode.GetNodes(L"Relationship", oNodes))
return;
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
size_t nCount = oNodes.size();
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oRel;
oNodes.GetAt(i, oRel);
XmlUtils::CXmlNode &oRel = oNodes[i];
if (NULL == check_need)
{

View File

@ -43,14 +43,13 @@ public:
virtual void LoadFromXml(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNodes oNodesIds;
std::vector<XmlUtils::CXmlNode> oNodesIds;
node.GetChilds(oNodesIds);
int nCount = oNodesIds.GetCount();
for (int i = 0; i < nCount; ++i)
size_t nCount = oNodesIds.size();
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode _node;
oNodesIds.GetAt(i, _node);
XmlUtils::CXmlNode& _node = oNodesIds[i];
std::wstring sType = _node.GetAttribute("SourceId");
if (!sType.empty())
@ -138,12 +137,11 @@ public:
{
m_valid = true;
XmlUtils::CXmlNodes oNodes = node.GetNodes(L"Transform");
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
std::vector<XmlUtils::CXmlNode> oNodes = node.GetNodes(L"Transform");
size_t nCount = oNodes.size();
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode nodeTransform;
oNodes.GetAt(i, nodeTransform);
XmlUtils::CXmlNode &nodeTransform = oNodes[i];
IXmlTransform* pTransform = IXmlTransform::GetFromType(nodeTransform.GetAttributeA("Algorithm"));
if (NULL == pTransform)