Commit 7f6611ab authored by ElenaSubbotina's avatar ElenaSubbotina

..

parent bb37e348
......@@ -38,7 +38,7 @@
#include "../../DocxFormat/IFileContainer.h"
#include <map>
#include <unordered_map>
namespace OOX
{
......@@ -74,7 +74,7 @@ namespace OOX
return m_nRow.IsInit() && m_nCol.IsInit() && m_sAuthor.IsInit();
}
};
class CAuthors : public WritingElementWithChilds<std::wstring>
class CAuthors : public WritingElement
{
public:
WritingElement_AdditionConstructors(CAuthors)
......@@ -87,7 +87,7 @@ namespace OOX
}
virtual void ClearItems()
{
m_arrItems.clear();
m_mapItems.clear();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
......@@ -100,15 +100,12 @@ namespace OOX
{
writer.WriteString(L"<authors>");
for ( SpreadsheetElemArray::const_iterator it = m_arrItems.begin(); it != m_arrItems.end(); it++)
{
if ( *it )
for ( std::unordered_map<int, std::wstring>::const_iterator it = m_mapItems.begin(); it != m_mapItems.end(); it++)
{
writer.WriteString(L"<author>");
writer.WriteEncodeXmlString(*(*it));
writer.WriteEncodeXmlString(it->second);
writer.WriteString(L"</author>");
}
}
writer.WriteString(L"</authors>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
......@@ -118,6 +115,8 @@ namespace OOX
if ( oReader.IsEmptyNode() )
return;
int index = 0;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
......@@ -125,8 +124,7 @@ namespace OOX
if ( L"author" == sName )
{
std::wstring *str = new std::wstring(oReader.GetText3());
m_arrItems.push_back(str);
m_mapItems.insert(std::make_pair(index++, oReader.GetText3()));
}
}
}
......@@ -140,6 +138,8 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
std::unordered_map<int, std::wstring> m_mapItems;
};
class CComment : public WritingElement
{
......
......@@ -189,7 +189,7 @@ namespace OOX
}
void PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::CVmlDrawing* pVmlDrawing)
{
std::list<std::wstring*> & aAuthors = pComments->m_oAuthors->m_arrItems;
std::unordered_map<int, std::wstring> & mapAuthors = pComments->m_oAuthors->m_mapItems;
if(pComments->m_oCommentList.IsInit())
{
......@@ -212,12 +212,12 @@ namespace OOX
unsigned int nAuthorId = pComment->m_oAuthorId->GetValue();
std::list<std::wstring*>::iterator itA = aAuthors.begin();
for(int a = 0; a < nAuthorId; a++)
itA++;
std::unordered_map<int, std::wstring>::iterator pFind = mapAuthors.find(nAuthorId);
if(itA != aAuthors.end())
pCommentItem->m_sAuthor = *itA;
if (pFind != mapAuthors.end())
{
pCommentItem->m_sAuthor = pFind->second;
}
OOX::Spreadsheet::CSi* pSi = pComment->m_oText.GetPointerEmptyNullable();
if(NULL != pSi)
......
......@@ -2535,14 +2535,14 @@ namespace BinXlsxRW {
{
m_pCurVmlDrawing->m_mapComments = &m_pCurWorksheet->m_mapComments;
std::map<std::wstring, unsigned int> mapAuthors;
std::map<std::wstring, unsigned int> mapByAuthors;
OOX::Spreadsheet::CComments* pComments = new OOX::Spreadsheet::CComments();
pComments->m_oCommentList.Init();
std::list<OOX::Spreadsheet::CComment*>& aComments = pComments->m_oCommentList->m_arrItems;
pComments->m_oAuthors.Init();
std::list<std::wstring*>& aAuthors = pComments->m_oAuthors->m_arrItems;
std::unordered_map<int, std::wstring> & mapByIndex = pComments->m_oAuthors->m_mapItems;
for (std::map<std::wstring, OOX::Spreadsheet::CCommentItem*>::const_iterator it = m_pCurWorksheet->m_mapComments.begin(); it != m_pCurWorksheet->m_mapComments.end(); ++it)
{
......@@ -2559,15 +2559,18 @@ namespace BinXlsxRW {
if(pCommentItem->m_sAuthor.IsInit())
{
const std::wstring& sAuthor = pCommentItem->m_sAuthor.get();
std::map<std::wstring, unsigned int>::const_iterator pair = mapAuthors.find(sAuthor);
std::map<std::wstring, unsigned int>::const_iterator pFind = mapByAuthors.find(sAuthor);
int nAuthorId;
if(mapAuthors.end() != pair)
nAuthorId = (int)pair->second;
if(pFind != mapByAuthors.end())
nAuthorId = pFind->second;
else
{
nAuthorId = (int)mapAuthors.size();
mapAuthors[sAuthor] = nAuthorId;
aAuthors.push_back(new std::wstring(sAuthor));
nAuthorId = (int)mapByAuthors.size();
mapByAuthors.insert(std::make_pair(sAuthor, nAuthorId));
mapByIndex.insert(std::make_pair(nAuthorId, sAuthor));
}
pNewComment->m_oAuthorId.Init();
pNewComment->m_oAuthorId->SetValue(nAuthorId);
......
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