mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
implementation Fb2 footnote
This commit is contained in:
@ -166,6 +166,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_nContentsId; // ID содержания
|
int m_nContentsId; // ID содержания
|
||||||
int m_nCrossReferenceId; // ID перекрестной ссылки
|
int m_nCrossReferenceId; // ID перекрестной ссылки
|
||||||
|
bool m_bFootnote; // Чтение Footnote из html
|
||||||
|
|
||||||
// STitleInfo* m_pSrcTitleInfo; // Данные об исходнике книги
|
// STitleInfo* m_pSrcTitleInfo; // Данные об исходнике книги
|
||||||
// SPublishInfo* m_pPublishInfo; // Сведения об издании книги
|
// SPublishInfo* m_pPublishInfo; // Сведения об издании книги
|
||||||
@ -178,6 +179,7 @@ public:
|
|||||||
// m_pPublishInfo = NULL;
|
// m_pPublishInfo = NULL;
|
||||||
m_nContentsId = 1;
|
m_nContentsId = 1;
|
||||||
m_nCrossReferenceId = 1;
|
m_nCrossReferenceId = 1;
|
||||||
|
m_bFootnote = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CFb2File_Private()
|
~CFb2File_Private()
|
||||||
@ -1425,7 +1427,6 @@ public:
|
|||||||
}
|
}
|
||||||
else if (sName == L"div")
|
else if (sName == L"div")
|
||||||
{
|
{
|
||||||
bool bFootnote = false;
|
|
||||||
std::wstring sFootnoteName;
|
std::wstring sFootnoteName;
|
||||||
NSStringUtils::CStringBuilder oFootnote;
|
NSStringUtils::CStringBuilder oFootnote;
|
||||||
while (m_oLightReader.MoveToNextAttribute())
|
while (m_oLightReader.MoveToNextAttribute())
|
||||||
@ -1433,15 +1434,16 @@ public:
|
|||||||
std::wstring sAtrName = m_oLightReader.GetName();
|
std::wstring sAtrName = m_oLightReader.GetName();
|
||||||
std::wstring sAtrText = m_oLightReader.GetText();
|
std::wstring sAtrText = m_oLightReader.GetText();
|
||||||
if (sAtrName == L"style" && sAtrText == L"mso-element:footnote")
|
if (sAtrName == L"style" && sAtrText == L"mso-element:footnote")
|
||||||
bFootnote = true;
|
m_bFootnote = true;
|
||||||
else if (sAtrName == L"id")
|
else if (sAtrName == L"id")
|
||||||
sFootnoteName = sAtrText;
|
sFootnoteName = sAtrText;
|
||||||
}
|
}
|
||||||
m_oLightReader.MoveToElement();
|
m_oLightReader.MoveToElement();
|
||||||
if (bFootnote && !sFootnoteName.empty())
|
if (m_bFootnote && !sFootnoteName.empty())
|
||||||
{
|
{
|
||||||
readStream(oFootnote, false, false);
|
readStream(oFootnote, false, false);
|
||||||
m_mFootnotes.insert(std::make_pair(sFootnoteName, oFootnote.GetData()));
|
m_mFootnotes.insert(std::make_pair(sFootnoteName, oFootnote.GetData()));
|
||||||
|
m_bFootnote = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
readStream(oXml, bWasP, bWasTable);
|
readStream(oXml, bWasP, bWasTable);
|
||||||
@ -1619,15 +1621,33 @@ public:
|
|||||||
}
|
}
|
||||||
else if (sName == L"a")
|
else if (sName == L"a")
|
||||||
{
|
{
|
||||||
|
bool bFootnote = false;
|
||||||
oXml.WriteString(L"<a ");
|
oXml.WriteString(L"<a ");
|
||||||
while (m_oLightReader.MoveToNextAttribute())
|
while (m_oLightReader.MoveToNextAttribute())
|
||||||
{
|
{
|
||||||
std::wstring sName = m_oLightReader.GetName();
|
std::wstring sAtrName = m_oLightReader.GetName();
|
||||||
if (sName == L"name")
|
std::wstring sAtrText = m_oLightReader.GetText();
|
||||||
sName = L"id";
|
if (!sAtrName.empty() && !sAtrText.empty())
|
||||||
oXml.WriteString(sName + L"=\"");
|
{
|
||||||
oXml.WriteString(m_oLightReader.GetText());
|
if (!m_bFootnote && sAtrName == L"style" && sAtrText.find(L"mso-footnote-id") != std::wstring::npos)
|
||||||
oXml.WriteString(L"\" ");
|
{
|
||||||
|
sAtrText = sAtrText.substr(sAtrText.rfind(L':') + 1);
|
||||||
|
oXml.WriteString(L"href=\"#");
|
||||||
|
oXml.WriteString(sAtrText);
|
||||||
|
oXml.WriteString(L"\" type=\"note\" ");
|
||||||
|
bFootnote = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bFootnote && (sAtrName == L"href" || sAtrName == L"type"))
|
||||||
|
continue;
|
||||||
|
if (sAtrName == L"name")
|
||||||
|
sAtrName = L"id";
|
||||||
|
oXml.WriteString(sAtrName + L"=\"");
|
||||||
|
oXml.WriteString(sAtrText);
|
||||||
|
oXml.WriteString(L"\" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_oLightReader.MoveToElement();
|
m_oLightReader.MoveToElement();
|
||||||
oXml.WriteString(L">");
|
oXml.WriteString(L">");
|
||||||
|
|||||||
Reference in New Issue
Block a user