Commit ea74d860 authored by konovalovsergey's avatar konovalovsergey

open/save footnote/endnote

parent a8a684bf
......@@ -64,6 +64,8 @@ namespace Writers
StylesWriter m_oStylesWriter;
NumberingWriter m_oNumberingWriter;
HeaderFooterWriter m_oHeaderFooterWriter;
FootnotesWriter m_oFootnotesWriter;
EndnotesWriter m_oEndnotesWriter;
SettingWriter m_oSettingWriter;
CommentsWriter m_oCommentsWriter;
ChartWriter m_oChartWriter;
......@@ -78,6 +80,8 @@ namespace Writers
m_pDrawingConverter(pDrawingConverter),m_sThemePath(sThemePath),m_bSaveChartAsImg(bSaveChartAsImg),
m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir),
m_oHeaderFooterWriter(sDirOutput, m_oContentTypesWriter),
m_oFootnotesWriter(sDirOutput, m_oContentTypesWriter),
m_oEndnotesWriter(sDirOutput, m_oContentTypesWriter),
m_oMediaWriter(sDirOutput),
m_oStylesWriter(sDirOutput, nVersion),
m_oNumberingWriter(sDirOutput, m_oContentTypesWriter),
......
......@@ -64,6 +64,12 @@ namespace Writers
static CString g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:ftr 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: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 wp14\">");
static CString g_string_ftr_End = _T("</w:ftr>");
static CString g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes 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: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 wp14\">");
static CString g_string_footnotes_End = _T("</w:footnotes>");
static CString g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes 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: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 wp14\">");
static CString g_string_endnotes_End = _T("</w:endnotes>");
class HeaderFooterWriter
{
CString m_sDir;
......@@ -122,5 +128,79 @@ namespace Writers
//return m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/") + sHeader, sFilename);
}
};
class FootnotesWriter
{
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
ContentWriter m_oNotesWriter;
FootnotesWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
void Write()
{
if(!IsEmpty())
{
CString sFilename = getFilename();
CString filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile;
oFile.CreateFile(filePath);
oFile.WriteStringUTF8(g_string_footnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_footnotes_End);
oFile.CloseFile();
//ContentType
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"));
}
}
CString getFilename()
{
return _T("footnotes.xml");
}
bool IsEmpty()
{
return !(m_oNotesWriter.m_oContent.GetCurSize() > 0);
}
};
class EndnotesWriter
{
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
ContentWriter m_oNotesWriter;
EndnotesWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
void Write()
{
if(!IsEmpty())
{
CString sFilename = getFilename();
CString filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile;
oFile.CreateFile(filePath);
oFile.WriteStringUTF8(g_string_endnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_endnotes_End);
oFile.CloseFile();
//ContentType
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"));
}
}
CString getFilename()
{
return _T("endnotes.xml");
}
bool IsEmpty()
{
return !(m_oNotesWriter.m_oContent.GetCurSize() > 0);
}
};
}
#endif // #ifndef HEADER_FOOTER_WRITER
......@@ -56,6 +56,8 @@ public:
CString sectPrChange;
CString cols;
CString pgBorders;
CString footnotePr;
CString endnotePr;
bool bHeader;
bool bFooter;
......@@ -97,6 +99,10 @@ public:
long nMFooter = SerializeCommon::Round(Footer * g_dKoef_mm_to_twips);
if(!sHeaderFooterReference.IsEmpty())
sRes.Append(sHeaderFooterReference);
if(!footnotePr.IsEmpty())
sRes.Append(footnotePr);
if(!endnotePr.IsEmpty())
sRes.Append(endnotePr);
if(bSectionType)
{
CString sType;
......
......@@ -1208,6 +1208,102 @@ public:
res = Read1(length, &Binary_pPrReader::ReadPageBorders, this, &pgBorders);
pSectPr->pgBorders = pgBorders.toXML();
}
else if( c_oSerProp_secPrType::footnotePr == type )
{
OOX::Logic::CFtnProps oFtnProps;
res = Read1(length, &Binary_pPrReader::ReadFootnotePr, this, &oFtnProps);
pSectPr->footnotePr = oFtnProps.toXML();
}
else if( c_oSerProp_secPrType::endnotePr == type )
{
OOX::Logic::CEdnProps oEdnProps;
res = Read1(length, &Binary_pPrReader::ReadEndnotePr, this, &oEdnProps);
pSectPr->endnotePr = oEdnProps.toXML();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFootnotePr(BYTE type, long length, void* poResult)
{
OOX::Logic::CFtnProps* pFtnProps = static_cast<OOX::Logic::CFtnProps*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerNotes::PrFmt == type )
{
pFtnProps->m_oNumFmt.Init();
res = Read1(length, &Binary_pPrReader::ReadNumFmt, this, pFtnProps->m_oNumFmt.GetPointer());
}
else if( c_oSerNotes::PrRestart == type )
{
pFtnProps->m_oNumRestart.Init();
pFtnProps->m_oNumRestart->m_oVal.Init();
pFtnProps->m_oNumRestart->m_oVal->SetValue((SimpleTypes::ERestartNumber)m_oBufferedStream.GetUChar());
}
else if( c_oSerNotes::PrStart == type )
{
pFtnProps->m_oNumStart.Init();
pFtnProps->m_oNumStart->m_oVal.Init();
pFtnProps->m_oNumStart->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerNotes::PrFntPos == type )
{
pFtnProps->m_oPos.Init();
pFtnProps->m_oPos->m_oVal.Init();
pFtnProps->m_oPos->m_oVal->SetValue((SimpleTypes::EFtnPos)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadEndnotePr(BYTE type, long length, void* poResult)
{
OOX::Logic::CEdnProps* pEdnProps = static_cast<OOX::Logic::CEdnProps*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerNotes::PrFmt == type )
{
pEdnProps->m_oNumFmt.Init();
res = Read1(length, &Binary_pPrReader::ReadNumFmt, this, pEdnProps->m_oNumFmt.GetPointer());
}
else if( c_oSerNotes::PrRestart == type )
{
pEdnProps->m_oNumRestart.Init();
pEdnProps->m_oNumRestart->m_oVal.Init();
pEdnProps->m_oNumRestart->m_oVal->SetValue((SimpleTypes::ERestartNumber)m_oBufferedStream.GetUChar());
}
else if( c_oSerNotes::PrStart == type )
{
pEdnProps->m_oNumStart.Init();
pEdnProps->m_oNumStart->m_oVal.Init();
pEdnProps->m_oNumStart->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerNotes::PrEndPos == type )
{
pEdnProps->m_oPos.Init();
pEdnProps->m_oPos->m_oVal.Init();
pEdnProps->m_oPos->m_oVal->SetValue((SimpleTypes::EEdnPos)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadNumFmtOut(long length, void* poResult)
{
return Read1(length, &Binary_pPrReader::ReadNumFmt, this, poResult);
}
int ReadNumFmt(BYTE type, long length, void* poResult)
{
ComplexTypes::Word::CNumFmt* pNumFmt = static_cast<ComplexTypes::Word::CNumFmt*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerNumTypes::NumFmtVal == type )
{
pNumFmt->m_oVal.Init();
pNumFmt->m_oVal->SetValue((SimpleTypes::ENumberFormat)m_oBufferedStream.GetUChar());
}
else if( c_oSerNumTypes::NumFmtFormat == type )
{
pNumFmt->m_sFormat.Init();
pNumFmt->m_sFormat->Append(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......@@ -2946,10 +3042,12 @@ public:
};
class Binary_SettingsTableReader : public Binary_CommonReader<Binary_SettingsTableReader>
{
Binary_pPrReader m_oBinary_pPrReader;
Writers::SettingWriter& m_oSettingWriter;
Writers::FileWriter& m_oFileWriter;
public:
Binary_SettingsTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter):Binary_CommonReader(poBufferedStream),m_oSettingWriter(oFileWriter.m_oSettingWriter),m_oFileWriter(oFileWriter)
Binary_SettingsTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter):
Binary_CommonReader(poBufferedStream),m_oSettingWriter(oFileWriter.m_oSettingWriter),m_oFileWriter(oFileWriter),m_oBinary_pPrReader(poBufferedStream, oFileWriter)
{
}
int Read()
......@@ -3027,10 +3125,101 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:trackRevisions w:val=\"false\"/>");
}
}
else if( c_oSer_SettingsType::FootnotePr == type )
{
OOX::Settings::CFtnDocProps oFtnProps;
res = Read1(length, &Binary_SettingsTableReader::ReadFootnotePr, this, &oFtnProps);
m_oFileWriter.m_oSettingWriter.AddSetting(oFtnProps.toXML());
}
else if( c_oSer_SettingsType::EndnotePr == type )
{
OOX::Settings::CEdnDocProps oEdnProps;
res = Read1(length, &Binary_SettingsTableReader::ReadEndnotePr, this, &oEdnProps);
m_oFileWriter.m_oSettingWriter.AddSetting(oEdnProps.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadFootnotePr(BYTE type, long length, void* poResult)
{
OOX::Settings::CFtnDocProps* pFtnProps = static_cast<OOX::Settings::CFtnDocProps*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerNotes::PrFmt == type )
{
pFtnProps->m_oNumFmt.Init();
res = m_oBinary_pPrReader.ReadNumFmtOut(length, pFtnProps->m_oNumFmt.GetPointer());
}
else if( c_oSerNotes::PrRestart == type )
{
pFtnProps->m_oNumRestart.Init();
pFtnProps->m_oNumRestart->m_oVal.Init();
pFtnProps->m_oNumRestart->m_oVal->SetValue((SimpleTypes::ERestartNumber)m_oBufferedStream.GetUChar());
}
else if( c_oSerNotes::PrStart == type )
{
pFtnProps->m_oNumStart.Init();
pFtnProps->m_oNumStart->m_oVal.Init();
pFtnProps->m_oNumStart->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerNotes::PrFntPos == type )
{
pFtnProps->m_oPos.Init();
pFtnProps->m_oPos->m_oVal.Init();
pFtnProps->m_oPos->m_oVal->SetValue((SimpleTypes::EFtnPos)m_oBufferedStream.GetUChar());
}
else if( c_oSerNotes::PrRef == type )
{
OOX::CFtnEdnSepRef* pRef = new OOX::CFtnEdnSepRef();
pRef->m_eType = OOX::et_w_footnote;
pRef->m_oId.Init();
pRef->m_oId->SetValue(m_oBufferedStream.GetLong());
pFtnProps->m_arrFootnote.push_back(pRef);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadEndnotePr(BYTE type, long length, void* poResult)
{
OOX::Settings::CEdnDocProps* pEdnProps = static_cast<OOX::Settings::CEdnDocProps*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerNotes::PrFmt == type )
{
pEdnProps->m_oNumFmt.Init();
res = m_oBinary_pPrReader.ReadNumFmtOut(length, pEdnProps->m_oNumFmt.GetPointer());
}
else if( c_oSerNotes::PrRestart == type )
{
pEdnProps->m_oNumRestart.Init();
pEdnProps->m_oNumRestart->m_oVal.Init();
pEdnProps->m_oNumRestart->m_oVal->SetValue((SimpleTypes::ERestartNumber)m_oBufferedStream.GetUChar());
}
else if( c_oSerNotes::PrStart == type )
{
pEdnProps->m_oNumStart.Init();
pEdnProps->m_oNumStart->m_oVal.Init();
pEdnProps->m_oNumStart->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerNotes::PrEndPos == type )
{
pEdnProps->m_oPos.Init();
pEdnProps->m_oPos->m_oVal.Init();
pEdnProps->m_oPos->m_oVal->SetValue((SimpleTypes::EEdnPos)m_oBufferedStream.GetUChar());
}
else if( c_oSerNotes::PrRef == type )
{
OOX::CFtnEdnSepRef* pRef = new OOX::CFtnEdnSepRef();
pRef->m_eType = OOX::et_w_endnote;
pRef->m_oId.Init();
pRef->m_oId->SetValue(m_oBufferedStream.GetLong());
pEdnProps->m_arrEndnote.push_back(pRef);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadMathPr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
......@@ -6028,10 +6217,66 @@ public:
{
GetRunStringWriter().WriteString(CString(_T("<w:continuationSeparator/>")));
}
else if ( c_oSerRunType::footnoteRef == type)
{
GetRunStringWriter().WriteString(CString(_T("<w:footnoteRef/>")));
}
else if ( c_oSerRunType::endnoteRef == type)
{
GetRunStringWriter().WriteString(CString(_T("<w:endnoteRef/>")));
}
else if ( c_oSerRunType::footnoteReference == type)
{
OOX::Logic::CFootnoteReference oFootnoteRef;
res = Read1(length, &Binary_DocumentTableReader::ReadFootnoteRef, this, &oFootnoteRef);
GetRunStringWriter().WriteString(oFootnoteRef.toXML());
}
else if ( c_oSerRunType::endnoteReference == type)
{
OOX::Logic::CEndnoteReference oEndnoteRef;
res = Read1(length, &Binary_DocumentTableReader::ReadEndnoteRef, this, &oEndnoteRef);
GetRunStringWriter().WriteString(oEndnoteRef.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
};
int ReadFootnoteRef(BYTE type, long length, void* poResult)
{
OOX::Logic::CFootnoteReference* pFootnoteRef = static_cast<OOX::Logic::CFootnoteReference*>(poResult);
int res = c_oSerConstants::ReadOk;
if (c_oSerNotes::RefCustomMarkFollows == type)
{
pFootnoteRef->m_oCustomMarkFollows.Init();
pFootnoteRef->m_oCustomMarkFollows->FromBool(m_oBufferedStream.GetBool());
}
else if (c_oSerNotes::RefId == type)
{
pFootnoteRef->m_oId.Init();
pFootnoteRef->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadEndnoteRef(BYTE type, long length, void* poResult)
{
OOX::Logic::CEndnoteReference* pEndnoteRef = static_cast<OOX::Logic::CEndnoteReference*>(poResult);
int res = c_oSerConstants::ReadOk;
if (c_oSerNotes::RefCustomMarkFollows == type)
{
pEndnoteRef->m_oCustomMarkFollows.Init();
pEndnoteRef->m_oCustomMarkFollows->FromBool(m_oBufferedStream.GetBool());
}
else if (c_oSerNotes::RefId == type)
{
pEndnoteRef->m_oId.Init();
pEndnoteRef->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
void ReadDrawing(CDrawingProperty &oCDrawingProperty)
{
CString sDrawingProperty = oCDrawingProperty.Write();
......@@ -6837,6 +7082,115 @@ int Binary_HdrFtrTableReader::ReadHdrFtrItemContent(BYTE type, long length, void
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
};
class Binary_NotesTableReader : public Binary_CommonReader<Binary_NotesTableReader>
{
Writers::FileWriter& m_oFileWriter;
CComments* m_pComments;
bool m_bIsFootnote;
nullable<SimpleTypes::CDecimalNumber<> > m_oId;
nullable<SimpleTypes::CFtnEdn<> > m_oType;
public:
Binary_NotesTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments, bool bIsFootnote):
Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_pComments(pComments),m_bIsFootnote(bIsFootnote)
{
}
int Read()
{
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
CString sFilename;
Writers::ContentWriter* pContentWriter = NULL;
if(m_bIsFootnote)
{
sFilename = m_oFileWriter.m_oFootnotesWriter.getFilename();
pContentWriter = &m_oFileWriter.m_oFootnotesWriter.m_oNotesWriter;
}
else
{
sFilename = m_oFileWriter.m_oEndnotesWriter.getFilename();
pContentWriter = &m_oFileWriter.m_oEndnotesWriter.m_oNotesWriter;
}
Binary_DocumentTableReader oBinary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, *pContentWriter, m_pComments);
int res = ReadTable(&Binary_NotesTableReader::ReadNotes, this, &oBinary_DocumentTableReader);
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") +
FILE_SEPARATOR_STR + _T("_rels")+
FILE_SEPARATOR_STR + sFilename + _T(".rels");
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
return res;
}
int ReadNotes(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerNotes::Note == type )
{
m_oType.reset();
m_oId.reset();
res = Read1(length, &Binary_NotesTableReader::ReadNote, this, poResult);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadNote(BYTE type, long length, void* poResult)
{
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
int res = c_oSerConstants::ReadOk;
if ( c_oSerNotes::NoteType == type )
{
m_oType.Init();
m_oType->SetValue((SimpleTypes::EFtnEdn)m_oBufferedStream.GetUChar());
}
else if ( c_oSerNotes::NoteId == type )
{
m_oId.Init();
m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerNotes::NoteContent == type )
{
XmlUtils::CStringWriter& writer = pBinary_DocumentTableReader->m_oDocumentWriter.m_oContent;
if(m_bIsFootnote)
{
writer.WriteString(_T("<w:footnote"));
}
else
{
writer.WriteString(_T("<w:endnote"));
}
if(m_oType.IsInit())
{
writer.WriteString(_T(" w:type=\""));
writer.WriteString(m_oType->ToString());
writer.WriteString(_T("\""));
}
if(m_oId.IsInit())
{
writer.WriteString(_T(" w:id=\""));
writer.WriteString(m_oId->ToString());
writer.WriteString(_T("\""));
}
writer.WriteString(_T(">"));
res = Read1(length, &Binary_NotesTableReader::ReadNoteContent, this, poResult);
if(m_bIsFootnote)
{
writer.WriteString(_T("</w:footnote>"));
}
else
{
writer.WriteString(_T("</w:endnote>"));
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadNoteContent(BYTE type, long length, void* poResult)
{
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
};
};
class BinaryFileReader
{
private:
......@@ -6965,6 +7319,13 @@ public: BinaryFileReader(CString& sFileInDir, NSBinPptxRW::CBinaryFileReader& oB
case c_oSerTableTypes::Numbering:
res = Binary_NumberingTableReader(m_oBufferedStream, m_oFileWriter).Read();
break;
case c_oSerTableTypes::Footnotes:
res = Binary_NotesTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_pComments, true).Read();
break;
case c_oSerTableTypes::Endnotes:
res = Binary_NotesTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_pComments, false).Read();
break;
//Comments должны читаться раньше чем c_oSerTableTypes::Document
//case c_oSerTableTypes::Comments:
// res = oBinary_CommentsTableReader.Read();
......@@ -6992,6 +7353,16 @@ public: BinaryFileReader(CString& sFileInDir, NSBinPptxRW::CBinaryFileReader& oB
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering")), CString(_T("numbering.xml")), CString(), &rId);
}
if(false == m_oFileWriter.m_oFootnotesWriter.IsEmpty())
{
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes")), CString(_T("footnotes.xml")), CString(), &rId);
}
if(false == m_oFileWriter.m_oEndnotesWriter.IsEmpty())
{
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes")), CString(_T("endnotes.xml")), CString(), &rId);
}
for(int i = 0, length = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders.size(); i < length; ++i)
{
Writers::HdrFtrItem* pHeader = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[i];
......
......@@ -150,7 +150,9 @@ extern int g_nCurFormatVersion;
Document = 6,
Other = 7,
Comments = 8,
Settings = 9
Settings = 9,
Footnotes = 10,
Endnotes = 11
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
......@@ -175,7 +177,7 @@ extern int g_nCurFormatVersion;
AbstractNum_Type = 3,
AbstractNum_Lvls = 4,
Lvl = 5,
lvl_Format = 6,
lvl_Format = 6,//deprecated (instead use lvl_NumFmt)
lvl_Jc = 7,
lvl_LvlText = 8,
lvl_LvlTextItem = 9,
......@@ -192,7 +194,10 @@ extern int g_nCurFormatVersion;
Num_NumId = 20,
lvl_PStyle = 21,
NumStyleLink = 22,
StyleLink = 23
StyleLink = 23,
lvl_NumFmt = 24,
NumFmtVal = 25,
NumFmtFormat = 26
};}
namespace c_oSerOtherTableTypes{enum c_oSerOtherTableTypes
{
......@@ -425,7 +430,9 @@ extern int g_nCurFormatVersion;
pageNumType = 6,
sectPrChange = 7,
cols = 8,
pgBorders = 9
pgBorders = 9,
footnotePr = 10,
endnotePr = 11
};}
namespace c_oSerProp_secPrSettingsType{enum c_oSerProp_secPrSettingsType
{
......@@ -492,7 +499,11 @@ extern int g_nCurFormatVersion;
noBreakHyphen = 20,
softHyphen = 21,
separator = 22,
continuationSeparator = 23
continuationSeparator = 23,
footnoteRef = 24,
endnoteRef = 25,
footnoteReference = 26,
endnoteReference = 27
};}
namespace c_oSerImageType{enum c_oSerImageType
{
......@@ -689,7 +700,9 @@ extern int g_nCurFormatVersion;
ClrSchemeMapping = 0,
DefaultTabStop = 1,
MathPr = 2,
TrackRevisions = 3
TrackRevisions = 3,
FootnotePr = 4,
EndnotePr = 5
};}
namespace c_oSer_MathPrType{enum c_oSer_SettingsType
{
......@@ -948,6 +961,21 @@ extern int g_nCurFormatVersion;
NoResize = 4,
NoSelect = 5
};}
namespace c_oSerNotes{enum c_oSerNotes
{
Note = 0,
NoteType = 1,
NoteId = 2,
NoteContent = 3,
RefCustomMarkFollows = 4,
RefId = 5,
PrFmt = 6,
PrRestart = 7,
PrStart = 8,
PrFntPos = 9,
PrEndPos = 10,
PrRef = 11
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
......@@ -1334,6 +1334,20 @@ namespace BinDocxRW
WritePageBorders(pSectPr->m_oPgBorders.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(pSectPr->m_oFootnotePr.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_secPrType::footnotePr);
WriteNotePr(pSectPr->m_oFootnotePr->m_oNumFmt, pSectPr->m_oFootnotePr->m_oNumRestart, pSectPr->m_oFootnotePr->m_oNumStart,
&pSectPr->m_oFootnotePr->m_oPos, NULL, NULL);
m_oBcw.WriteItemEnd(nCurPos);
}
if(pSectPr->m_oEndnotePr.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_secPrType::endnotePr);
WriteNotePr(pSectPr->m_oEndnotePr->m_oNumFmt, pSectPr->m_oEndnotePr->m_oNumRestart, pSectPr->m_oEndnotePr->m_oNumStart,
NULL, &pSectPr->m_oEndnotePr->m_oPos, NULL);
m_oBcw.WriteItemEnd(nCurPos);
}
};
void WritePageSettings(OOX::Logic::CSectionProperty* pSectPr)
{
......@@ -1640,6 +1654,71 @@ namespace BinDocxRW
}
//todo id
};
void WriteNotePr(const nullable<ComplexTypes::Word::CNumFmt>& numFmt, const nullable<ComplexTypes::Word::CNumRestart>& numRestart,
const nullable<ComplexTypes::Word::CDecimalNumber>& numStart, nullable<ComplexTypes::Word::CFtnPos>* ftnPos,
nullable<ComplexTypes::Word::CEdnPos>* endPos, std::vector<OOX::CFtnEdnSepRef*>* refs)
{
int nCurPos = 0;
if(numFmt.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::PrFmt);
WriteNumFmt(numFmt.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(numRestart.IsInit() && numRestart->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::PrRestart);
m_oBcw.m_oStream.WriteBYTE(numRestart->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(numStart.IsInit() && numStart->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::PrStart);
m_oBcw.m_oStream.WriteLONG(numStart->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(NULL != ftnPos && ftnPos->IsInit() && (*ftnPos)->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::PrFntPos);
m_oBcw.m_oStream.WriteBYTE((*ftnPos)->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(NULL != endPos && endPos->IsInit() && (*endPos)->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::PrEndPos);
m_oBcw.m_oStream.WriteBYTE((*endPos)->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(NULL != refs)
{
for(size_t i = 0; i < refs->size(); ++i)
{
OOX::CFtnEdnSepRef* pRef = (*refs)[i];
if(NULL != pRef && pRef->m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::PrRef);
m_oBcw.m_oStream.WriteLONG(pRef->m_oId->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
}
void WriteNumFmt(const ComplexTypes::Word::CNumFmt& oNumFmt)
{
int nCurPos = 0;
if(oNumFmt.m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNumTypes::NumFmtVal);
m_oBcw.m_oStream.WriteBYTE(oNumFmt.m_oVal->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oNumFmt.m_sFormat.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNumTypes::NumFmtFormat);
m_oBcw.m_oStream.WriteStringW3(oNumFmt.m_sFormat.get());
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
class Binary_tblPrWriter
{
......@@ -5189,9 +5268,53 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nPosObject);
break;
}
case OOX::et_w_footnoteRef:
{
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::footnoteRef);
m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null);
}
break;
case OOX::et_w_endnoteRef:
{
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::endnoteRef);
m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null);
}
break;
case OOX::et_w_footnoteReference:
{
OOX::Logic::CFootnoteReference* pFootnoteReference = static_cast<OOX::Logic::CFootnoteReference*>(item);
int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::footnoteReference);
WriteNoteRef(pFootnoteReference->m_oCustomMarkFollows, pFootnoteReference->m_oId);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_endnoteReference:
{
OOX::Logic::CEndnoteReference* pEndnoteReference = static_cast<OOX::Logic::CEndnoteReference*>(item);
int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::endnoteReference);
WriteNoteRef(pEndnoteReference->m_oCustomMarkFollows, pEndnoteReference->m_oId);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
}
}
}
void WriteNoteRef(const nullable<SimpleTypes::COnOff<>>& oCustomMarkFollows, const nullable<SimpleTypes::CDecimalNumber<>>& oId)
{
int nCurPos = 0;
if (oCustomMarkFollows.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::RefCustomMarkFollows);
m_oBcw.m_oStream.WriteBOOL(oCustomMarkFollows->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::RefId);
m_oBcw.m_oStream.WriteLONG(oId->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
}
void WriteDelText(const CString& text)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::delText);
......@@ -6489,8 +6612,9 @@ namespace BinDocxRW
class BinarySettingsTableWriter
{
BinaryCommonWriter m_oBcw;
Binary_pPrWriter bpPrs;
public:
BinarySettingsTableWriter(ParamsWriter& oParamsWriter):m_oBcw(oParamsWriter)
BinarySettingsTableWriter(ParamsWriter& oParamsWriter):m_oBcw(oParamsWriter),bpPrs(oParamsWriter, NULL)
{
};
void Write(OOX::CSettings& oSettings)
......@@ -6526,6 +6650,20 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBOOL(oSettings.m_oTrackRevisions->m_oVal.ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oSettings.m_oFootnotePr.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::FootnotePr);
bpPrs.WriteNotePr(oSettings.m_oFootnotePr->m_oNumFmt, oSettings.m_oFootnotePr->m_oNumRestart, oSettings.m_oFootnotePr->m_oNumStart,
&oSettings.m_oFootnotePr->m_oPos, NULL, &oSettings.m_oFootnotePr->m_arrFootnote);
m_oBcw.WriteItemEnd(nCurPos);
}
if(oSettings.m_oEndnotePr.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::EndnotePr);
bpPrs.WriteNotePr(oSettings.m_oEndnotePr->m_oNumFmt, oSettings.m_oEndnotePr->m_oNumRestart, oSettings.m_oEndnotePr->m_oNumStart,
NULL, &oSettings.m_oEndnotePr->m_oPos, &oSettings.m_oEndnotePr->m_arrEndnote);
m_oBcw.WriteItemEnd(nCurPos);
}
};
void WriteMathPr(const OOX::Logic::CMathPr &pMathPr)
{
......@@ -6823,6 +6961,69 @@ namespace BinDocxRW
}
};
};
class BinaryNotesTableWriter
{
BinaryCommonWriter m_oBcw;
ParamsWriter& m_oParamsWriter;
NSBinPptxRW::CDrawingConverter* m_pOfficeDrawingConverter;
public:
BinaryNotesTableWriter(ParamsWriter& oParamsWriter):
m_oBcw(oParamsWriter),m_oParamsWriter(oParamsWriter),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter)
{
}
void WriteFootnotes(OOX::CFootnotes& oFootnotes)
{
ParamsDocumentWriter oParamsDocumentWriter(&oFootnotes, oFootnotes.m_oReadPath.GetPath());
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter, oFootnotes.m_arrShapeTypes);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteEndnotes(OOX::CEndnotes& oEndnotes)
{
ParamsDocumentWriter oParamsDocumentWriter(&oEndnotes, oEndnotes.m_oReadPath.GetPath());
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter, oEndnotes.m_arrShapeTypes);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<CString>& arrShapeTypes)
{
int nCurPos = 0;
for(size_t i = 0 ; i < arrNotes.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::Note);
WriteNote(*arrNotes[i], oParamsDocumentWriter, arrShapeTypes);
m_oBcw.WriteItemEnd(nCurPos);
}
}
void WriteNote(const OOX::CFtnEdn& oFtnEdn, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<CString>& arrShapeTypes)
{
int nCurPos = 0;
if(oFtnEdn.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::NoteType);
m_oBcw.m_oStream.WriteBYTE(oFtnEdn.m_oType->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oFtnEdn.m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::NoteId);
m_oBcw.m_oStream.WriteLONG(oFtnEdn.m_oId->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_sDocumentPath, arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::NoteContent);
oBinaryDocumentTableWriter.WriteDocumentContent(oFtnEdn.m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
}
};
class BinaryFileWriter
{
BinaryCommonWriter m_oBcw;
......@@ -6966,6 +7167,24 @@ namespace BinDocxRW
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryNotesTableWriter oBinaryNotesWriter(m_oParamsWriter);
//Write Footnotes
OOX::CFootnotes* pFootnotes = oDocx.GetFootnotes();
if(NULL != pFootnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Footnotes);
oBinaryNotesWriter.WriteFootnotes(*pFootnotes);
this->WriteTableEnd(nCurPos);
}
//Write Endnotes
OOX::CEndnotes* pEndnotes = oDocx.GetEndnotes();
if(NULL != pEndnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Endnotes);
oBinaryNotesWriter.WriteEndnotes(*pEndnotes);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, poDocument, &m_oParamsWriter.m_mapIgnoreComments);
//Write DocumentTable
......
......@@ -346,6 +346,8 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
m_pCurFileWriter->m_oNumberingWriter.Write();
m_pCurFileWriter->m_oFontTableWriter.Write();
m_pCurFileWriter->m_oHeaderFooterWriter.Write();
m_pCurFileWriter->m_oFootnotesWriter.Write();
m_pCurFileWriter->m_oEndnotesWriter.Write();
//Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
m_pCurFileWriter->m_oSettingWriter.Write();
m_pCurFileWriter->m_oWebSettingsWriter.Write();
......
......@@ -72,25 +72,33 @@ namespace OOX
CPath oRootPath;
read(oRootPath, oPath);
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
virtual void read(const CPath& oRootPath, const CPath& oFilePath)
{
IFileContainer::Read( oRootPath, oPath );
m_oReadPath = oFilePath;
IFileContainer::Read( oRootPath, oFilePath );
XmlUtils::CXmlNode oEndnotes;
oEndnotes.FromXmlFile( oPath.GetPath(), true );
Common::readAllShapeTypes(oFilePath, m_arrShapeTypes);
if ( _T("w:endnotes") == oEndnotes.GetName() )
{
XmlUtils::CXmlNodes oEndnoteList;
oEndnotes.GetNodes( _T("w:endnote"), oEndnoteList );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
for ( int nIndex = 0; nIndex < oEndnoteList.GetCount(); nIndex++ )
CWCharWrapper sName = oReader.GetName();
if ( _T("w:endnotes") == sName && !oReader.IsEmptyNode() )
{
int nNumberingDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nNumberingDepth ) )
{
XmlUtils::CXmlNode oEndnoteNode;
if ( oEndnoteList.GetAt( nIndex, oEndnoteNode ) )
sName = oReader.GetName();
if ( _T("w:endnote") == sName )
{
CFtnEdn *pEndnote = new CFtnEdn( oEndnoteNode );
m_arrEndnote.push_back( pEndnote );
CFtnEdn *pEndnote = new CFtnEdn( oReader );
if (pEndnote) m_arrEndnote.push_back( pEndnote );
}
}
}
......@@ -150,8 +158,9 @@ namespace OOX
}
public:
CPath m_oReadPath;
std::vector<OOX::CFtnEdn*> m_arrEndnote;
std::vector<CString> m_arrShapeTypes;
};
} // namespace OOX
#endif // OOX_ENDNOTE_INCLUDE_H_
\ No newline at end of file
#endif // OOX_ENDNOTE_INCLUDE_H_
......@@ -72,25 +72,33 @@ namespace OOX
CPath oRootPath;
read(oRootPath, oPath);
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
virtual void read(const CPath& oRootPath, const CPath& oFilePath)
{
IFileContainer::Read( oRootPath, oPath );
m_oReadPath = oFilePath;
IFileContainer::Read( oRootPath, oFilePath );
XmlUtils::CXmlNode oFootnotes;
oFootnotes.FromXmlFile( oPath.GetPath(), true );
Common::readAllShapeTypes(oFilePath, m_arrShapeTypes);
if ( _T("w:footnotes") == oFootnotes.GetName() )
{
XmlUtils::CXmlNodes oFootnoteList;
oFootnotes.GetNodes( _T("w:footnote"), oFootnoteList );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
for ( int nIndex = 0; nIndex < oFootnoteList.GetCount(); nIndex++ )
CWCharWrapper sName = oReader.GetName();
if ( _T("w:footnotes") == sName && !oReader.IsEmptyNode() )
{
int nNumberingDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nNumberingDepth ) )
{
XmlUtils::CXmlNode oFootnoteNode;
if ( oFootnoteList.GetAt( nIndex, oFootnoteNode ) )
sName = oReader.GetName();
if ( _T("w:footnote") == sName )
{
CFtnEdn *pFootnote = new CFtnEdn( oFootnoteNode );
CFtnEdn *pFootnote = new CFtnEdn( oReader );
if (pFootnote) m_arrFootnote.push_back( pFootnote );
}
}
}
......@@ -150,9 +158,10 @@ namespace OOX
}
public:
CPath m_oReadPath;
std::vector<OOX::CFtnEdn*> m_arrFootnote;
std::vector<CString> m_arrShapeTypes;
};
} // namespace OOX
#endif // OOX_FOOTNOTE_INCLUDE_H_
\ No newline at end of file
#endif // OOX_FOOTNOTE_INCLUDE_H_
......@@ -60,27 +60,15 @@ namespace OOX
class CFtnEdn : public WritingElementWithChilds<>
{
public:
WritingElement_AdditionConstructors(CFtnEdn)
CFtnEdn()
{
m_eType = et_Unknown;
}
CFtnEdn(const XmlUtils::CXmlNode& oNode)
{
m_eType = et_Unknown;
fromXML( (XmlUtils::CXmlNode&)oNode );
}
virtual ~CFtnEdn()
{
}
public:
const CFtnEdn& operator =(const XmlUtils::CXmlNode& oNode)
{
ClearItems();
fromXML( (XmlUtils::CXmlNode&)oNode );
return *this;
}
virtual void ClearItems()
{
m_eType = et_Unknown;
......@@ -183,6 +171,100 @@ namespace OOX
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
CWCharWrapper sName = oReader.GetName();
if ( _T("w:footnote") == sName )
m_eType = et_w_footnote;
else if ( _T("w:endnote") == sName )
m_eType = et_w_endnote;
else
return;
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
sName = oReader.GetName();
WritingElement *pItem = NULL;
/*if ( _T("w:altChunk") == sName )
pItem = new Logic::CAltChunk( oReader );
else */if ( _T("w:bookmarkEnd") == sName )
pItem = new Logic::CBookmarkEnd( oReader );
else if ( _T("w:bookmarkStart") == sName )
pItem = new Logic::CBookmarkStart( oReader );
else if ( _T("w:commentRangeEnd") == sName )
pItem = new Logic::CCommentRangeEnd( oReader );
else if ( _T("w:commentRangeStart") == sName )
pItem = new Logic::CCommentRangeStart( oReader );
//else if ( _T("w:customXml") == sName )
// pItem = new Logic::CCustomXml( oReader );
else if ( _T("w:customXmlDelRangeEnd") == sName )
pItem = new Logic::CCustomXmlDelRangeEnd( oReader );
else if ( _T("w:customXmlDelRangeStart") == sName )
pItem = new Logic::CCustomXmlDelRangeStart( oReader );
else if ( _T("w:customXmlInsRangeEnd") == sName )
pItem = new Logic::CCustomXmlInsRangeEnd( oReader );
else if ( _T("w:customXmlInsRangeStart") == sName )
pItem = new Logic::CCustomXmlInsRangeStart( oReader );
else if ( _T("w:customXmlMoveFromRangeEnd") == sName )
pItem = new Logic::CCustomXmlMoveFromRangeEnd( oReader );
else if ( _T("w:customXmlMoveFromRangeStart") == sName )
pItem = new Logic::CCustomXmlMoveFromRangeStart( oReader );
else if ( _T("w:customXmlMoveToRangeEnd") == sName )
pItem = new Logic::CCustomXmlMoveToRangeEnd( oReader );
else if ( _T("w:customXmlMoveToRangeStart") == sName )
pItem = new Logic::CCustomXmlMoveToRangeStart( oReader );
else if ( _T("w:del") == sName )
pItem = new Logic::CDel( oReader );
else if ( _T("w:ins") == sName )
pItem = new Logic::CIns( oReader );
//else if ( _T("w:moveFrom") == sName )
// pItem = new Logic::CMoveFrom( oReader );
else if ( _T("w:moveFromRangeEnd") == sName )
pItem = new Logic::CMoveToRangeEnd( oReader );
else if ( _T("w:moveFromRangeStart") == sName )
pItem = new Logic::CMoveToRangeStart( oReader );
//else if ( _T("w:moveTo") == sName )
// pItem = new Logic::CMoveTo( oReader );
else if ( _T("w:moveToRangeEnd") == sName )
pItem = new Logic::CMoveToRangeEnd( oReader );
else if ( _T("w:moveToRangeStart") == sName )
pItem = new Logic::CMoveToRangeStart( oReader );
else if ( _T("m:oMath") == sName )
pItem = new Logic::COMath( oReader );
else if ( _T("m:oMathPara") == sName )
pItem = new Logic::COMathPara( oReader );
else if ( _T("w:p") == sName )
pItem = new Logic::CParagraph( oReader );
else if ( _T("w:permEnd") == sName )
pItem = new Logic::CPermEnd( oReader );
else if ( _T("w:permStart") == sName )
pItem = new Logic::CPermStart( oReader );
else if ( _T("w:proofErr") == sName )
pItem = new Logic::CProofErr( oReader );
else if ( _T("w:sdt") == sName )
pItem = new Logic::CSdt( oReader );
else if ( _T("w:tbl") == sName )
pItem = new Logic::CTbl( oReader );
if ( pItem )
m_arrItems.push_back( pItem );
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("w:id"), m_oId )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:type"), m_oType )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString toXML() const
{
CString sResult;
......
......@@ -1234,7 +1234,12 @@ namespace OOX
{
CString sResult = _T("<w:endnoteReference ");
ComplexTypes_WriteAttribute( _T("w:customMarkFollows=\""), m_oCustomMarkFollows );
if ( m_oCustomMarkFollows.IsInit() )
{
sResult += _T("w:customMarkFollows=\"");
sResult += m_oCustomMarkFollows->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
ComplexTypes_WriteAttribute( _T("w:id=\""), m_oId );
sResult += _T("/>");
......@@ -1343,7 +1348,12 @@ namespace OOX
{
CString sResult = _T("<w:footnoteReference ");
ComplexTypes_WriteAttribute( _T("w:customMarkFollows=\""), m_oCustomMarkFollows );
if ( m_oCustomMarkFollows.IsInit() )
{
sResult += _T("w:customMarkFollows=\"");
sResult += m_oCustomMarkFollows->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
ComplexTypes_WriteAttribute( _T("w:id=\""), m_oId );
sResult += _T("/>");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment