mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-18 14:37:12 +08:00
Compare commits
14 Commits
core-win-3
...
core-win-6
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a3a73d0ec | |||
| 5a82c47fa0 | |||
| 65f7a4a170 | |||
| 413424bf62 | |||
| 01499a21f3 | |||
| a9215a867b | |||
| e9fd8205fa | |||
| f30a3c4ae8 | |||
| 615179f9da | |||
| f0fdf9f86e | |||
| 14921ca98d | |||
| 4894639c09 | |||
| 3727c2e982 | |||
| a5122a6a47 |
@ -41,6 +41,8 @@ namespace Writers
|
||||
static std::wstring g_string_comment_End = _T("</w:comments>");
|
||||
static std::wstring g_string_commentExt_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w15:commentsEx xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\">");
|
||||
static std::wstring g_string_commentExt_End = _T("</w15:commentsEx>");
|
||||
static std::wstring g_string_commentsIds_Start = _T("<w16cid:commentsIds mc:Ignorable=\"w16cid\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\">");
|
||||
static std::wstring g_string_commentsIds_End = _T("</w16cid:commentsIds>");
|
||||
static std::wstring g_string_people_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w15:people xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\">");
|
||||
static std::wstring g_string_people_End = _T("</w15:people>");
|
||||
|
||||
@ -50,21 +52,25 @@ namespace Writers
|
||||
public:
|
||||
std::wstring m_sComment;
|
||||
std::wstring m_sCommentExt;
|
||||
std::wstring m_sCommentsIds;
|
||||
std::wstring m_sPeople;
|
||||
std::wstring m_sDocumentComment;
|
||||
std::wstring m_sDocumentCommentExt;
|
||||
std::wstring m_sDocumentCommentsIds;
|
||||
std::wstring m_sDocumentPeople;
|
||||
|
||||
CommentsWriter(std::wstring sDir) : m_sDir(sDir)
|
||||
{
|
||||
}
|
||||
void setElements(std::wstring& sComment, std::wstring& sCommentExt, std::wstring& sPeople, std::wstring& sDocumentComment, std::wstring& sDocumentCommentExt, std::wstring& sDocumentPeople)
|
||||
void setElements(std::wstring& sComment, std::wstring& sCommentExt, std::wstring& sCommentsIds, std::wstring& sPeople, std::wstring& sDocumentComment, std::wstring& sDocumentCommentExt, std::wstring& sDocumentCommentsIds, std::wstring& sDocumentPeople)
|
||||
{
|
||||
m_sComment = sComment;
|
||||
m_sCommentExt = sCommentExt;
|
||||
m_sCommentsIds = sCommentsIds;
|
||||
m_sPeople = sPeople;
|
||||
m_sDocumentComment = sDocumentComment;
|
||||
m_sDocumentCommentExt = sDocumentCommentExt;
|
||||
m_sDocumentCommentsIds = sDocumentCommentsIds;
|
||||
m_sDocumentPeople = sDocumentPeople;
|
||||
}
|
||||
void Write()
|
||||
@ -90,6 +96,15 @@ namespace Writers
|
||||
oFile.WriteStringUTF8(g_string_commentExt_End);
|
||||
oFile.CloseFile();
|
||||
}
|
||||
if(false == m_sCommentsIds.empty())
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(sDir + OOX::FileTypes::CommentsIds.DefaultFileName().GetPath());
|
||||
oFile.WriteStringUTF8(g_string_commentsIds_Start);
|
||||
oFile.WriteStringUTF8(m_sCommentsIds);
|
||||
oFile.WriteStringUTF8(g_string_commentsIds_End);
|
||||
oFile.CloseFile();
|
||||
}
|
||||
if(false == m_sPeople.empty())
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
@ -120,6 +135,15 @@ namespace Writers
|
||||
oFile.WriteStringUTF8(g_string_commentExt_End);
|
||||
oFile.CloseFile();
|
||||
}
|
||||
if(false == m_sDocumentCommentsIds.empty())
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(sDir + OOX::FileTypes::DocumentCommentsIds.DefaultFileName().GetPath());
|
||||
oFile.WriteStringUTF8(g_string_commentsIds_Start);
|
||||
oFile.WriteStringUTF8(m_sDocumentCommentsIds);
|
||||
oFile.WriteStringUTF8(g_string_commentsIds_End);
|
||||
oFile.CloseFile();
|
||||
}
|
||||
if(false == m_sDocumentPeople.empty())
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
@ -1906,6 +1906,7 @@ public:
|
||||
std::wstring Date;
|
||||
std::wstring OOData;
|
||||
bool Solved;
|
||||
unsigned int DurableId;
|
||||
std::wstring Text;
|
||||
std::wstring m_sParaId;
|
||||
std::wstring m_sParaIdParent;
|
||||
@ -1914,12 +1915,14 @@ public:
|
||||
bool bIdOpen;
|
||||
bool bIdFormat;
|
||||
bool bSolved;
|
||||
bool bDurableId;
|
||||
public:
|
||||
CComment(IdCounter& oParaIdCounter, IdCounter& oFormatIdCounter):m_oParaIdCounter(oParaIdCounter),m_oFormatIdCounter(oFormatIdCounter)
|
||||
{
|
||||
bIdOpen = false;
|
||||
bIdFormat = false;
|
||||
bSolved = false;
|
||||
bDurableId = false;
|
||||
}
|
||||
~CComment()
|
||||
{
|
||||
@ -1956,15 +1959,6 @@ public:
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
std::wstring writeTemplates(bool isExt)
|
||||
{
|
||||
std::wstring sRes;
|
||||
sRes += isExt ? writeContentExt(this) : writeContent(this);
|
||||
|
||||
for(size_t i = 0; i < replies.size(); ++i)
|
||||
sRes += isExt ? writeContentExt(replies[i]) : writeContent(replies[i]);
|
||||
return sRes;
|
||||
}
|
||||
static std::wstring writeRef(CComment* pComment, const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter)
|
||||
{
|
||||
std::wstring sRes;
|
||||
@ -1978,7 +1972,7 @@ public:
|
||||
sRes += (sAfter);
|
||||
return sRes;
|
||||
}
|
||||
static bool writeContentWritePart(CComment* pComment, std::wstring& sText, int nPrevIndex, int nCurIndex, bool bFirst, std::wstring& sRes)
|
||||
static void writeContentWritePart(CComment* pComment, std::wstring& sText, int nPrevIndex, int nCurIndex, std::wstring& sRes)
|
||||
{
|
||||
std::wstring sPart;
|
||||
if(nPrevIndex < nCurIndex)
|
||||
@ -1986,17 +1980,11 @@ public:
|
||||
|
||||
int nId = pComment->m_oParaIdCounter.getNextId();
|
||||
|
||||
std::wstring sId = XmlUtils::IntToString(nId, L"%08X");
|
||||
if(bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
pComment->m_sParaId = sId;
|
||||
}
|
||||
sRes += L"<w:p w14:paraId=\"" + sId + L"\" w14:textId=\"" + sId + L"\">";
|
||||
pComment->m_sParaId = XmlUtils::IntToString(nId, L"%08X");
|
||||
sRes += L"<w:p w14:paraId=\"" + pComment->m_sParaId + L"\" w14:textId=\"" + pComment->m_sParaId + L"\">";
|
||||
sRes += L"<w:pPr><w:spacing w:line=\"240\" w:after=\"0\" w:lineRule=\"auto\" w:before=\"0\"/><w:ind w:firstLine=\"0\" w:left=\"0\" w:right=\"0\"/><w:jc w:val=\"left\"/></w:pPr><w:r><w:rPr><w:rFonts w:eastAsia=\"Arial\" w:ascii=\"Arial\" w:hAnsi=\"Arial\" w:cs=\"Arial\"/><w:sz w:val=\"22\"/></w:rPr><w:t xml:space=\"preserve\">";
|
||||
sRes += sPart;
|
||||
sRes += L"</w:t></w:r></w:p>";
|
||||
return bFirst;
|
||||
}
|
||||
static std::wstring writeContent(CComment* pComment)
|
||||
{
|
||||
@ -2050,18 +2038,17 @@ public:
|
||||
|
||||
XmlUtils::replace_all(sText, L"\r", L"");
|
||||
|
||||
bool bFirst = true;
|
||||
int nPrevIndex = 0;
|
||||
for (int i = 0; i < (int)sText.length(); i++)
|
||||
{
|
||||
wchar_t cToken = sText[i];
|
||||
if('\n' == cToken)
|
||||
{
|
||||
bFirst = writeContentWritePart(pComment, sText, nPrevIndex, i, bFirst, sRes);
|
||||
writeContentWritePart(pComment, sText, nPrevIndex, i, sRes);
|
||||
nPrevIndex = i + 1;
|
||||
}
|
||||
}
|
||||
writeContentWritePart(pComment, sText, nPrevIndex, (int)sText.length(), bFirst, sRes);
|
||||
writeContentWritePart(pComment, sText, nPrevIndex, (int)sText.length(), sRes);
|
||||
sRes += L"</w:comment>";
|
||||
return sRes;
|
||||
}
|
||||
@ -2084,6 +2071,15 @@ w15:paraIdParent=\"" + pComment->m_sParaIdParent + L"\" w15:done=\"" + sDone + L
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
static std::wstring writeContentsIds(CComment* pComment)
|
||||
{
|
||||
std::wstring sRes;
|
||||
if(!pComment->m_sParaId.empty() && pComment->bDurableId)
|
||||
{
|
||||
sRes += L"<w16cid:commentId w16cid:paraId=\"" + pComment->m_sParaId + L"\" w16cid:durableId=\"" + XmlUtils::IntToString(pComment->DurableId, L"%08X") + L"\"/>";
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
static std::wstring writePeople(CComment* pComment)
|
||||
{
|
||||
std::wstring sRes;
|
||||
@ -2151,7 +2147,9 @@ public:
|
||||
std::wstring sRes;
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += it->second->writeTemplates(false);
|
||||
sRes += CComment::writeContent(it->second);
|
||||
for(size_t i = 0; i < it->second->replies.size(); ++i)
|
||||
sRes += CComment::writeContent(it->second->replies[i]);
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
@ -2160,7 +2158,20 @@ public:
|
||||
std::wstring sRes;
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += it->second->writeTemplates(true);
|
||||
sRes += CComment::writeContentExt(it->second);
|
||||
for(size_t i = 0; i < it->second->replies.size(); ++i)
|
||||
sRes += CComment::writeContentExt(it->second->replies[i]);
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
std::wstring writeContentsIds()
|
||||
{
|
||||
std::wstring sRes;
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += CComment::writeContentsIds(it->second);
|
||||
for(size_t i = 0; i < it->second->replies.size(); ++i)
|
||||
sRes += CComment::writeContentsIds(it->second->replies[i]);
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
|
||||
@ -3399,6 +3399,11 @@ int Binary_CommentsTableReader::ReadCommentContent(BYTE type, long length, void*
|
||||
pComment->bSolved = true;
|
||||
pComment->Solved = m_oBufferedStream.GetBool();
|
||||
}
|
||||
else if ( c_oSer_CommentsType::DurableId == type )
|
||||
{
|
||||
pComment->bDurableId = true;
|
||||
pComment->DurableId = m_oBufferedStream.GetULong();
|
||||
}
|
||||
else if ( c_oSer_CommentsType::Replies == type )
|
||||
{
|
||||
READ1_DEF(length, res, this->ReadReplies, &pComment->replies);
|
||||
@ -9106,13 +9111,15 @@ int BinaryFileReader::ReadMainTable()
|
||||
|
||||
std::wstring sContent = oComments.writeContent();
|
||||
std::wstring sContentEx = oComments.writeContentExt(); //важно чтобы writeContentExt вызывался после writeContent
|
||||
std::wstring sContentsId = oComments.writeContentsIds();
|
||||
std::wstring sPeople = oComments.writePeople();
|
||||
|
||||
std::wstring sDocumentContent = oBinary_DocumentCommentsTableReader.m_oComments.writeContent();
|
||||
std::wstring sDocumentContentEx = oBinary_DocumentCommentsTableReader.m_oComments.writeContentExt(); //важно чтобы writeContentExt вызывался после writeContent
|
||||
std::wstring sDocumentContentsId = oBinary_DocumentCommentsTableReader.m_oComments.writeContentsIds();
|
||||
std::wstring sDocumentPeople = oBinary_DocumentCommentsTableReader.m_oComments.writePeople();
|
||||
|
||||
oCommentsWriter.setElements(sContent, sContentEx, sPeople, sDocumentContent, sDocumentContentEx, sDocumentPeople);
|
||||
oCommentsWriter.setElements(sContent, sContentEx, sContentsId, sPeople, sDocumentContent, sDocumentContentEx, sDocumentContentsId, sDocumentPeople);
|
||||
|
||||
if(false == oCommentsWriter.m_sComment.empty())
|
||||
{
|
||||
|
||||
@ -803,7 +803,8 @@ extern int g_nCurFormatVersion;
|
||||
QuoteText = 7,
|
||||
Solved = 8,
|
||||
Replies = 9,
|
||||
OOData = 10
|
||||
OOData = 10,
|
||||
DurableId = 11
|
||||
};}
|
||||
namespace c_oSer_SettingsType{enum c_oSer_SettingsType
|
||||
{
|
||||
|
||||
@ -7330,17 +7330,16 @@ void BinaryDocumentTableWriter::WriteDropDownList(const OOX::Logic::CSdtDropDown
|
||||
BinaryCommentsTableWriter::BinaryCommentsTableWriter(ParamsWriter& oParamsWriter):m_oBcw(oParamsWriter)
|
||||
{
|
||||
};
|
||||
void BinaryCommentsTableWriter::Write(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, std::map<int, bool>& mapIgnoreComments)
|
||||
void BinaryCommentsTableWriter::Write(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, OOX::CCommentsIds* pCommentsIds, std::map<int, bool>& mapIgnoreComments)
|
||||
{
|
||||
int nStart = m_oBcw.WriteItemWithLengthStart();
|
||||
WriteCommentsContent(oComments, pCommentsExt, pPeople, mapIgnoreComments);
|
||||
WriteCommentsContent(oComments, pCommentsExt, pPeople, pCommentsIds, mapIgnoreComments);
|
||||
m_oBcw.WriteItemWithLengthEnd(nStart);
|
||||
}
|
||||
void BinaryCommentsTableWriter::WriteCommentsContent(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, std::map<int, bool>& mapIgnoreComments)
|
||||
void BinaryCommentsTableWriter::WriteCommentsContent(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, OOX::CCommentsIds* pCommentsIds, std::map<int, bool>& mapIgnoreComments)
|
||||
{
|
||||
std::map<std::wstring, std::wstring> mapAuthorToUserId;
|
||||
std::map<int, CCommentWriteTemp*> mapParaIdToComment;
|
||||
std::map<int, bool> mapCommentsIgnore;
|
||||
std::map<unsigned int, CCommentWriteTemp*> mapParaIdToComment;
|
||||
std::vector<CCommentWriteTemp*> aCommentsToWrite;
|
||||
//map author -> userId
|
||||
if(NULL != pPeople)
|
||||
@ -7385,7 +7384,7 @@ void BinaryCommentsTableWriter::WriteCommentsContent(OOX::CComments& oComments,
|
||||
OOX::CCommentExt* pCommentExt = pCommentsExt->m_arrComments[i];
|
||||
if(pCommentExt->m_oParaId.IsInit())
|
||||
{
|
||||
std::map<int, CCommentWriteTemp*>::const_iterator pPair = mapParaIdToComment.find(pCommentExt->m_oParaId->GetValue());
|
||||
std::map<unsigned int, CCommentWriteTemp*>::const_iterator pPair = mapParaIdToComment.find(pCommentExt->m_oParaId->GetValue());
|
||||
if(mapParaIdToComment.end() != pPair)
|
||||
{
|
||||
CCommentWriteTemp* pCommentWriteTemp = pPair->second;
|
||||
@ -7394,8 +7393,8 @@ void BinaryCommentsTableWriter::WriteCommentsContent(OOX::CComments& oComments,
|
||||
pCommentWriteTemp->bDone = pCommentExt->m_oDone->ToBool();
|
||||
if(pCommentExt->m_oParaIdParent.IsInit())
|
||||
{
|
||||
int nParaIdParent = pCommentExt->m_oParaIdParent->GetValue();
|
||||
std::map<int, CCommentWriteTemp*>::const_iterator pPairParent = mapParaIdToComment.find(nParaIdParent);
|
||||
unsigned int nParaIdParent = pCommentExt->m_oParaIdParent->GetValue();
|
||||
std::map<unsigned int, CCommentWriteTemp*>::const_iterator pPairParent = mapParaIdToComment.find(nParaIdParent);
|
||||
if(mapParaIdToComment.end() != pPairParent)
|
||||
{
|
||||
CCommentWriteTemp* pCommentWriteTempParent = pPairParent->second;
|
||||
@ -7408,7 +7407,22 @@ void BinaryCommentsTableWriter::WriteCommentsContent(OOX::CComments& oComments,
|
||||
}
|
||||
}
|
||||
}
|
||||
int nCurPos = 0;
|
||||
if(NULL != pCommentsIds)
|
||||
{
|
||||
for(size_t i = 0, length = pCommentsIds->m_arrComments.size(); i < length; i++)
|
||||
{
|
||||
OOX::CCommentId* pCommentId = pCommentsIds->m_arrComments[i];
|
||||
if(pCommentId->m_oParaId.IsInit() && pCommentId->m_oDurableId.IsInit())
|
||||
{
|
||||
std::map<unsigned int, CCommentWriteTemp*>::const_iterator pPair = mapParaIdToComment.find(pCommentId->m_oParaId->GetValue());
|
||||
if(mapParaIdToComment.end() != pPair)
|
||||
{
|
||||
CCommentWriteTemp* pCommentWriteTemp = pPair->second;
|
||||
pCommentWriteTemp->nDurableId = pCommentId->m_oDurableId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t i = 0, length = aCommentsToWrite.size(); i < length; ++i)
|
||||
{
|
||||
@ -7470,6 +7484,12 @@ void BinaryCommentsTableWriter::WriteComment(CCommentWriteTemp& oComment)
|
||||
m_oBcw.m_oStream.WriteBOOL(oComment.bDone.get2());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
if(oComment.nDurableId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_CommentsType::DurableId);
|
||||
m_oBcw.m_oStream.WriteULONG(oComment.nDurableId->GetValue());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
if(oComment.aReplies.size() > 0)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_CommentsType::Replies);
|
||||
@ -8123,14 +8143,14 @@ void BinaryFileWriter::intoBindoc(const std::wstring& sDir)
|
||||
{
|
||||
BinDocxRW::BinaryCommentsTableWriter oBinaryCommentsTableWriter(m_oParamsWriter);
|
||||
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Comments);
|
||||
oBinaryCommentsTableWriter.Write(*oDocx.m_pComments, oDocx.m_pCommentsExt, oDocx.m_pPeople, m_oParamsWriter.m_mapIgnoreComments);
|
||||
oBinaryCommentsTableWriter.Write(*oDocx.m_pComments, oDocx.m_pCommentsExt, oDocx.m_pPeople, oDocx.m_pCommentsIds, m_oParamsWriter.m_mapIgnoreComments);
|
||||
this->WriteTableEnd(nCurPos);
|
||||
}
|
||||
if(NULL != oDocx.m_pDocumentComments)
|
||||
{
|
||||
BinDocxRW::BinaryCommentsTableWriter oBinaryCommentsTableWriter(m_oParamsWriter);
|
||||
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::DocumentComments);
|
||||
oBinaryCommentsTableWriter.Write(*oDocx.m_pDocumentComments, oDocx.m_pDocumentCommentsExt, oDocx.m_pDocumentPeople, m_oParamsWriter.m_mapIgnoreComments);
|
||||
oBinaryCommentsTableWriter.Write(*oDocx.m_pDocumentComments, oDocx.m_pDocumentCommentsExt, oDocx.m_pDocumentPeople, oDocx.m_pDocumentCommentsIds, m_oParamsWriter.m_mapIgnoreComments);
|
||||
this->WriteTableEnd(nCurPos);
|
||||
}
|
||||
|
||||
|
||||
@ -481,13 +481,14 @@ namespace BinDocxRW
|
||||
OOX::CComment* pComment;
|
||||
nullable<bool> bDone;
|
||||
nullable<std::wstring> sUserId;
|
||||
nullable<SimpleTypes::CLongHexNumber<> > nDurableId;
|
||||
std::vector<CCommentWriteTemp*> aReplies;
|
||||
};
|
||||
BinaryCommonWriter m_oBcw;
|
||||
public:
|
||||
BinaryCommentsTableWriter(ParamsWriter& oParamsWriter);
|
||||
void Write(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, std::map<int, bool>& mapIgnoreComments);
|
||||
void WriteCommentsContent(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, std::map<int, bool>& mapIgnoreComments);
|
||||
void Write(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, OOX::CCommentsIds* pCommentsIds, std::map<int, bool>& mapIgnoreComments);
|
||||
void WriteCommentsContent(OOX::CComments& oComments, OOX::CCommentsExt* pCommentsExt, OOX::CPeople* pPeople, OOX::CCommentsIds* pCommentsIds, std::map<int, bool>& mapIgnoreComments);
|
||||
void WriteComment(CCommentWriteTemp& oComment);
|
||||
void WriteReplies(std::vector<CCommentWriteTemp*>& aCommentWriteTemp);
|
||||
};
|
||||
|
||||
@ -122,7 +122,7 @@ namespace PPTX
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
EffectList.fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -541,7 +541,7 @@ bool OOXParagraphReader::Parse3( ReaderParameter oParam , RtfParagraph& oOutputP
|
||||
OOX::Logic::CParagraph *pParagraph = dynamic_cast<OOX::Logic::CParagraph*>(oox_comment->m_arrItems[i]);
|
||||
if ((pParagraph) && (pParagraph->m_oParaId.IsInit()))
|
||||
{
|
||||
std::map<int, int>::iterator pFindPara = oParam.oDocx->m_pCommentsExt->m_mapComments.find(pParagraph->m_oParaId->GetValue());
|
||||
std::map<unsigned int, int>::iterator pFindPara = oParam.oDocx->m_pCommentsExt->m_mapComments.find(pParagraph->m_oParaId->GetValue());
|
||||
if (pFindPara != oParam.oDocx->m_pCommentsExt->m_mapComments.end())
|
||||
{
|
||||
oParam.oReader->m_mapCommentsPara.insert(std::make_pair( pParagraph->m_oParaId->GetValue(), pFindRef->second.index));
|
||||
|
||||
@ -584,7 +584,7 @@ std::wstring RtfBorder::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
case bt_brdrs: sResult += L" w:val=\"single\""; break;
|
||||
case bt_brdrth: sResult += L" w:val=\"thick\""; break;
|
||||
case bt_brdrsh: sResult += L" w:val=\"\"thin"; break;
|
||||
case bt_brdrsh: sResult += L" w:val=\"thin"; break;
|
||||
case bt_brdrdb: sResult += L" w:val=\"double\""; break;
|
||||
case bt_brdrdot: sResult += L" w:val=\"dotted\""; break;
|
||||
case bt_brdrdash: sResult += L" w:val=\"dashed\""; break;
|
||||
@ -593,7 +593,7 @@ std::wstring RtfBorder::RenderToOOX(RenderParameter oRenderParameter)
|
||||
case bt_brdrdashd: sResult += L" w:val=\"dotDash\""; break;
|
||||
case bt_brdrdashdd: sResult += L" w:val=\"dotDotDash\""; break;
|
||||
case bt_brdrinset: sResult += L" w:val=\"inset\""; break;
|
||||
case bt_brdrnone: sResult += L" w:val=\"none\""; break;
|
||||
case bt_brdrnone: sResult += L" w:val=\"nil\""; break;
|
||||
case bt_brdroutset: sResult += L" w:val=\"outset\""; break;
|
||||
case bt_brdrtriple: sResult += L" w:val=\"triple\""; break;
|
||||
case bt_brdrtnthsg: sResult += L" w:val=\"thinThickSmallGap\""; break;
|
||||
|
||||
@ -4,7 +4,7 @@ CD /D %~dp0
|
||||
if exist "%SCRIPTPATH%boost_1_58_0.7z" (
|
||||
echo "boost already downloaded"
|
||||
) else (
|
||||
Powershell.exe Invoke-WebRequest -OutFile boost_1_58_0.7z https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.7z
|
||||
Powershell.exe Invoke-WebRequest -OutFile boost_1_58_0.7z https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.7z -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox
|
||||
)
|
||||
|
||||
SET UNSIP_PROGRAMM="C:\Program Files\7-Zip\7z.exe"
|
||||
|
||||
@ -25,6 +25,10 @@ if defined BUILD_PLATFORM (
|
||||
SET "BUILD_PLATFORMS=win_64 win_32"
|
||||
GOTO :found
|
||||
)
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:xp=%" (
|
||||
SET "BUILD_PLATFORMS=win_64 win_32"
|
||||
GOTO :found
|
||||
)
|
||||
)
|
||||
|
||||
SET "BUILD_PLATFORMS=win_32"
|
||||
|
||||
@ -195,6 +195,7 @@ HEADERS += docxformatlib.h \
|
||||
../Source/XlsxFormat/Chart/ChartSerialize.h \
|
||||
../Source/XlsxFormat/Chart/ChartSerializeEx.h \
|
||||
../Source/XlsxFormat/Comments/Comments.h \
|
||||
../Source/XlsxFormat/Comments/ThreadedComments.h \
|
||||
../Source/XlsxFormat/Drawing/CellAnchor.h \
|
||||
../Source/XlsxFormat/Drawing/Drawing.h \
|
||||
../Source/XlsxFormat/Drawing/FromTo.h \
|
||||
|
||||
@ -3427,7 +3427,7 @@ namespace SimpleTypes
|
||||
//--------------------------------------------------------------------------------
|
||||
// LongHexNumber 17.18.50 (Part 1)
|
||||
//--------------------------------------------------------------------------------
|
||||
template<int nDefValue = 0>
|
||||
template<unsigned int nDefValue = 0>
|
||||
class CLongHexNumber : public CSimpleType<int, nDefValue>
|
||||
{
|
||||
public:
|
||||
@ -3448,7 +3448,7 @@ namespace SimpleTypes
|
||||
return XmlUtils::IntToString(this->m_eValue, L"%08X");
|
||||
}
|
||||
|
||||
SimpleType_FromString (int)
|
||||
SimpleType_FromString (unsigned int)
|
||||
SimpleType_Operator_Equal (CLongHexNumber)
|
||||
private:
|
||||
|
||||
|
||||
@ -391,6 +391,83 @@ CDocumentCommentsExt::CDocumentCommentsExt(OOX::Document *pMain, const CPath& oP
|
||||
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
|
||||
if (docx) docx->m_pDocumentCommentsExt = this;
|
||||
}
|
||||
void CCommentId::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes( oReader );
|
||||
|
||||
if ( !oReader.IsEmptyNode() )
|
||||
oReader.ReadTillEnd();
|
||||
}
|
||||
|
||||
void CCommentId::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"w16cid:paraId", m_oParaId )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, L"w16cid:durableId", m_oDurableId )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
|
||||
CCommentsIds::CCommentsIds(OOX::Document *pMain) : OOX::File(pMain)
|
||||
{
|
||||
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
|
||||
if (docx) docx->m_pCommentsIds = this;
|
||||
}
|
||||
CCommentsIds::CCommentsIds(OOX::Document *pMain, const CPath& oPath) : OOX::File(pMain)
|
||||
{
|
||||
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
|
||||
if (docx) docx->m_pCommentsIds = this;
|
||||
|
||||
read( oPath );
|
||||
}
|
||||
CCommentsIds::~CCommentsIds()
|
||||
{
|
||||
for(size_t i = 0, length = m_arrComments.size(); i < length; ++i)
|
||||
{
|
||||
if (m_arrComments[i]) delete m_arrComments[i];
|
||||
m_arrComments[i] = NULL;
|
||||
}
|
||||
m_arrComments.clear();
|
||||
}
|
||||
void CCommentsIds::read(const CPath& oFilePath)
|
||||
{
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
|
||||
if ( !oReader.FromFile( oFilePath.GetPath() ) )
|
||||
return;
|
||||
|
||||
if ( !oReader.ReadNextNode() )
|
||||
return;
|
||||
|
||||
std::wstring sName = oReader.GetName();
|
||||
if ( L"w16cid:commentsIds" == sName && !oReader.IsEmptyNode() )
|
||||
{
|
||||
int nNumberingDepth = oReader.GetDepth();
|
||||
while ( oReader.ReadNextSiblingNode( nNumberingDepth ) )
|
||||
{
|
||||
sName = oReader.GetName();
|
||||
if ( L"w16cid:commentId" == sName )
|
||||
{
|
||||
CCommentId* pCommentExt = new CCommentId(oReader);
|
||||
if (pCommentExt->m_oParaId.IsInit() && pCommentExt->m_oDurableId.IsInit())
|
||||
{
|
||||
m_arrComments.push_back( pCommentExt );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CDocumentCommentsIds::CDocumentCommentsIds(OOX::Document *pMain) : CCommentsIds(NULL)
|
||||
{
|
||||
File::m_pMainDocument = pMain;
|
||||
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
|
||||
if (docx) docx->m_pDocumentCommentsIds = this;
|
||||
}
|
||||
CDocumentCommentsIds::CDocumentCommentsIds(OOX::Document *pMain, const CPath& oPath) : CCommentsIds(NULL, oPath)
|
||||
{
|
||||
File::m_pMainDocument = pMain;
|
||||
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
|
||||
if (docx) docx->m_pDocumentCommentsIds = this;
|
||||
}
|
||||
void CPresenceInfo::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes( oReader );
|
||||
|
||||
@ -184,7 +184,7 @@ namespace OOX
|
||||
}
|
||||
|
||||
std::vector<CCommentExt*> m_arrComments;
|
||||
std::map<int, int> m_mapComments; //paraId, index
|
||||
std::map<unsigned int, int> m_mapComments; //paraId, index
|
||||
};
|
||||
class CDocumentCommentsExt : public CCommentsExt
|
||||
{
|
||||
@ -197,6 +197,73 @@ namespace OOX
|
||||
}
|
||||
};
|
||||
|
||||
class CCommentId : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CCommentId)
|
||||
CCommentId()
|
||||
{
|
||||
}
|
||||
virtual ~CCommentId()
|
||||
{
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_w16_commentId;
|
||||
}
|
||||
private:
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
public:
|
||||
nullable<SimpleTypes::CLongHexNumber<> > m_oParaId;
|
||||
nullable<SimpleTypes::CLongHexNumber<> > m_oDurableId;
|
||||
};
|
||||
|
||||
class CCommentsIds : public OOX::File
|
||||
{
|
||||
public:
|
||||
CCommentsIds(OOX::Document *pMain);
|
||||
CCommentsIds(OOX::Document *pMain, const CPath& oPath);
|
||||
virtual ~CCommentsIds();
|
||||
virtual void read(const CPath& oFilePath);
|
||||
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
}
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return FileTypes::CommentsIds;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
|
||||
std::vector<CCommentId*> m_arrComments;
|
||||
};
|
||||
class CDocumentCommentsIds : public CCommentsIds
|
||||
{
|
||||
public:
|
||||
CDocumentCommentsIds(OOX::Document *pMain);
|
||||
CDocumentCommentsIds(OOX::Document *pMain, const CPath& oPath);
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return FileTypes::DocumentCommentsIds;
|
||||
}
|
||||
};
|
||||
|
||||
class CPresenceInfo : public WritingElement
|
||||
{
|
||||
public:
|
||||
|
||||
@ -60,10 +60,12 @@ namespace OOX
|
||||
class CSettings;
|
||||
class CComments;
|
||||
class CCommentsExt;
|
||||
class CCommentsIds;
|
||||
class CPeople;
|
||||
class CDocumentComments;
|
||||
class CDocumentCommentsExt;
|
||||
class CDocumentPeople;
|
||||
class CDocumentCommentsIds;
|
||||
class VbaProject;
|
||||
class JsaProject;
|
||||
class CHdrFtr;
|
||||
@ -118,10 +120,12 @@ namespace OOX
|
||||
OOX::CSettings *m_pSettings; // Настройки word/settings.xml
|
||||
OOX::CComments *m_pComments; // word/comments.xml
|
||||
OOX::CCommentsExt *m_pCommentsExt;// word/commentsExtended.xml
|
||||
OOX::CCommentsIds *m_pCommentsIds;// word/commentsIds.xml
|
||||
OOX::CPeople *m_pPeople; // word/people.xml
|
||||
OOX::CDocumentComments *m_pDocumentComments; // word/documentComments.xml
|
||||
OOX::CDocumentCommentsExt *m_pDocumentCommentsExt;// word/documentCommentsExtended.xml
|
||||
OOX::CDocumentPeople *m_pDocumentPeople; // word/documentPeople.xml
|
||||
OOX::CDocumentCommentsIds *m_pDocumentCommentsIds;// word/documentCommentsIds.xml
|
||||
|
||||
OOX::VbaProject *m_pVbaProject;
|
||||
OOX::JsaProject *m_pJsaProject;
|
||||
@ -143,10 +147,12 @@ private:
|
||||
m_pTheme = NULL;
|
||||
m_pComments = NULL;
|
||||
m_pCommentsExt = NULL;
|
||||
m_pCommentsIds = NULL;
|
||||
m_pPeople = NULL;
|
||||
m_pDocumentComments = NULL;
|
||||
m_pDocumentCommentsExt = NULL;
|
||||
m_pDocumentPeople = NULL;
|
||||
m_pDocumentCommentsIds = NULL;
|
||||
m_pVbaProject = NULL;
|
||||
m_pJsaProject = NULL;
|
||||
}
|
||||
|
||||
@ -103,6 +103,10 @@ namespace OOX
|
||||
return smart_ptr<OOX::File>(new CCommentsExt( pMain, oFileName ));
|
||||
else if ( oRelation.Type() == FileTypes::DocumentCommentsExt )
|
||||
return smart_ptr<OOX::File>(new CDocumentCommentsExt( pMain, oFileName ));
|
||||
else if ( oRelation.Type() == FileTypes::CommentsIds )
|
||||
return smart_ptr<OOX::File>(new CCommentsIds( pMain, oFileName ));
|
||||
else if ( oRelation.Type() == FileTypes::DocumentCommentsIds )
|
||||
return smart_ptr<OOX::File>(new CDocumentCommentsIds( pMain, oFileName ));
|
||||
else if ( oRelation.Type() == FileTypes::People )
|
||||
return smart_ptr<OOX::File>(new CPeople( pMain, oFileName ));
|
||||
else if ( oRelation.Type() == FileTypes::DocumentPeople )
|
||||
@ -232,6 +236,10 @@ namespace OOX
|
||||
return smart_ptr<OOX::File>(new CCommentsExt( pMain, oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::DocumentCommentsExt )
|
||||
return smart_ptr<OOX::File>(new CDocumentCommentsExt( pMain, oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::CommentsIds)
|
||||
return smart_ptr<OOX::File>(new CCommentsIds( pMain, oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::DocumentCommentsIds)
|
||||
return smart_ptr<OOX::File>(new CDocumentCommentsIds( pMain, oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::People )
|
||||
return smart_ptr<OOX::File>(new CPeople( pMain, oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::DocumentPeople )
|
||||
|
||||
@ -122,6 +122,14 @@ namespace OOX
|
||||
L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",
|
||||
L"http://schemas.onlyoffice.com/commentsExtendedDocument");
|
||||
|
||||
const FileType CommentsIds (L"", L"commentsIds.xml",
|
||||
L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml",
|
||||
L"http://schemas.microsoft.com/office/2016/09/relationships/commentsIds");
|
||||
|
||||
const FileType DocumentCommentsIds (L"", L"commentsIdsDocument.xml",
|
||||
L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml",
|
||||
L"http://schemas.onlyoffice.com/commentsIdsDocument");
|
||||
|
||||
const FileType People (L"", L"people.xml",
|
||||
L"application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml",
|
||||
L"http://schemas.microsoft.com/office/2011/relationships/people");
|
||||
|
||||
@ -830,6 +830,8 @@ namespace OOX
|
||||
et_w15_person, // <w15:person>
|
||||
et_w15_commentEx, // <w15:commentEx>
|
||||
|
||||
et_w16_commentId, // <w16cid:commentId>
|
||||
|
||||
et_w_ShapeTextBody, //<wps:txbx>
|
||||
et_w_Shape, //<wps:wsp>
|
||||
et_w_GroupShape, //<wpg:wgp>
|
||||
@ -1169,6 +1171,8 @@ namespace OOX
|
||||
et_x_Comment,
|
||||
et_x_ThreadedComments,
|
||||
et_x_ThreadedComment,
|
||||
et_x_ThreadedCommentMentions,
|
||||
et_x_ThreadedCommentMention,
|
||||
et_x_PersonList,
|
||||
et_x_Person,
|
||||
et_x_ConditionalFormatting,
|
||||
|
||||
@ -296,10 +296,14 @@ namespace XmlUtils
|
||||
//
|
||||
// CoTaskMemFree(guidString);
|
||||
//#else
|
||||
srand((unsigned int) time(NULL));
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned int) time(NULL));
|
||||
}
|
||||
|
||||
std::wstringstream sstream;
|
||||
sstream << boost::wformat(L"%X%X-%X-%X-%X-%X%X%X") % std::rand() % std::rand() % std::rand() % ((std::rand() & 0x0fff) | 0x4000) % ((rand() % 0x3fff) + 0x8000) % rand() % rand() % rand();
|
||||
sstream << boost::wformat(L"%04X%04X-%04X-%04X-%04X-%04X%04X%04X") % std::rand() % std::rand() % std::rand() % ((std::rand() & 0x0fff) | 0x4000) % ((rand() % 0x3fff) + 0x8000) % rand() % rand() % rand();
|
||||
result = sstream.str();
|
||||
//#endif
|
||||
return result;
|
||||
|
||||
@ -41,6 +41,7 @@ namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CThreadedComment;
|
||||
class CCommentItem
|
||||
{
|
||||
public:
|
||||
@ -62,11 +63,15 @@ namespace OOX
|
||||
nullable_bool m_bMove;
|
||||
nullable_bool m_bSize;
|
||||
nullable<CSi> m_oText;
|
||||
nullable_string m_sGfxdata;
|
||||
nullable_bool m_bVisible;
|
||||
nullable_string m_sFillColorRgb;
|
||||
CThreadedComment* m_pThreadedComment;
|
||||
bool m_bThreadedCommentCopy;
|
||||
nullable_string m_sGfxdata;
|
||||
nullable_bool m_bVisible;
|
||||
nullable_string m_sFillColorRgb;
|
||||
CCommentItem()
|
||||
{
|
||||
m_pThreadedComment = NULL;
|
||||
m_bThreadedCommentCopy = false;
|
||||
}
|
||||
bool IsValid()
|
||||
{
|
||||
@ -86,12 +91,12 @@ namespace OOX
|
||||
}
|
||||
virtual void ClearItems()
|
||||
{
|
||||
m_arrItems.clear();
|
||||
m_arrItems.clear();
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
@ -99,10 +104,10 @@ namespace OOX
|
||||
{
|
||||
writer.WriteString(L"<authors>");
|
||||
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
writer.WriteString(L"<author>");
|
||||
writer.WriteEncodeXmlString(m_arrItems[i]);
|
||||
writer.WriteEncodeXmlString(m_arrItems[i]);
|
||||
writer.WriteString(L"</author>");
|
||||
}
|
||||
writer.WriteString(L"</authors>");
|
||||
@ -121,7 +126,7 @@ namespace OOX
|
||||
|
||||
if ( L"author" == sName )
|
||||
{
|
||||
m_arrItems.push_back(oReader.GetText3());
|
||||
m_arrItems.push_back(oReader.GetText3());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,7 +141,7 @@ namespace OOX
|
||||
{
|
||||
}
|
||||
public:
|
||||
std::vector<std::wstring> m_arrItems;
|
||||
std::vector<std::wstring> m_arrItems;
|
||||
};
|
||||
class CComment : public WritingElement
|
||||
{
|
||||
@ -151,7 +156,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
@ -162,6 +167,7 @@ namespace OOX
|
||||
writer.WriteString(L"<comment");
|
||||
WritingStringNullableAttrEncodeXmlString(L"ref", m_oRef, m_oRef->ToString());
|
||||
WritingStringNullableAttrInt(L"authorId", m_oAuthorId, m_oAuthorId->GetValue());
|
||||
WritingStringNullableAttrString(L"xr:uid", m_oUid, m_oUid->ToString());
|
||||
writer.WriteString(L">");
|
||||
|
||||
writer.WriteString(L"<text>");
|
||||
@ -198,11 +204,13 @@ namespace OOX
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"ref", m_oRef )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"authorId", m_oAuthorId )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"xr:uid", m_oUid )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::CRelationshipId > m_oRef;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oAuthorId;
|
||||
nullable<SimpleTypes::CGuid > m_oUid;
|
||||
|
||||
nullable<CSi> m_oText;
|
||||
};
|
||||
@ -219,7 +227,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
@ -227,13 +235,13 @@ namespace OOX
|
||||
{
|
||||
writer.WriteString(L"<commentList>");
|
||||
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
if ( m_arrItems[i] )
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
}
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
if ( m_arrItems[i] )
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteString(L"</commentList>");
|
||||
}
|
||||
@ -333,15 +341,15 @@ namespace OOX
|
||||
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
NSStringUtils::CStringBuilder sXml;
|
||||
sXml.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">");
|
||||
sXml.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\" mc:Ignorable=\"xr\">");
|
||||
if(m_oAuthors.IsInit())
|
||||
m_oAuthors->toXML(sXml);
|
||||
if(m_oCommentList.IsInit())
|
||||
m_oCommentList->toXML(sXml);
|
||||
sXml.WriteString(L"</comments>");
|
||||
|
||||
std::wstring sPath = oPath.GetPath();
|
||||
NSFile::CFileBinary::SaveToFile(sPath, sXml.GetData());
|
||||
std::wstring sPath = oPath.GetPath();
|
||||
NSFile::CFileBinary::SaveToFile(sPath, sXml.GetData());
|
||||
|
||||
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
|
||||
IFileContainer::Write(oPath, oDirectory, oContent);
|
||||
@ -385,7 +393,7 @@ namespace OOX
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
@ -33,8 +33,10 @@
|
||||
#ifndef OOX_XLSXTREADEDCOMMENTS_FILE_INCLUDE_H_
|
||||
#define OOX_XLSXTREADEDCOMMENTS_FILE_INCLUDE_H_
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "../Xlsx.h"
|
||||
#include "../Worksheets/Worksheet.h"
|
||||
#include "../Workbook/Workbook.h"
|
||||
#include "../SharedStrings/Si.h"
|
||||
|
||||
namespace OOX
|
||||
@ -62,14 +64,10 @@ namespace OOX
|
||||
{
|
||||
writer.WriteString(L"<person");
|
||||
WritingStringNullableAttrEncodeXmlString(L"displayName", displayName, *displayName);
|
||||
WritingStringNullableAttrString(L"userId", userId, *userId);
|
||||
WritingStringNullableAttrString(L"providerId", providerId, *providerId);
|
||||
WritingStringNullableAttrString(L"id", id, *id);
|
||||
writer.WriteString(L">");
|
||||
//writer.WriteString(L"<text>");
|
||||
//m_oText->toXML2(writer);
|
||||
//writer.WriteString(L"</text>");
|
||||
writer.WriteString(L"</person>");
|
||||
WritingStringNullableAttrString(L"userId", userId, *userId);
|
||||
WritingStringNullableAttrEncodeXmlString(L"providerId", providerId, *providerId);
|
||||
writer.WriteString(L"/>");
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
@ -120,17 +118,17 @@ namespace OOX
|
||||
CPersonList(OOX::Document* pMain) : OOX::File(pMain)
|
||||
{
|
||||
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
|
||||
if ((xlsx) && (!xlsx->m_arWorksheets.empty()))
|
||||
if ((xlsx) && xlsx->m_pWorkbook)
|
||||
{
|
||||
xlsx->m_arWorksheets.back()->m_pPersonList = this;
|
||||
xlsx->m_pWorkbook->m_pPersonList = this;
|
||||
}
|
||||
}
|
||||
CPersonList(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain)
|
||||
{
|
||||
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
|
||||
if ((xlsx) && (!xlsx->m_arWorksheets.empty()))
|
||||
if ((xlsx) && xlsx->m_pWorkbook)
|
||||
{
|
||||
xlsx->m_arWorksheets.back()->m_pPersonList = this;
|
||||
xlsx->m_pWorkbook->m_pPersonList = this;
|
||||
}
|
||||
read( oRootPath, oPath );
|
||||
}
|
||||
@ -200,7 +198,12 @@ namespace OOX
|
||||
|
||||
if ( L"person" == sName )
|
||||
{
|
||||
m_arrItems.push_back(new CPerson(oReader));
|
||||
CPerson* pPerson = new CPerson(oReader);
|
||||
if(pPerson->id.IsInit())
|
||||
{
|
||||
m_mapPersonList[pPerson->id.get()] = pPerson;
|
||||
}
|
||||
m_arrItems.push_back(pPerson);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,12 +239,127 @@ namespace OOX
|
||||
{
|
||||
return m_oReadPath;
|
||||
}
|
||||
public:
|
||||
std::unordered_map<std::wstring, CPerson*> m_mapPersonList;
|
||||
private:
|
||||
CPath m_oReadPath;
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
}
|
||||
};
|
||||
class CThreadedCommentMention : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CThreadedCommentMention)
|
||||
CThreadedCommentMention()
|
||||
{
|
||||
}
|
||||
virtual ~CThreadedCommentMention()
|
||||
{
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<mention");
|
||||
WritingStringNullableAttrString(L"mentionpersonId", mentionpersonId, mentionpersonId->ToString());
|
||||
WritingStringNullableAttrString(L"mentionId", mentionId, mentionId->ToString());
|
||||
WritingStringNullableAttrInt(L"startIndex", startIndex, startIndex->GetValue());
|
||||
WritingStringNullableAttrInt(L"length", length, length->GetValue());
|
||||
writer.WriteString(L"/>");
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes( oReader );
|
||||
|
||||
if ( !oReader.IsEmptyNode() )
|
||||
oReader.ReadTillEnd();
|
||||
}
|
||||
|
||||
virtual EElementType getType () const
|
||||
{
|
||||
return et_x_ThreadedCommentMention;
|
||||
}
|
||||
|
||||
private:
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"mentionpersonId", mentionpersonId )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"mentionId", mentionId )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"startIndex", startIndex )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"length", length )
|
||||
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::CGuid> mentionpersonId;
|
||||
nullable<SimpleTypes::CGuid> mentionId;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> startIndex;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> length;
|
||||
};
|
||||
class CThreadedCommentMentions : public WritingElementWithChilds<CThreadedCommentMention>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CThreadedCommentMentions)
|
||||
CThreadedCommentMentions()
|
||||
{
|
||||
}
|
||||
virtual ~CThreadedCommentMentions()
|
||||
{
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<mentions>");
|
||||
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
if ( m_arrItems[i] )
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
}
|
||||
writer.WriteString(L"</mentions>");
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes( oReader );
|
||||
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
|
||||
|
||||
if ( _T("mention") == sName )
|
||||
m_arrItems.push_back(new CThreadedCommentMention(oReader));
|
||||
}
|
||||
}
|
||||
|
||||
virtual EElementType getType () const
|
||||
{
|
||||
return et_x_ThreadedCommentMentions;
|
||||
}
|
||||
|
||||
private:
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
}
|
||||
};
|
||||
class CThreadedComment : public WritingElement
|
||||
{
|
||||
public:
|
||||
@ -262,15 +380,26 @@ namespace OOX
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<threadedComment");
|
||||
WritingStringNullableAttrEncodeXmlString(L"ref", ref, ref->ToString());
|
||||
WritingStringNullableAttrString(L"personId", personId, *personId);
|
||||
WritingStringNullableAttrString(L"id", id, *id);
|
||||
WritingStringNullableAttrString(L"dT", dT, *dT);
|
||||
WritingStringNullableAttrEncodeXmlString(L"ref", ref, ref.get());
|
||||
WritingStringNullableAttrString(L"dT", dT, dT->ToString());
|
||||
WritingStringNullableAttrString(L"personId", personId, personId->ToString());
|
||||
WritingStringNullableAttrString(L"id", id, id->ToString());
|
||||
WritingStringNullableAttrString(L"parentId", parentId, parentId->ToString());
|
||||
WritingStringNullableAttrBool2(L"done", done);
|
||||
writer.WriteString(L">");
|
||||
|
||||
writer.WriteString(L"<text>");
|
||||
m_oText->toXML2(writer);
|
||||
writer.WriteString(L"</text>");
|
||||
if(m_oText.IsInit())
|
||||
{
|
||||
writer.WriteString(_T("<text xml:space=\"preserve\">"));
|
||||
writer.WriteEncodeXmlStringHHHH(m_oText->m_sText);
|
||||
//last '\n' not in format but excel add it
|
||||
writer.WriteString(_T("\n"));//todo \r?
|
||||
writer.WriteString(_T("</text>"));
|
||||
}
|
||||
if(m_oMentions.IsInit())
|
||||
{
|
||||
m_oMentions->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</threadedComment>");
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
@ -287,31 +416,66 @@ namespace OOX
|
||||
|
||||
if ( _T("text") == sName )
|
||||
m_oText = oReader;
|
||||
else if ( _T("mentions") == sName )
|
||||
m_oMentions = oReader;
|
||||
}
|
||||
PrepareText();
|
||||
}
|
||||
|
||||
virtual EElementType getType () const
|
||||
{
|
||||
return et_x_ThreadedComment;
|
||||
}
|
||||
bool operator < (const CThreadedComment& elem) const
|
||||
{
|
||||
if(dT.IsInit() && elem.dT.IsInit())
|
||||
{
|
||||
return dT->GetValue() < elem.dT->GetValue();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void PrepareText ()
|
||||
{
|
||||
//last '\n' not in format but excel add it
|
||||
if(m_oText.IsInit())
|
||||
{
|
||||
if(m_oText->m_sText.length() > 0 && '\n' == m_oText->m_sText[m_oText->m_sText.length() - 1])
|
||||
m_oText->m_sText.pop_back();
|
||||
if(m_oText->m_sText.length() > 0 && '\r' == m_oText->m_sText[m_oText->m_sText.length() - 1])
|
||||
m_oText->m_sText.pop_back();
|
||||
}
|
||||
}
|
||||
static bool Compare (CThreadedComment* val1, CThreadedComment* val2)
|
||||
{
|
||||
return *val1 < *val2;
|
||||
}
|
||||
|
||||
private:
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"ref", ref )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"dT", dT )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"personId", personId )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"id", id )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"dT", dT )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"parentId", parentId )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"done", done )
|
||||
|
||||
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::CRelationshipId> ref;
|
||||
nullable_string personId;
|
||||
nullable_string id;
|
||||
nullable_string dT;
|
||||
nullable_string ref;
|
||||
nullable<SimpleTypes::CDateTime> dT;
|
||||
nullable<SimpleTypes::CGuid> personId;
|
||||
nullable<SimpleTypes::CGuid> id;
|
||||
nullable<SimpleTypes::CGuid> parentId;
|
||||
nullable_bool done;
|
||||
|
||||
nullable<CSi> m_oText;
|
||||
nullable<CText> m_oText;
|
||||
nullable<CThreadedCommentMentions> m_oMentions;
|
||||
|
||||
std::vector<CThreadedComment*> m_arrReplies;
|
||||
};
|
||||
class CThreadedComments : public OOX::FileGlobalEnumerated, public OOX::IFileContainer, public WritingElementWithChilds<CThreadedComment>
|
||||
{
|
||||
@ -398,10 +562,43 @@ namespace OOX
|
||||
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
|
||||
|
||||
if ( L"threadedComment" == sName )
|
||||
m_arrItems.push_back(new CThreadedComment(oReader));
|
||||
{
|
||||
CThreadedComment* pThreadedComment = new CThreadedComment(oReader);
|
||||
m_arrItems.push_back(pThreadedComment);
|
||||
}
|
||||
}
|
||||
PrepareTopLevelComments();
|
||||
}
|
||||
void PrepareTopLevelComments ()
|
||||
{
|
||||
//find TopLevelComments
|
||||
for(size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
CThreadedComment* pThreadedComment = m_arrItems[i];
|
||||
if(pThreadedComment->id.IsInit() && !pThreadedComment->parentId.IsInit())
|
||||
{
|
||||
m_mapTopLevelThreadedComments[pThreadedComment->id->ToString()] = pThreadedComment;
|
||||
}
|
||||
}
|
||||
//add Replies
|
||||
for(size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
CThreadedComment* pThreadedComment = m_arrItems[i];
|
||||
if(pThreadedComment->parentId.IsInit())
|
||||
{
|
||||
std::unordered_map<std::wstring, CThreadedComment*>::const_iterator oFind = m_mapTopLevelThreadedComments.find(pThreadedComment->parentId->ToString());
|
||||
if(m_mapTopLevelThreadedComments.end() != oFind)
|
||||
{
|
||||
oFind->second->m_arrReplies.push_back(pThreadedComment);
|
||||
}
|
||||
}
|
||||
}
|
||||
//sort Replies
|
||||
for (std::unordered_map<std::wstring, CThreadedComment*>::const_iterator it = m_mapTopLevelThreadedComments.begin(); it != m_mapTopLevelThreadedComments.end(); ++it)
|
||||
{
|
||||
std::sort (it->second->m_arrReplies.begin(), it->second->m_arrReplies.end(), CThreadedComment::Compare);
|
||||
}
|
||||
}
|
||||
|
||||
virtual EElementType getType () const
|
||||
{
|
||||
return et_x_ThreadedComments;
|
||||
@ -435,6 +632,8 @@ namespace OOX
|
||||
{
|
||||
return m_oReadPath;
|
||||
}
|
||||
public:
|
||||
std::unordered_map<std::wstring, CThreadedComment*> m_mapTopLevelThreadedComments;
|
||||
private:
|
||||
CPath m_oReadPath;
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
|
||||
@ -75,7 +75,7 @@ namespace OOX
|
||||
L"http://schemas.microsoft.com/office/2017/10/relationships/threadedComment",
|
||||
L"threadedComments/threadedComment", true, true);
|
||||
|
||||
const FileType Persons (L"../persons", L"person.xml",
|
||||
const FileType Persons (L"persons", L"person.xml",
|
||||
L"application/vnd.ms-excel.person+xml",
|
||||
L"http://schemas.microsoft.com/office/2017/10/relationships/person");
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CPersonList;
|
||||
//необработанные child:
|
||||
//<customWorkbookViews>
|
||||
//<extLst>
|
||||
@ -67,6 +68,7 @@ namespace OOX
|
||||
{
|
||||
m_bMacroEnabled = false;
|
||||
m_bSpreadsheets = true;
|
||||
m_pPersonList = NULL;
|
||||
|
||||
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
|
||||
if ((xlsx) && (!xlsx->m_pWorkbook))
|
||||
@ -77,7 +79,8 @@ namespace OOX
|
||||
CWorkbook(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain), OOX::IFileContainer(pMain)
|
||||
{
|
||||
m_bMacroEnabled = false;
|
||||
m_bSpreadsheets = true;
|
||||
m_bSpreadsheets = true;
|
||||
m_pPersonList = NULL;
|
||||
|
||||
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
|
||||
if ((xlsx) && (!xlsx->m_pWorkbook))
|
||||
@ -255,6 +258,7 @@ namespace OOX
|
||||
nullable<std::wstring> m_oPivotCachesXml;
|
||||
nullable<OOX::Spreadsheet::CCalcPr> m_oCalcPr;
|
||||
|
||||
CPersonList* m_pPersonList;
|
||||
bool m_bMacroEnabled;
|
||||
};
|
||||
} //Spreadsheet
|
||||
|
||||
@ -48,7 +48,6 @@ namespace OOX
|
||||
m_bSpreadsheets = true;
|
||||
m_bWriteDirectlyToFile = false;
|
||||
m_pComments = NULL;
|
||||
m_pPersonList = NULL;
|
||||
m_pThreadedComments = NULL;
|
||||
|
||||
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
|
||||
@ -67,7 +66,6 @@ namespace OOX
|
||||
m_bSpreadsheets = true;
|
||||
m_bWriteDirectlyToFile = false;
|
||||
m_pComments = NULL;
|
||||
m_pPersonList = NULL;
|
||||
m_pThreadedComments = NULL;
|
||||
|
||||
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
|
||||
@ -105,21 +103,8 @@ namespace OOX
|
||||
{
|
||||
read(oReader);
|
||||
}
|
||||
|
||||
if(m_oLegacyDrawing.IsInit() && m_oLegacyDrawing->m_oId.IsInit())
|
||||
{
|
||||
OOX::RId oRId(m_oLegacyDrawing->m_oId->GetValue());
|
||||
|
||||
smart_ptr<OOX::File> oVmlDrawing = IFileContainer::Find(oRId);
|
||||
|
||||
if (m_pComments && oVmlDrawing.IsInit() && OOX::FileTypes::VmlDrawing == oVmlDrawing->type())
|
||||
{
|
||||
OOX::CVmlDrawing* pVmlDrawing = static_cast<OOX::CVmlDrawing*>(oVmlDrawing.GetPointer());
|
||||
|
||||
PrepareComments(m_pComments, pVmlDrawing);
|
||||
}
|
||||
}
|
||||
|
||||
PrepareComments(m_pComments, m_pThreadedComments, m_oLegacyDrawing.GetPointer());
|
||||
PrepareConditionalFormatting();
|
||||
PrepareDataValidations();
|
||||
}
|
||||
@ -178,10 +163,10 @@ namespace OOX
|
||||
m_oHeaderFooter = oReader;
|
||||
else if (_T("sheetPr") == sName)
|
||||
m_oSheetPr = oReader;
|
||||
else if (_T("extLst") == sName)
|
||||
m_oExtLst = oReader;
|
||||
else if (_T("picture") == sName)
|
||||
m_oPicture = oReader;
|
||||
else if (_T("extLst") == sName)
|
||||
m_oExtLst = oReader;
|
||||
else if (_T("picture") == sName)
|
||||
m_oPicture = oReader;
|
||||
else if (_T("rowBreaks") == sName)
|
||||
m_oRowBreaks = oReader;
|
||||
else if (_T("colBreaks") == sName)
|
||||
@ -256,20 +241,78 @@ namespace OOX
|
||||
}
|
||||
}
|
||||
}
|
||||
void CWorksheet::PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::CVmlDrawing* pVmlDrawing)
|
||||
void CWorksheet::PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::Spreadsheet::CThreadedComments* pThreadedComments, OOX::Spreadsheet::CLegacyDrawingWorksheet* pLegacyDrawing)
|
||||
{
|
||||
std::vector<std::wstring> & arAuthors = pComments->m_oAuthors->m_arrItems;
|
||||
OOX::CVmlDrawing* pVmlDrawing = NULL;
|
||||
if(NULL != pLegacyDrawing && pLegacyDrawing->m_oId.IsInit())
|
||||
{
|
||||
OOX::RId oRId(pLegacyDrawing->m_oId->GetValue());
|
||||
|
||||
smart_ptr<OOX::File> oVmlDrawing = IFileContainer::Find(oRId);
|
||||
|
||||
if (oVmlDrawing.IsInit() && OOX::FileTypes::VmlDrawing == oVmlDrawing->type())
|
||||
{
|
||||
pVmlDrawing = static_cast<OOX::CVmlDrawing*>(oVmlDrawing.GetPointer());
|
||||
}
|
||||
}
|
||||
//2.3.7.3.1 Reconciliation
|
||||
//if Corresponding placeholder is not found, Delete the entire comment thread.
|
||||
if(!pComments || !pVmlDrawing)
|
||||
return;
|
||||
std::unordered_map<std::wstring, int> mapCheckCopyThreadedComments;
|
||||
std::vector<std::wstring> & arAuthors = pComments->m_oAuthors->m_arrItems;
|
||||
|
||||
if(pComments->m_oCommentList.IsInit())
|
||||
{
|
||||
std::vector<OOX::Spreadsheet::CComment*> & aComments = pComments->m_oCommentList->m_arrItems;
|
||||
|
||||
for ( size_t i = 0; i < aComments.size(); ++i)
|
||||
for ( size_t i = 0; i < aComments.size(); ++i)
|
||||
{
|
||||
OOX::Spreadsheet::CComment* pComment = aComments[i];
|
||||
OOX::Spreadsheet::CComment* pComment = aComments[i];
|
||||
|
||||
if (!pComment) continue;
|
||||
|
||||
bool bThreadedCommentCopy = false;
|
||||
OOX::Spreadsheet::CThreadedComment* pThreadedComment = NULL;
|
||||
if(pThreadedComments)
|
||||
{
|
||||
std::unordered_map<std::wstring, CThreadedComment*>::iterator pFind = pThreadedComments->m_mapTopLevelThreadedComments.end();
|
||||
|
||||
if(pComment->m_oUid.IsInit())
|
||||
{
|
||||
pFind = pThreadedComments->m_mapTopLevelThreadedComments.find(pComment->m_oUid->ToString());
|
||||
}
|
||||
else if(pComment->m_oAuthorId.IsInit())
|
||||
{
|
||||
unsigned int nAuthorId = pComment->m_oAuthorId->GetValue();
|
||||
|
||||
if (nAuthorId >= 0 && nAuthorId < arAuthors.size())
|
||||
{
|
||||
const std::wstring& sAuthor = arAuthors[nAuthorId];
|
||||
if(0 == sAuthor.compare(0, 3, L"tc="))
|
||||
{
|
||||
pFind = pThreadedComments->m_mapTopLevelThreadedComments.find(sAuthor.substr(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pThreadedComments->m_mapTopLevelThreadedComments.end() != pFind)
|
||||
{
|
||||
pThreadedComment = pFind->second;
|
||||
if(mapCheckCopyThreadedComments.end() != mapCheckCopyThreadedComments.find(pThreadedComment->id->ToString()))
|
||||
{
|
||||
bThreadedCommentCopy = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapCheckCopyThreadedComments[pThreadedComment->id->ToString()] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(pComment->m_oRef.IsInit() && pComment->m_oAuthorId.IsInit())
|
||||
{
|
||||
int nRow, nCol;
|
||||
@ -281,22 +324,26 @@ namespace OOX
|
||||
|
||||
unsigned int nAuthorId = pComment->m_oAuthorId->GetValue();
|
||||
|
||||
if (nAuthorId >= 0 && nAuthorId < arAuthors.size())
|
||||
{
|
||||
pCommentItem->m_sAuthor = arAuthors[nAuthorId];
|
||||
if (nAuthorId >= 0 && nAuthorId < arAuthors.size())
|
||||
{
|
||||
pCommentItem->m_sAuthor = arAuthors[nAuthorId];
|
||||
}
|
||||
|
||||
OOX::Spreadsheet::CSi* pSi = pComment->m_oText.GetPointerEmptyNullable();
|
||||
if(NULL != pSi)
|
||||
pCommentItem->m_oText.reset(pSi);
|
||||
std::wstring sNewId = std::to_wstring(pCommentItem->m_nRow.get()) + L"-" + std::to_wstring(pCommentItem->m_nCol.get());
|
||||
|
||||
pCommentItem->m_pThreadedComment = pThreadedComment;
|
||||
pCommentItem->m_bThreadedCommentCopy = bThreadedCommentCopy;
|
||||
|
||||
std::wstring sNewId = std::to_wstring(pCommentItem->m_nRow.get()) + L"-" + std::to_wstring(pCommentItem->m_nCol.get());
|
||||
m_mapComments [sNewId] = pCommentItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < pVmlDrawing->m_arrItems.size(); ++i)
|
||||
for ( size_t i = 0; i < pVmlDrawing->m_arrItems.size(); ++i)
|
||||
{
|
||||
OOX::Vml::CShape* pShape = dynamic_cast<OOX::Vml::CShape*>(pVmlDrawing->m_arrItems[i]);
|
||||
|
||||
@ -323,9 +370,9 @@ namespace OOX
|
||||
{
|
||||
int nRow = pClientData->m_oRow->GetValue();
|
||||
int nCol = pClientData->m_oColumn->GetValue();
|
||||
std::wstring sId = std::to_wstring(nRow) + L"-" + std::to_wstring(nCol);
|
||||
std::wstring sId = std::to_wstring(nRow) + L"-" + std::to_wstring(nCol);
|
||||
|
||||
boost::unordered_map<std::wstring, CCommentItem*>::const_iterator pPair = m_mapComments.find(sId);
|
||||
boost::unordered_map<std::wstring, CCommentItem*>::const_iterator pPair = m_mapComments.find(sId);
|
||||
if(pPair != m_mapComments.end())
|
||||
{
|
||||
CCommentItem* pCommentItem = pPair->second;
|
||||
@ -531,8 +578,8 @@ mc:Ignorable=\"x14ac\">");
|
||||
|
||||
const OOX::RId CWorksheet::AddHyperlink (std::wstring& sHref)
|
||||
{
|
||||
std::wstring sExistRId = IsExistHyperlink(sHref);
|
||||
if(sExistRId.empty())
|
||||
std::wstring sExistRId = IsExistHyperlink(sHref);
|
||||
if(sExistRId.empty())
|
||||
{
|
||||
smart_ptr<OOX::File> oHyperlinkFile = smart_ptr<OOX::File>( new OOX::HyperLink( File::m_pMainDocument, OOX::CPath(sHref, false) ) );
|
||||
const OOX::RId rId = Add( oHyperlinkFile );
|
||||
@ -546,7 +593,7 @@ mc:Ignorable=\"x14ac\">");
|
||||
}
|
||||
void CWorksheet::ClearItems()
|
||||
{
|
||||
for (boost::unordered_map<std::wstring, CCommentItem*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
for (boost::unordered_map<std::wstring, CCommentItem*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace OOX
|
||||
|
||||
void PrepareDataValidations();
|
||||
void PrepareConditionalFormatting();
|
||||
void PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::CVmlDrawing* pVmlDrawing);
|
||||
void PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::Spreadsheet::CThreadedComments* pThreadedComments, OOX::Spreadsheet::CLegacyDrawingWorksheet* pLegacyDrawing);
|
||||
void PrepareToWrite();
|
||||
|
||||
CPath m_oReadPath;
|
||||
@ -151,7 +151,6 @@ namespace OOX
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
CComments *m_pComments;
|
||||
CPersonList *m_pPersonList;
|
||||
CThreadedComments *m_pThreadedComments;
|
||||
|
||||
std::map<std::wstring, CConditionalFormattingRule*> m_mapConditionalFormattingEx;
|
||||
|
||||
@ -45,7 +45,13 @@ core_windows {
|
||||
DESTDIR = $$CORE_ROOT_DIR/build/bin/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
################################################
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer -lkernel -lgraphics -lUnicodeConverter
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lkernel -lgraphics -lUnicodeConverter
|
||||
|
||||
build_xp {
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH/xp -ldoctrenderer
|
||||
} else {
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
|
||||
}
|
||||
|
||||
core_linux {
|
||||
LIBS += -ldl
|
||||
|
||||
@ -441,14 +441,14 @@ private:
|
||||
}
|
||||
else if (lIndex + 1 < lSize)
|
||||
{
|
||||
int nPatternSize = vPattern.size();
|
||||
size_t nPatternSize = vPattern.size();
|
||||
vPattern.at(nPatternSize - 1) = vPattern.at(nPatternSize - 1) + pPattern[lIndex + 1];
|
||||
lIndex++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int nPatternSize = vPattern.size();
|
||||
size_t nPatternSize = vPattern.size();
|
||||
vPattern.at(nPatternSize - 2) = vPattern.at(nPatternSize - 2) + vPattern.at(nPatternSize - 1);
|
||||
vPattern.pop_back();
|
||||
}
|
||||
@ -459,8 +459,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
int nPatternSize = vPattern.size();
|
||||
if (nPatternSize)
|
||||
size_t nPatternSize = vPattern.size();
|
||||
if (nPatternSize > 0)
|
||||
{
|
||||
m_pDashPattern = new double[nPatternSize];
|
||||
if (m_pDashPattern)
|
||||
@ -879,8 +879,8 @@ private:
|
||||
vResPoints.push_back(TColorAndPoint(lColor1, 1));
|
||||
}
|
||||
|
||||
LONG lResCount = vResPoints.size();
|
||||
if (!lResCount)
|
||||
size_t lResCount = vResPoints.size();
|
||||
if (lResCount == 0)
|
||||
return;
|
||||
|
||||
m_pShadingColors = new TColor[lResCount];
|
||||
@ -1416,7 +1416,7 @@ private:
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
for (int nIndex = 0, nCount = m_vCommands.size(); nIndex < nCount; nIndex++)
|
||||
for (size_t nIndex = 0, nCount = m_vCommands.size(); nIndex < nCount; nIndex++)
|
||||
{
|
||||
CPathCommandBase* pCommand = m_vCommands.at(nIndex);
|
||||
delete pCommand;
|
||||
|
||||
@ -101,7 +101,11 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPPTXFormatLib
|
||||
#docxformat
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lDocxFormatLib
|
||||
#doctrenderer
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
|
||||
build_xp {
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH/xp -ldoctrenderer
|
||||
} else {
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
|
||||
}
|
||||
#HtmlRenderer
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lHtmlRenderer
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPdfReader
|
||||
|
||||
@ -98,9 +98,9 @@ namespace NExtractTools
|
||||
}
|
||||
return sExt;
|
||||
}
|
||||
bool replaceContentType(const std::wstring &sDir, const std::wstring &sCTFrom, const std::wstring &sCTTo)
|
||||
_UINT32 replaceContentType(const std::wstring &sDir, const std::wstring &sCTFrom, const std::wstring &sCTTo)
|
||||
{
|
||||
bool res = false;
|
||||
_UINT32 nRes = 0;
|
||||
std::wstring sContentTypesPath = sDir + FILE_SEPARATOR_STR + _T("[Content_Types].xml");
|
||||
if (NSFile::CFileBinary::Exists(sContentTypesPath))
|
||||
{
|
||||
@ -108,10 +108,11 @@ namespace NExtractTools
|
||||
if (NSFile::CFileBinary::ReadAllTextUtf8(sContentTypesPath, sData))
|
||||
{
|
||||
sData = string_replaceAll(sData, sCTFrom, sCTTo);
|
||||
res = NSFile::CFileBinary::SaveToFile(sContentTypesPath, sData, true);
|
||||
if (false == NSFile::CFileBinary::SaveToFile(sContentTypesPath, sData, true))
|
||||
nRes = AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return nRes;
|
||||
}
|
||||
_UINT32 processEncryptionError(_UINT32 hRes, const std::wstring &sFrom, InputParams& params)
|
||||
{
|
||||
@ -200,12 +201,38 @@ namespace NExtractTools
|
||||
|
||||
_UINT32 nRes = doct_bin2docx_dir(sFrom, sTo, sResultDocxDir, bFromChanges, sThemeDir, params);
|
||||
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
// compress
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultDocxDir, sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
if (SUCCEEDED_X2T(nRes) && params.m_nFormatTo)
|
||||
{
|
||||
if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM == *params.m_nFormatTo)
|
||||
{
|
||||
std::wstring sCTFrom = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
|
||||
std::wstring sCTTo;
|
||||
switch(*params.m_nFormatTo)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: sCTTo = _T("application/vnd.ms-word.document.macroEnabled.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX: sCTTo = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM: sCTTo = _T("application/vnd.ms-word.template.macroEnabledTemplate.main+xml");break;
|
||||
}
|
||||
nRes = replaceContentType(sResultDocxDir, sCTFrom, sCTTo);
|
||||
}
|
||||
}
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
if(params.hasSavePassword())
|
||||
{
|
||||
std::wstring sToMscrypt = sTemp + FILE_SEPARATOR_STR + _T("tomscrypt.docx");
|
||||
nRes = dir2zip(sResultDocxDir, sToMscrypt);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = oox2mscrypt(sToMscrypt, sTo, sTemp, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sResultDocxDir, sTo);
|
||||
}
|
||||
}
|
||||
|
||||
return nRes;
|
||||
}
|
||||
// bin -> docx dir
|
||||
@ -347,13 +374,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sDocumentRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = sData.rfind(L"<", pos);
|
||||
size_t pos2 = sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -426,13 +453,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sDocumentRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = sData.rfind(L"<", pos);
|
||||
size_t pos2 = sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -572,12 +599,38 @@ namespace NExtractTools
|
||||
NSDirectory::CreateDirectory(sResultXlsxDir);
|
||||
|
||||
_UINT32 nRes = xlst_bin2xlsx_dir(sFrom, sTo, sResultXlsxDir, bFromChanges, sThemeDir, params);
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
// compress
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultXlsxDir, sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
|
||||
if (SUCCEEDED_X2T(nRes) && params.m_nFormatTo)
|
||||
{
|
||||
if (AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM == *params.m_nFormatTo)
|
||||
{
|
||||
std::wstring sCTFrom = _T("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
|
||||
std::wstring sCTTo;
|
||||
switch(*params.m_nFormatTo)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: sCTTo = _T("application/vnd.ms-excel.sheet.macroEnabled.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX: sCTTo = _T("application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM: sCTTo = _T("application/vnd.ms-excel.template.macroEnabled.main+xml");break;
|
||||
}
|
||||
nRes = replaceContentType(sResultXlsxDir, sCTFrom, sCTTo);
|
||||
}
|
||||
}
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
if(params.hasSavePassword())
|
||||
{
|
||||
std::wstring sToMscrypt = sTemp + FILE_SEPARATOR_STR + _T("tomscrypt.xlsx");
|
||||
nRes = dir2zip(sResultXlsxDir, sToMscrypt);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = oox2mscrypt(sToMscrypt, sTo, sTemp, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sResultXlsxDir, sTo);
|
||||
}
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
_UINT32 xlst_bin2xlsx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params)
|
||||
@ -715,13 +768,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sWorkbookRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = sData.rfind(L"<", pos);
|
||||
size_t pos2 = sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -785,13 +838,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sWorkbookRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = (int)sData.rfind(L"<", pos);
|
||||
size_t pos2 = (int)sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -916,13 +969,41 @@ namespace NExtractTools
|
||||
NSDirectory::CreateDirectory(sResultPptxDir);
|
||||
|
||||
_UINT32 nRes = pptt_bin2pptx_dir(sFrom, sTo, sResultPptxDir, bFromChanges, sThemeDir, params);
|
||||
if (!SUCCEEDED_X2T(nRes))
|
||||
return nRes;
|
||||
|
||||
// zip pptx folder to output file
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultPptxDir,sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
|
||||
|
||||
if(SUCCEEDED_X2T(nRes) && params.m_nFormatTo)
|
||||
{
|
||||
if (AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX == *params.m_nFormatTo ||
|
||||
AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM == *params.m_nFormatTo || AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM == *params.m_nFormatTo)
|
||||
{
|
||||
std::wstring sCTFrom = _T("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml");
|
||||
std::wstring sCTTo;
|
||||
switch(*params.m_nFormatTo)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM: sCTTo = _T("application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX: sCTTo = _T("application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX: sCTTo = _T("application/vnd.openxmlformats-officedocument.presentationml.template.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM: sCTTo = _T("application/vnd.ms-powerpoint.template.macroEnabled.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM: sCTTo = _T("application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml");break;
|
||||
}
|
||||
nRes = replaceContentType(sResultPptxDir, sCTFrom, sCTTo);
|
||||
}
|
||||
}
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
if(params.hasSavePassword())
|
||||
{
|
||||
std::wstring sToMscrypt = sTemp + FILE_SEPARATOR_STR + _T("tomscrypt.pptx");
|
||||
nRes = dir2zip(sResultPptxDir, sToMscrypt);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = oox2mscrypt(sToMscrypt, sTo, sTemp, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
}
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
_UINT32 pptt_bin2pptx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params)
|
||||
@ -1447,13 +1528,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sPresentationRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = sData.rfind(L"<", pos);
|
||||
size_t pos2 = sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -1518,13 +1599,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sPresentationRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = sData.rfind(L"<", pos);
|
||||
size_t pos2 = sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -1589,13 +1670,13 @@ namespace NExtractTools
|
||||
std::wstring sData;
|
||||
if(NSFile::CFileBinary::ReadAllTextUtf8(sPresentationRelsPath, sData))
|
||||
{
|
||||
int pos = sData.find(L"vbaProject.bin");
|
||||
if (pos > 0)
|
||||
size_t pos = sData.find(L"vbaProject.bin");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
int pos1 = sData.rfind(L"<", pos);
|
||||
int pos2 = sData.find(L">", pos);
|
||||
size_t pos1 = sData.rfind(L"<", pos);
|
||||
size_t pos2 = sData.find(L">", pos);
|
||||
|
||||
if (pos1 > 0 && pos2 > 0)
|
||||
if (pos1 != std::wstring::npos && pos2 != std::wstring::npos)
|
||||
{
|
||||
sData.erase(sData.begin() + pos1, sData.begin() + pos2 + 1);
|
||||
}
|
||||
@ -3053,7 +3134,7 @@ namespace NExtractTools
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX: sCTTo = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM: sCTTo = _T("application/vnd.ms-word.template.macroEnabledTemplate.main+xml");break;
|
||||
}
|
||||
nRes = replaceContentType(sFrom, sCTFrom, sCTTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
nRes = replaceContentType(sFrom, sCTFrom, sCTTo);
|
||||
}
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
@ -3285,7 +3366,7 @@ namespace NExtractTools
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX: sCTTo = _T("application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM: sCTTo = _T("application/vnd.ms-excel.template.macroEnabled.main+xml");break;
|
||||
}
|
||||
nRes = replaceContentType(sFrom, sCTFrom, sCTTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
nRes = replaceContentType(sFrom, sCTFrom, sCTTo);
|
||||
}
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
@ -3495,7 +3576,7 @@ namespace NExtractTools
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM: sCTTo = _T("application/vnd.ms-powerpoint.template.macroEnabled.main+xml");break;
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM: sCTTo = _T("application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml");break;
|
||||
}
|
||||
nRes = replaceContentType(sFrom, sCTFrom, sCTTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
nRes = replaceContentType(sFrom, sCTFrom, sCTTo);
|
||||
}
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
@ -4052,6 +4133,17 @@ namespace NExtractTools
|
||||
}break;
|
||||
case TCD_DOCT2DOCX:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX);
|
||||
result = doct2docx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_DOCT2DOTX:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX);
|
||||
result = doct2docx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_DOCT2DOCM:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM);
|
||||
result = doct2docx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_XLSX2XLST:
|
||||
@ -4060,6 +4152,17 @@ namespace NExtractTools
|
||||
}break;
|
||||
case TCD_XLST2XLSX:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX);
|
||||
result = xlst2xlsx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_XLST2XLSM:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM);
|
||||
result = xlst2xlsx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_XLST2XLTX:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX);
|
||||
result = xlst2xlsx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_PPTX2PPTT:
|
||||
@ -4068,8 +4171,19 @@ namespace NExtractTools
|
||||
}break;
|
||||
case TCD_PPTT2PPTX:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX);
|
||||
result = pptt2pptx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
}break;
|
||||
case TCD_PPTT2PPTM:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM);
|
||||
result = pptt2pptx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_PPTT2POTX:
|
||||
{
|
||||
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX);
|
||||
result = pptt2pptx (sFileFrom, sFileTo, sTempDir, bFromChanges, sThemeDir, oInputParams);
|
||||
}break;
|
||||
case TCD_DOTX2DOCX:
|
||||
{
|
||||
result = dotx2docx (sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
|
||||
@ -41,27 +41,27 @@ namespace NExtractTools
|
||||
{
|
||||
TConversionDirection res = TCD_ERROR;
|
||||
|
||||
int nExt1Pos = sFile1.rfind(_T('.'));
|
||||
int nExt2Pos = sFile2.rfind(_T('.'));
|
||||
size_t nExt1Pos = sFile1.rfind(_T('.'));
|
||||
size_t nExt2Pos = sFile2.rfind(_T('.'));
|
||||
|
||||
// check for directory (zip task)
|
||||
int nSeparator1Pos = sFile1.rfind(_T('/'));
|
||||
if (-1 == nSeparator1Pos)
|
||||
size_t nSeparator1Pos = sFile1.rfind(_T('/'));
|
||||
if (std::wstring::npos == nSeparator1Pos)
|
||||
{
|
||||
nSeparator1Pos = sFile1.rfind(_T('\\'));
|
||||
}
|
||||
|
||||
// check for directory (unzip task)
|
||||
int nSeparator2Pos = sFile2.rfind(_T('/'));
|
||||
if (-1 == nSeparator2Pos)
|
||||
if (std::wstring::npos == nSeparator2Pos)
|
||||
{
|
||||
nSeparator2Pos = sFile2.rfind(_T('\\'));
|
||||
}
|
||||
|
||||
|
||||
// check for directory in name
|
||||
bool bIsFile1Directory = ((-1 != nSeparator1Pos) && (nExt1Pos < nSeparator1Pos)); // i.e: /root1/child1.lalala/folder
|
||||
bool bIsFile2Directory = ((-1 != nSeparator2Pos) && (nExt2Pos < nSeparator2Pos));
|
||||
bool bIsFile1Directory = ((std::wstring::npos != nSeparator1Pos) && (nExt1Pos < nSeparator1Pos)); // i.e: /root1/child1.lalala/folder
|
||||
bool bIsFile2Directory = ((std::wstring::npos != nSeparator2Pos) && (nExt2Pos < nSeparator2Pos));
|
||||
|
||||
// automatic zip/unzip task detection
|
||||
if (bIsFile1Directory)
|
||||
@ -184,27 +184,31 @@ namespace NExtractTools
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".docx"))) res = TCD_DOCT2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".docm"))) res = TCD_DOCT2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".docm"))) res = TCD_DOCT2DOCM;
|
||||
else if (0 == sExt2.compare(_T(".dotx"))) res = TCD_DOCT2DOTX;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_T2BIN;
|
||||
else if (0 == sExt2.compare(_T(".rtf"))) res = TCD_DOCT2RTF;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".xlsx"))) res = TCD_XLST2XLSX;
|
||||
else if (0 == sExt2.compare(_T(".xlsm"))) res = TCD_XLST2XLSX;
|
||||
else if (0 == sExt2.compare(_T(".xlsm"))) res = TCD_XLST2XLSM;
|
||||
else if (0 == sExt2.compare(_T(".xltx"))) res = TCD_XLST2XLTX;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_T2BIN;
|
||||
else if (0 == sExt2.compare(_T(".csv"))) res = TCD_XLST2CSV;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".pptx"))) res = TCD_PPTT2PPTX;
|
||||
else if (0 == sExt2.compare(_T(".pptm"))) res = TCD_PPTT2PPTX;
|
||||
else if (0 == sExt2.compare(_T(".pptm"))) res = TCD_PPTT2PPTM;
|
||||
else if (0 == sExt2.compare(_T(".potx"))) res = TCD_PPTT2POTX;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_T2BIN;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_WORD:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".docx"))) res = TCD_DOCT_BIN2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".docm"))) res = TCD_DOCT_BIN2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".dotx"))) res = TCD_DOCT_BIN2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_BIN2T;
|
||||
else if (0 == sExt2.compare(_T(".rtf"))) res = TCD_DOCT_BIN2RTF;
|
||||
}break;
|
||||
@ -212,6 +216,7 @@ namespace NExtractTools
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".xlsx"))) res = TCD_XLST_BIN2XLSX;
|
||||
else if (0 == sExt2.compare(_T(".xlsm"))) res = TCD_XLST_BIN2XLSX;
|
||||
else if (0 == sExt2.compare(_T(".xltx"))) res = TCD_XLST_BIN2XLSX;
|
||||
else if (0 == sExt2.compare(_T(".xlst"))) res = TCD_BIN2T;
|
||||
else if (0 == sExt2.compare(_T(".csv"))) res = TCD_XLST_BIN2CSV;
|
||||
}break;
|
||||
@ -219,6 +224,7 @@ namespace NExtractTools
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".pptx"))) res = TCD_PPTT_BIN2PPTX;
|
||||
else if (0 == sExt2.compare(_T(".pptm"))) res = TCD_PPTT_BIN2PPTX;
|
||||
else if (0 == sExt2.compare(_T(".potx"))) res = TCD_PPTT_BIN2PPTX;
|
||||
else if (0 == sExt2.compare(_T(".pptt"))) res = TCD_BIN2T;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_PDF:
|
||||
|
||||
@ -63,6 +63,8 @@ namespace NExtractTools
|
||||
|
||||
TCD_DOCX2DOCT,
|
||||
TCD_DOCT2DOCX,
|
||||
TCD_DOCT2DOTX,
|
||||
TCD_DOCT2DOCM,
|
||||
TCD_DOCX2DOCT_BIN,
|
||||
TCD_DOCT_BIN2DOCX,
|
||||
TCD_DOTX2DOCX,
|
||||
@ -72,6 +74,8 @@ namespace NExtractTools
|
||||
|
||||
TCD_XLSX2XLST,
|
||||
TCD_XLST2XLSX,
|
||||
TCD_XLST2XLSM,
|
||||
TCD_XLST2XLTX,
|
||||
TCD_XLSX2XLST_BIN,
|
||||
TCD_XLST_BIN2XLSX,
|
||||
TCD_XLTX2XLSX,
|
||||
@ -81,6 +85,8 @@ namespace NExtractTools
|
||||
|
||||
TCD_PPTX2PPTT,
|
||||
TCD_PPTT2PPTX,
|
||||
TCD_PPTT2POTX,
|
||||
TCD_PPTT2PPTM,
|
||||
TCD_PPTX2PPTT_BIN,
|
||||
TCD_PPTT_BIN2PPTX,
|
||||
TCD_PPSX2PPTX,
|
||||
|
||||
@ -81,7 +81,8 @@ namespace BinXlsxRW
|
||||
Worksheets = 4,
|
||||
CalcChain = 5,
|
||||
App = 6,
|
||||
Core = 7
|
||||
Core = 7,
|
||||
PersonList = 8
|
||||
};}
|
||||
|
||||
namespace c_oSerStylesTypes{enum c_oSerStylesTypes
|
||||
@ -930,7 +931,8 @@ namespace BinXlsxRW
|
||||
WidthMM = 14,
|
||||
HeightMM = 15,
|
||||
MoveWithCells = 16,
|
||||
SizeWithCells = 17
|
||||
SizeWithCells = 17,
|
||||
ThreadedComment = 18
|
||||
};}
|
||||
namespace c_oSer_CommentData{enum c_oSer_CommentData
|
||||
{
|
||||
@ -945,6 +947,28 @@ namespace BinXlsxRW
|
||||
Reply = 8,
|
||||
OOTime = 9
|
||||
};}
|
||||
namespace c_oSer_ThreadedComment{enum c_oSer_ThreadedComment
|
||||
{
|
||||
dT = 0,
|
||||
personId = 1,
|
||||
id = 2,
|
||||
done = 3,
|
||||
text = 4,
|
||||
mention = 5,
|
||||
reply = 6,
|
||||
mentionpersonId = 7,
|
||||
mentionId = 8,
|
||||
startIndex = 9,
|
||||
length = 10
|
||||
};}
|
||||
namespace c_oSer_Person{enum c_oSer_Person
|
||||
{
|
||||
person = 0,
|
||||
id = 1,
|
||||
providerId = 2,
|
||||
userId = 3,
|
||||
displayName = 4
|
||||
};}
|
||||
namespace c_oSer_ConditionalFormatting{enum c_oSer_ConditionalFormatting
|
||||
{
|
||||
Pivot = 0,
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinkPath.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Comments/ThreadedComments.h"
|
||||
|
||||
namespace BinXlsxRW
|
||||
{
|
||||
@ -2908,6 +2909,54 @@ void BinaryWorkbookTableWriter::WriteDefinedName(const OOX::Spreadsheet::CDefine
|
||||
}
|
||||
}
|
||||
|
||||
BinaryPersonTableWriter::BinaryPersonTableWriter(NSBinPptxRW::CBinaryFileWriter &oCBufferedStream):m_oBcw(oCBufferedStream)
|
||||
{
|
||||
}
|
||||
void BinaryPersonTableWriter::Write(OOX::Spreadsheet::CPersonList& oPersonList)
|
||||
{
|
||||
int nStart = m_oBcw.WriteItemWithLengthStart();
|
||||
WritePersonList(oPersonList);
|
||||
m_oBcw.WriteItemWithLengthEnd(nStart);
|
||||
}
|
||||
void BinaryPersonTableWriter::WritePersonList(OOX::Spreadsheet::CPersonList& oPersonList)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
for(size_t i = 0; i < oPersonList.m_arrItems.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Person::person);
|
||||
WritePerson(*oPersonList.m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void BinaryPersonTableWriter::WritePerson(OOX::Spreadsheet::CPerson& oPerson)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(oPerson.id.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Person::id);
|
||||
m_oBcw.m_oStream.WriteStringW3(oPerson.id.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oPerson.providerId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Person::providerId);
|
||||
m_oBcw.m_oStream.WriteStringW3(oPerson.providerId.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oPerson.userId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Person::userId);
|
||||
m_oBcw.m_oStream.WriteStringW3(oPerson.userId.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oPerson.displayName.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Person::displayName);
|
||||
m_oBcw.m_oStream.WriteStringW3(oPerson.displayName.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
|
||||
BinaryWorksheetTableWriter::BinaryWorksheetTableWriter(NSBinPptxRW::CBinaryFileWriter &oCBufferedStream, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter):
|
||||
m_oBcw(oCBufferedStream),m_pEmbeddedFontsManager(pEmbeddedFontsManager),m_pIndexedColors(pIndexedColors),m_pTheme(pTheme),m_oFontProcessor(oFontProcessor),m_pOfficeDrawingConverter(pOfficeDrawingConverter)
|
||||
{
|
||||
@ -5048,7 +5097,7 @@ void BinaryWorksheetTableWriter::WriteComments(boost::unordered_map<std::wstring
|
||||
//записываем тот обьект, который был в бинарнике, подменяем только текст, который мог быть отредактирован в Excel
|
||||
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Comment);
|
||||
WriteComment(oComment, aCommentDatas, oComment.m_oText);
|
||||
WriteComment(oComment, aCommentDatas);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
|
||||
for(size_t i = 0, length = aCommentDatas.size(); i < length; ++i)
|
||||
@ -5099,7 +5148,7 @@ void BinaryWorksheetTableWriter::getSavedComment(OOX::Spreadsheet::CCommentItem&
|
||||
}
|
||||
}
|
||||
}
|
||||
void BinaryWorksheetTableWriter::WriteComment(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas, nullable<OOX::Spreadsheet::CSi>& oCommentText)
|
||||
void BinaryWorksheetTableWriter::WriteComment(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
int nRow = 0;
|
||||
@ -5121,7 +5170,7 @@ void BinaryWorksheetTableWriter::WriteComment(OOX::Spreadsheet::CCommentItem& oC
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_Comments::CommentDatas);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
|
||||
nCurPos = m_oBcw.WriteItemWithLengthStart();
|
||||
WriteCommentData(oComment, aCommentDatas, oCommentText);
|
||||
WriteCommentData(oComment, aCommentDatas);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
|
||||
if(oComment.m_nLeft.IsInit())
|
||||
@ -5208,8 +5257,16 @@ void BinaryWorksheetTableWriter::WriteComment(OOX::Spreadsheet::CCommentItem& oC
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
|
||||
m_oBcw.m_oStream.WriteBOOL(oComment.m_bSize.get());
|
||||
}
|
||||
if(NULL != oComment.m_pThreadedComment)
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_Comments::ThreadedComment);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
|
||||
nCurPos = m_oBcw.WriteItemWithLengthStart();
|
||||
WriteThreadedComment(*oComment.m_pThreadedComment, oComment.m_bThreadedCommentCopy);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void BinaryWorksheetTableWriter::WriteCommentData(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas, nullable<OOX::Spreadsheet::CSi>& oCommentText)
|
||||
void BinaryWorksheetTableWriter::WriteCommentData(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(aCommentDatas.size() > 0)
|
||||
@ -5218,20 +5275,20 @@ void BinaryWorksheetTableWriter::WriteCommentData(OOX::Spreadsheet::CCommentItem
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Comments::CommentData);
|
||||
if(0 == i)
|
||||
WriteCommentDataContent(&oComment, aCommentDatas[i], &oCommentText);
|
||||
WriteCommentDataContent(&oComment, aCommentDatas[i]);
|
||||
else
|
||||
WriteCommentDataContent(NULL, aCommentDatas[i], NULL);
|
||||
WriteCommentDataContent(NULL, aCommentDatas[i]);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_Comments::CommentData);
|
||||
WriteCommentDataContent(&oComment, NULL, &oCommentText);
|
||||
WriteCommentDataContent(&oComment, NULL);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void BinaryWorksheetTableWriter::WriteCommentDataContent(OOX::Spreadsheet::CCommentItem* pComment, SerializeCommon::CommentData* pCommentData, nullable<OOX::Spreadsheet::CSi>* pCommentText)
|
||||
void BinaryWorksheetTableWriter::WriteCommentDataContent(OOX::Spreadsheet::CCommentItem* pComment, SerializeCommon::CommentData* pCommentData)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(NULL != pCommentData && !pCommentData->sText.empty())
|
||||
@ -5239,10 +5296,10 @@ void BinaryWorksheetTableWriter::WriteCommentDataContent(OOX::Spreadsheet::CComm
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::Text);
|
||||
m_oBcw.m_oStream.WriteStringW(pCommentData->sText);
|
||||
}
|
||||
else if(NULL != pCommentText && pCommentText->IsInit())
|
||||
else if(NULL != pComment && pComment->m_oText.IsInit())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::Text);
|
||||
m_oBcw.m_oStream.WriteStringW((*pCommentText)->ToString());
|
||||
m_oBcw.m_oStream.WriteStringW(pComment->m_oText->ToString());
|
||||
}
|
||||
if(NULL != pCommentData)
|
||||
{
|
||||
@ -5266,11 +5323,6 @@ void BinaryWorksheetTableWriter::WriteCommentDataContent(OOX::Spreadsheet::CComm
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::UserName);
|
||||
m_oBcw.m_oStream.WriteStringW(pCommentData->sUserName);
|
||||
}
|
||||
if (!pCommentData->sUserName.empty())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::UserName);
|
||||
m_oBcw.m_oStream.WriteStringW(pCommentData->sUserName);
|
||||
}
|
||||
if (!pCommentData->sQuoteText.empty())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::QuoteText);
|
||||
@ -5311,10 +5363,94 @@ void BinaryWorksheetTableWriter::WriteCommentReplies(std::vector<SerializeCommon
|
||||
{
|
||||
SerializeCommon::CommentData* pReply = aReplies[i];
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_CommentData::Reply);
|
||||
WriteCommentDataContent(NULL, pReply, NULL);
|
||||
WriteCommentDataContent(NULL, pReply);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void BinaryWorksheetTableWriter::WriteThreadedComment(OOX::Spreadsheet::CThreadedComment& oThreadedComment, bool bThreadedCommentCopy)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
|
||||
if(oThreadedComment.dT.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::dT);
|
||||
m_oBcw.m_oStream.WriteStringW3(oThreadedComment.dT->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oThreadedComment.personId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::personId);
|
||||
m_oBcw.m_oStream.WriteStringW3(oThreadedComment.personId->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(bThreadedCommentCopy)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::id);
|
||||
m_oBcw.m_oStream.WriteStringW3(L"{" + XmlUtils::GenerateGuid() + L"}");
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
else if(oThreadedComment.id.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::id);
|
||||
m_oBcw.m_oStream.WriteStringW3(oThreadedComment.id->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oThreadedComment.done.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::done);
|
||||
m_oBcw.m_oStream.WriteBOOL(oThreadedComment.done.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oThreadedComment.m_oText.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::text);
|
||||
m_oBcw.m_oStream.WriteStringW3(oThreadedComment.m_oText->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oThreadedComment.m_oMentions.IsInit())
|
||||
{
|
||||
for(size_t i = 0; i < oThreadedComment.m_oMentions->m_arrItems.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::mention);
|
||||
WriteThreadedCommentMention(*oThreadedComment.m_oMentions->m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
for(size_t i = 0; i < oThreadedComment.m_arrReplies.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::reply);
|
||||
WriteThreadedComment(*oThreadedComment.m_arrReplies[i], bThreadedCommentCopy);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void BinaryWorksheetTableWriter::WriteThreadedCommentMention(OOX::Spreadsheet::CThreadedCommentMention& oMention)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(oMention.mentionpersonId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::mentionpersonId);
|
||||
m_oBcw.m_oStream.WriteStringW3(oMention.mentionpersonId->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oMention.mentionId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::mentionId);
|
||||
m_oBcw.m_oStream.WriteStringW3(oMention.mentionId->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oMention.startIndex.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::startIndex);
|
||||
m_oBcw.m_oStream.WriteULONG(oMention.startIndex->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(oMention.length.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ThreadedComment::length);
|
||||
m_oBcw.m_oStream.WriteULONG(oMention.length->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void BinaryWorksheetTableWriter::WriteSheetPr(const OOX::Spreadsheet::CSheetPr& oSheetPr)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
@ -6485,6 +6621,14 @@ void BinaryFileWriter::intoBindoc(OOX::Spreadsheet::CXlsx &oXlsx, NSBinPptxRW::C
|
||||
oBinarySharedStringTableWriter.Write(*oXlsx.m_pSharedStrings, pIndexedColors, oXlsx.GetTheme(), m_oFontProcessor);
|
||||
WriteTableEnd(nCurPos);
|
||||
}
|
||||
|
||||
if(oXlsx.m_pWorkbook && oXlsx.m_pWorkbook->m_pPersonList)
|
||||
{
|
||||
nCurPos = WriteTableStart(c_oSerTableTypes::PersonList);
|
||||
BinaryPersonTableWriter oBinaryPersonTableWriter(oBufferedStream);
|
||||
oBinaryPersonTableWriter.Write(*oXlsx.m_pWorkbook->m_pPersonList);
|
||||
WriteTableEnd(nCurPos);
|
||||
}
|
||||
//Styles
|
||||
if(oXlsx.m_pStyles)
|
||||
{
|
||||
|
||||
@ -58,6 +58,17 @@
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Table/Connections.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Table/QueryTable.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CPerson;
|
||||
class CPersonList;
|
||||
class CThreadedComment;
|
||||
class CThreadedCommentMention;
|
||||
}
|
||||
}
|
||||
|
||||
namespace BinXlsxRW
|
||||
{
|
||||
class BinaryTableWriter
|
||||
@ -175,6 +186,15 @@ namespace BinXlsxRW
|
||||
void WriteDdeValue(const OOX::Spreadsheet::CDdeValue& ddeValue);
|
||||
void WriteDefinedName(const OOX::Spreadsheet::CDefinedName& definedName);
|
||||
};
|
||||
class BinaryPersonTableWriter
|
||||
{
|
||||
BinaryCommonWriter m_oBcw;
|
||||
public:
|
||||
BinaryPersonTableWriter(NSBinPptxRW::CBinaryFileWriter &oCBufferedStream);
|
||||
void Write(OOX::Spreadsheet::CPersonList& oPersonList);
|
||||
void WritePersonList(OOX::Spreadsheet::CPersonList& oPersonList);
|
||||
void WritePerson(OOX::Spreadsheet::CPerson& oPerson);
|
||||
};
|
||||
class BinaryWorksheetTableWriter
|
||||
{
|
||||
BinaryCommonWriter m_oBcw;
|
||||
@ -224,10 +244,12 @@ namespace BinXlsxRW
|
||||
void WriteExt(const OOX::Spreadsheet::CExt& oExt);
|
||||
void WriteComments(boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>& mapComments);
|
||||
void getSavedComment(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aDatas);
|
||||
void WriteComment(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas, nullable<OOX::Spreadsheet::CSi>& oCommentText);
|
||||
void WriteCommentData(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas, nullable<OOX::Spreadsheet::CSi>& oCommentText);
|
||||
void WriteCommentDataContent(OOX::Spreadsheet::CCommentItem* pComment, SerializeCommon::CommentData* pCommentData, nullable<OOX::Spreadsheet::CSi>* pCommentText);
|
||||
void WriteComment(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas);
|
||||
void WriteCommentData(OOX::Spreadsheet::CCommentItem& oComment, std::vector<SerializeCommon::CommentData*>& aCommentDatas);
|
||||
void WriteCommentDataContent(OOX::Spreadsheet::CCommentItem* pComment, SerializeCommon::CommentData* pCommentData);
|
||||
void WriteCommentReplies(std::vector<SerializeCommon::CommentData*>& aReplies);
|
||||
void WriteThreadedComment(OOX::Spreadsheet::CThreadedComment& oThreadedComment, bool bThreadedCommentCopy);
|
||||
void WriteThreadedCommentMention(OOX::Spreadsheet::CThreadedCommentMention& oMention);
|
||||
void WriteSheetPr(const OOX::Spreadsheet::CSheetPr& oSheetPr);
|
||||
void WritemHeaderFooter(const OOX::Spreadsheet::CHeaderFooter& oHeaderFooter);
|
||||
void WritemRowColBreaks(const OOX::Spreadsheet::CRowColBreaks& oRowColBreaks);
|
||||
|
||||
@ -67,6 +67,8 @@
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Comments/ThreadedComments.h"
|
||||
|
||||
namespace BinXlsxRW
|
||||
{
|
||||
#define SEEK_TO_POS_START(type) \
|
||||
@ -3131,6 +3133,11 @@ int BinaryCommentReader::ReadComment(BYTE type, long length, void* poResult)
|
||||
pNewComment->m_bMove = m_oBufferedStream.GetBool();
|
||||
else if ( c_oSer_Comments::SizeWithCells == type )
|
||||
pNewComment->m_bSize = m_oBufferedStream.GetBool();
|
||||
else if ( c_oSer_Comments::ThreadedComment == type )
|
||||
{
|
||||
pNewComment->m_pThreadedComment = new OOX::Spreadsheet::CThreadedComment();
|
||||
READ1_DEF(length, res, this->ReadThreadedComment, pNewComment->m_pThreadedComment);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -3203,6 +3210,77 @@ int BinaryCommentReader::ReadCommentReplies(BYTE type, long length, void* poResu
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int BinaryCommentReader::ReadThreadedComment(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Spreadsheet::CThreadedComment* pThreadedComment = static_cast<OOX::Spreadsheet::CThreadedComment*>(poResult);
|
||||
if ( c_oSer_ThreadedComment::dT == type )
|
||||
{
|
||||
pThreadedComment->dT = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::personId == type )
|
||||
{
|
||||
pThreadedComment->personId = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::id == type )
|
||||
{
|
||||
pThreadedComment->id = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::done == type )
|
||||
{
|
||||
pThreadedComment->done = m_oBufferedStream.GetBool();
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::text == type )
|
||||
{
|
||||
pThreadedComment->m_oText.Init();
|
||||
pThreadedComment->m_oText->m_sText = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::mention == type )
|
||||
{
|
||||
OOX::Spreadsheet::CThreadedCommentMention* pMention = new OOX::Spreadsheet::CThreadedCommentMention();
|
||||
READ1_DEF(length, res, this->ReadThreadedCommentMention, pMention);
|
||||
if(!pThreadedComment->m_oMentions.IsInit())
|
||||
{
|
||||
pThreadedComment->m_oMentions.Init();
|
||||
}
|
||||
pThreadedComment->m_oMentions->m_arrItems.push_back(pMention);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::reply == type )
|
||||
{
|
||||
OOX::Spreadsheet::CThreadedComment* pReply = new OOX::Spreadsheet::CThreadedComment();
|
||||
READ1_DEF(length, res, this->ReadThreadedComment, pReply);
|
||||
pThreadedComment->m_arrReplies.push_back(pReply);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int BinaryCommentReader::ReadThreadedCommentMention(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Spreadsheet::CThreadedCommentMention* pMention = static_cast<OOX::Spreadsheet::CThreadedCommentMention*>(poResult);
|
||||
if ( c_oSer_ThreadedComment::mentionpersonId == type )
|
||||
{
|
||||
pMention->mentionpersonId = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::mentionId == type )
|
||||
{
|
||||
pMention->mentionId = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::startIndex == type )
|
||||
{
|
||||
pMention->startIndex.Init();
|
||||
pMention->startIndex->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else if ( c_oSer_ThreadedComment::length == type )
|
||||
{
|
||||
pMention->length.Init();
|
||||
pMention->length->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
void BinaryCommentReader::parseCommentData(SerializeCommon::CommentData* pCommentData, OOX::Spreadsheet::CSi& oSi)
|
||||
{
|
||||
if(NULL != pCommentData && false == pCommentData->sText.empty())
|
||||
@ -3234,6 +3312,27 @@ void BinaryCommentReader::addCommentRun(OOX::Spreadsheet::CSi& oSi, const std::w
|
||||
pRun->m_arrItems.push_back(pText);
|
||||
oSi.m_arrItems.push_back(pRun);
|
||||
}
|
||||
void BinaryCommentReader::addThreadedComment(OOX::Spreadsheet::CSi& oSi, OOX::Spreadsheet::CThreadedComment* pThreadedComment)
|
||||
{
|
||||
OOX::Spreadsheet::CText* pText = new OOX::Spreadsheet::CText();
|
||||
pText->m_sText.append(L"[Threaded comment]\n\nYour version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more: https://go.microsoft.com/fwlink/?linkid=870924\n\n");
|
||||
if(pThreadedComment->m_oText.IsInit())
|
||||
{
|
||||
pText->m_sText.append(L"Comment:\n ");
|
||||
pText->m_sText.append(pThreadedComment->m_oText->ToString());
|
||||
pText->m_sText.append(L"\n\n");
|
||||
}
|
||||
for(size_t i = 0; i < pThreadedComment->m_arrReplies.size(); ++i)
|
||||
{
|
||||
if(pThreadedComment->m_arrReplies[i]->m_oText.IsInit())
|
||||
{
|
||||
pText->m_sText.append(L"Reply:\n ");
|
||||
pText->m_sText.append(pThreadedComment->m_arrReplies[i]->m_oText->ToString());
|
||||
pText->m_sText.append(L"\n\n");
|
||||
}
|
||||
}
|
||||
oSi.m_arrItems.push_back(pText);
|
||||
}
|
||||
|
||||
BinaryWorksheetsTableReader::BinaryWorksheetsTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook,
|
||||
OOX::Spreadsheet::CSharedStrings* pSharedStrings, std::vector<OOX::Spreadsheet::CWorksheet*>& arWorksheets, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets,
|
||||
@ -3517,61 +3616,7 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_map<BYTE, std::v
|
||||
SEEK_TO_POS_START(c_oSerWorksheetsTypes::Comments);
|
||||
BinaryCommentReader oBinaryCommentReader(m_oBufferedStream, m_pCurWorksheet.GetPointer());
|
||||
oBinaryCommentReader.Read(length, poResult);
|
||||
|
||||
if(false == m_pCurWorksheet->m_mapComments.empty())
|
||||
{
|
||||
m_pCurVmlDrawing->m_mapComments = &m_pCurWorksheet->m_mapComments;
|
||||
|
||||
boost::unordered_map<std::wstring, unsigned int> mapByAuthors;
|
||||
OOX::Spreadsheet::CComments* pComments = new OOX::Spreadsheet::CComments(NULL);
|
||||
|
||||
pComments->m_oCommentList.Init();
|
||||
std::vector<OOX::Spreadsheet::CComment*>& aComments = pComments->m_oCommentList->m_arrItems;
|
||||
|
||||
pComments->m_oAuthors.Init();
|
||||
|
||||
for (boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>::const_iterator it = m_pCurWorksheet->m_mapComments.begin(); it != m_pCurWorksheet->m_mapComments.end(); ++it)
|
||||
{
|
||||
if(it->second->IsValid())
|
||||
{
|
||||
OOX::Spreadsheet::CCommentItem* pCommentItem = it->second;
|
||||
OOX::Spreadsheet::CComment* pNewComment = new OOX::Spreadsheet::CComment();
|
||||
if(pCommentItem->m_nRow.IsInit() && pCommentItem->m_nCol.IsInit())
|
||||
{
|
||||
pNewComment->m_oRef.Init();
|
||||
pNewComment->m_oRef->SetValue(OOX::Spreadsheet::CCell::combineRef(pCommentItem->m_nRow.get(), pCommentItem->m_nCol.get()));
|
||||
}
|
||||
|
||||
if(pCommentItem->m_sAuthor.IsInit())
|
||||
{
|
||||
const std::wstring& sAuthor = pCommentItem->m_sAuthor.get();
|
||||
boost::unordered_map<std::wstring, unsigned int>::const_iterator pFind = mapByAuthors.find(sAuthor);
|
||||
|
||||
int nAuthorId;
|
||||
if(pFind != mapByAuthors.end())
|
||||
nAuthorId = (int)pFind->second;
|
||||
else
|
||||
{
|
||||
nAuthorId = (int)mapByAuthors.size();
|
||||
|
||||
mapByAuthors.insert(std::make_pair(sAuthor, nAuthorId));
|
||||
|
||||
pComments->m_oAuthors->m_arrItems.push_back( sAuthor );
|
||||
}
|
||||
pNewComment->m_oAuthorId.Init();
|
||||
pNewComment->m_oAuthorId->SetValue(nAuthorId);
|
||||
}
|
||||
|
||||
OOX::Spreadsheet::CSi* pSi = pCommentItem->m_oText.GetPointerEmptyNullable();
|
||||
if(NULL != pSi)
|
||||
pNewComment->m_oText.reset(pSi);
|
||||
aComments.push_back(pNewComment);
|
||||
}
|
||||
}
|
||||
|
||||
NSCommon::smart_ptr<OOX::File> pCommentsFile(pComments);
|
||||
m_pCurWorksheet->Add(pCommentsFile);
|
||||
}
|
||||
WriteComments();
|
||||
SEEK_TO_POS_END2();
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
SEEK_TO_POS_START(c_oSerWorksheetsTypes::Drawings);
|
||||
@ -3715,6 +3760,102 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_map<BYTE, std::v
|
||||
m_pCurWorksheet->toXMLEnd(oStreamWriter);
|
||||
return res;
|
||||
}
|
||||
void BinaryWorksheetsTableReader::WriteComments()
|
||||
{
|
||||
if(false == m_pCurWorksheet->m_mapComments.empty())
|
||||
{
|
||||
m_pCurVmlDrawing->m_mapComments = &m_pCurWorksheet->m_mapComments;
|
||||
|
||||
boost::unordered_map<std::wstring, unsigned int> mapByAuthors;
|
||||
OOX::Spreadsheet::CComments* pComments = new OOX::Spreadsheet::CComments(NULL);
|
||||
|
||||
pComments->m_oCommentList.Init();
|
||||
std::vector<OOX::Spreadsheet::CComment*>& aComments = pComments->m_oCommentList->m_arrItems;
|
||||
|
||||
pComments->m_oAuthors.Init();
|
||||
|
||||
OOX::Spreadsheet::CThreadedComments* pThreadedComments = new OOX::Spreadsheet::CThreadedComments(NULL);
|
||||
|
||||
for (boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>::const_iterator it = m_pCurWorksheet->m_mapComments.begin(); it != m_pCurWorksheet->m_mapComments.end(); ++it)
|
||||
{
|
||||
OOX::Spreadsheet::CCommentItem* pCommentItem = it->second;
|
||||
if(pCommentItem->IsValid())
|
||||
{
|
||||
OOX::Spreadsheet::CComment* pNewComment = new OOX::Spreadsheet::CComment();
|
||||
if(pCommentItem->m_nRow.IsInit() && pCommentItem->m_nCol.IsInit())
|
||||
{
|
||||
pNewComment->m_oRef.Init();
|
||||
pNewComment->m_oRef->SetValue(OOX::Spreadsheet::CCell::combineRef(pCommentItem->m_nRow.get(), pCommentItem->m_nCol.get()));
|
||||
}
|
||||
if(NULL != pCommentItem->m_pThreadedComment)
|
||||
{
|
||||
OOX::Spreadsheet::CThreadedComment* pThreadedComment = pCommentItem->m_pThreadedComment;
|
||||
if( pNewComment->m_oRef.IsInit())
|
||||
{
|
||||
pThreadedComment->ref = pNewComment->m_oRef->ToString();
|
||||
}
|
||||
if(!pThreadedComment->id.IsInit())
|
||||
{
|
||||
pThreadedComment->id = L"{" + XmlUtils::GenerateGuid() + L"}";
|
||||
}
|
||||
pNewComment->m_oUid = pThreadedComment->id->ToString();
|
||||
pCommentItem->m_sAuthor = L"tc=" + pThreadedComment->id->ToString();
|
||||
|
||||
pCommentItem->m_oText.Init();
|
||||
BinaryCommentReader::addThreadedComment(pCommentItem->m_oText.get2(), pThreadedComment);
|
||||
|
||||
pThreadedComments->m_arrItems.push_back(pThreadedComment);
|
||||
for(size_t i = 0; i < pThreadedComment->m_arrReplies.size(); ++i)
|
||||
{
|
||||
pThreadedComment->m_arrReplies[i]->parentId = pThreadedComment->id->ToString();
|
||||
pThreadedComment->m_arrReplies[i]->ref = pThreadedComment->ref.get();
|
||||
if(!pThreadedComment->m_arrReplies[i]->id.IsInit())
|
||||
{
|
||||
pThreadedComment->m_arrReplies[i]->id = L"{" + XmlUtils::GenerateGuid() + L"}";
|
||||
}
|
||||
pThreadedComments->m_arrItems.push_back(pThreadedComment->m_arrReplies[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(pCommentItem->m_sAuthor.IsInit())
|
||||
{
|
||||
const std::wstring& sAuthor = pCommentItem->m_sAuthor.get();
|
||||
boost::unordered_map<std::wstring, unsigned int>::const_iterator pFind = mapByAuthors.find(sAuthor);
|
||||
|
||||
int nAuthorId;
|
||||
if(pFind != mapByAuthors.end())
|
||||
nAuthorId = (int)pFind->second;
|
||||
else
|
||||
{
|
||||
nAuthorId = (int)mapByAuthors.size();
|
||||
|
||||
mapByAuthors.insert(std::make_pair(sAuthor, nAuthorId));
|
||||
|
||||
pComments->m_oAuthors->m_arrItems.push_back( sAuthor );
|
||||
}
|
||||
pNewComment->m_oAuthorId.Init();
|
||||
pNewComment->m_oAuthorId->SetValue(nAuthorId);
|
||||
}
|
||||
pNewComment->m_oText.reset(pCommentItem->m_oText.GetPointerEmptyNullable());
|
||||
|
||||
aComments.push_back(pNewComment);
|
||||
}
|
||||
else if(NULL != pCommentItem->m_pThreadedComment)
|
||||
{
|
||||
RELEASEOBJECT(pCommentItem->m_pThreadedComment);
|
||||
for(size_t i = 0; i < pCommentItem->m_pThreadedComment->m_arrReplies.size(); ++i)
|
||||
{
|
||||
RELEASEOBJECT(pCommentItem->m_pThreadedComment->m_arrReplies[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSCommon::smart_ptr<OOX::File> pCommentsFile(pComments);
|
||||
m_pCurWorksheet->Add(pCommentsFile);
|
||||
NSCommon::smart_ptr<OOX::File> pThreadedCommentsFile(pThreadedComments);
|
||||
m_pCurWorksheet->Add(pThreadedCommentsFile);
|
||||
}
|
||||
}
|
||||
int BinaryWorksheetsTableReader::ReadPivotTable(BYTE type, long length, void* poResult)
|
||||
{
|
||||
PivotCachesTemp* pPivotCachesTemp = static_cast<PivotCachesTemp*>(poResult);
|
||||
@ -6333,6 +6474,58 @@ void BinaryOtherTableReader::ReadMediaItemSaveFilePath(const std::wstring& sTemp
|
||||
m_sCurSrc = sNewImagePath;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------------------
|
||||
BinaryPersonReader::BinaryPersonReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook):Binary_CommonReader(oBufferedStream),m_oWorkbook(oWorkbook)
|
||||
{
|
||||
}
|
||||
int BinaryPersonReader::Read()
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Spreadsheet::CPersonList* pPersonList = new OOX::Spreadsheet::CPersonList(NULL);
|
||||
READ_TABLE_DEF(res, this->ReadPersonList, pPersonList);
|
||||
smart_ptr<OOX::File> oFilePersonListFile(pPersonList);
|
||||
m_oWorkbook.Add(oFilePersonListFile);
|
||||
return res;
|
||||
}
|
||||
int BinaryPersonReader::ReadPersonList(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Spreadsheet::CPersonList* pPersonList = static_cast<OOX::Spreadsheet::CPersonList*>(poResult);
|
||||
if ( c_oSer_Person::person == type )
|
||||
{
|
||||
OOX::Spreadsheet::CPerson* pPerson = new OOX::Spreadsheet::CPerson();
|
||||
READ1_DEF(length, res, this->ReadPerson, pPerson);
|
||||
pPersonList->m_arrItems.push_back(pPerson);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int BinaryPersonReader::ReadPerson(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Spreadsheet::CPerson* pPerson = static_cast<OOX::Spreadsheet::CPerson*>(poResult);
|
||||
if ( c_oSer_Person::id == type )
|
||||
{
|
||||
pPerson->id = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_Person::providerId == type )
|
||||
{
|
||||
pPerson->providerId = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_Person::userId == type )
|
||||
{
|
||||
pPerson->userId = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else if ( c_oSer_Person::displayName == type )
|
||||
{
|
||||
pPerson->displayName = m_oBufferedStream.GetString3(length);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------------------
|
||||
BinaryFileReader::BinaryFileReader()
|
||||
{
|
||||
@ -6580,6 +6773,11 @@ int BinaryFileReader::ReadMainTable(OOX::Spreadsheet::CXlsx& oXlsx, NSBinPptxRW:
|
||||
oXlsx.Add(oCurFile);
|
||||
}
|
||||
break;
|
||||
case c_oSerTableTypes::PersonList:
|
||||
{
|
||||
res = BinaryPersonReader(oBufferedStream, *oXlsx.m_pWorkbook).Read();
|
||||
}
|
||||
break;
|
||||
case c_oSerTableTypes::Styles:
|
||||
{
|
||||
oXlsx.CreateStyles();
|
||||
|
||||
@ -48,6 +48,15 @@
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheDefinition.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheRecords.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CPersonList;
|
||||
class CThreadedComment;
|
||||
}
|
||||
}
|
||||
|
||||
namespace BinXlsxRW
|
||||
{
|
||||
class ImageObject
|
||||
@ -232,8 +241,11 @@ namespace BinXlsxRW
|
||||
int ReadCommentDatas(BYTE type, long length, void* poResult);
|
||||
int ReadCommentData(BYTE type, long length, void* poResult);
|
||||
int ReadCommentReplies(BYTE type, long length, void* poResult);
|
||||
int ReadThreadedComment(BYTE type, long length, void* poResult);
|
||||
int ReadThreadedCommentMention(BYTE type, long length, void* poResult);
|
||||
void parseCommentData(SerializeCommon::CommentData* pCommentData, OOX::Spreadsheet::CSi& oSi);
|
||||
void addCommentRun(OOX::Spreadsheet::CSi& oSi, const std::wstring& text, bool isBold);
|
||||
static void addThreadedComment(OOX::Spreadsheet::CSi& oSi, OOX::Spreadsheet::CThreadedComment* pThreadedComment);
|
||||
};
|
||||
class BinaryWorksheetsTableReader : public Binary_CommonReader
|
||||
{
|
||||
@ -324,6 +336,7 @@ namespace BinXlsxRW
|
||||
int ReadDataValidationsContent(BYTE type, long length, void* poResult);
|
||||
int ReadDataValidation(BYTE type, long length, void* poResult);
|
||||
|
||||
void WriteComments();
|
||||
void AddLineBreak(OOX::Spreadsheet::CSi& oSi);
|
||||
std::wstring GetControlVmlShape(void* pControl);
|
||||
};
|
||||
@ -349,6 +362,15 @@ namespace BinXlsxRW
|
||||
void ReadMediaItemSaveFileFILE(FILE* pFile);
|
||||
void ReadMediaItemSaveFilePath(const std::wstring& sTempPath);
|
||||
};
|
||||
class BinaryPersonReader : public Binary_CommonReader
|
||||
{
|
||||
OOX::Spreadsheet::CWorkbook& m_oWorkbook;
|
||||
public:
|
||||
BinaryPersonReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook);
|
||||
int Read();
|
||||
int ReadPersonList(BYTE type, long length, void* poResult);
|
||||
int ReadPerson(BYTE type, long length, void* poResult);
|
||||
};
|
||||
class BinaryFileReader
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user