mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-11 01:52:24 +08:00
Fix bug 75486
This commit is contained in:
@ -270,6 +270,7 @@ namespace DocFileFormat
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos(cp);
|
||||
int fcEnd = m_document->FindFileCharPos(cpEnd);
|
||||
bool PBookmark = false;
|
||||
|
||||
ParagraphPropertyExceptions* papx = findValidPapx(fc);
|
||||
|
||||
@ -406,13 +407,17 @@ namespace DocFileFormat
|
||||
{
|
||||
for (std::vector<std::vector<wchar_t> >::iterator iter = runs->begin(); iter != runs->end(); ++iter)
|
||||
{
|
||||
if (writeBookmarks(cp))
|
||||
if (writeBookmarks(cp, PBookmark))
|
||||
{
|
||||
cp = writeRun(&(*iter), chpxs->at(it), cp);
|
||||
}
|
||||
PBookmark = true;
|
||||
if (cp == m_document->FIB->m_RgLw97.ccpText - 1)
|
||||
writeBookmarks(cp, PBookmark);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(runs);
|
||||
PBookmark = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1971,22 +1976,77 @@ namespace DocFileFormat
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool DocumentMapping::writeBookmarks(int cp)
|
||||
bool DocumentMapping::writeBookmarks(int cp, bool para)
|
||||
{
|
||||
bool result = true;
|
||||
static std::vector<int> openedInThisPara;
|
||||
static std::set<int> allClosedIds;
|
||||
static int nextIdForSequence = 0;
|
||||
|
||||
for (size_t b = 0; b < m_document->BookmarkStartEndCPs.size(); ++b)
|
||||
{
|
||||
if (m_document->BookmarkStartEndCPs[b].start == cp)
|
||||
{
|
||||
result = writeBookmarkStart(b);
|
||||
}
|
||||
for (size_t b = 0; b < m_document->BookmarkStartEndCPs.size(); ++b)
|
||||
{
|
||||
if (m_document->BookmarkStartEndCPs[b].start == cp)
|
||||
{
|
||||
int xmlId = b;
|
||||
|
||||
if (m_document->BookmarkStartEndCPs[b].end == cp)
|
||||
{
|
||||
result = writeBookmarkEnd(b);
|
||||
}
|
||||
}
|
||||
result = writeBookmarkStart(xmlId);
|
||||
openedInThisPara.push_back(xmlId);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasPositionClosings = false;
|
||||
int positionClosingCount = 0;
|
||||
|
||||
for (size_t b = 0; b < m_document->BookmarkStartEndCPs.size(); ++b)
|
||||
{
|
||||
if (m_document->BookmarkStartEndCPs[b].end == cp)
|
||||
{
|
||||
hasPositionClosings = true;
|
||||
positionClosingCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPositionClosings)
|
||||
{
|
||||
|
||||
for (int i = 0; i < positionClosingCount; i++)
|
||||
{
|
||||
if (!openedInThisPara.empty())
|
||||
{
|
||||
int idToClose = openedInThisPara[0];
|
||||
result = writeBookmarkEnd(idToClose);
|
||||
allClosedIds.insert(idToClose);
|
||||
openedInThisPara.erase(openedInThisPara.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
while (allClosedIds.find(nextIdForSequence) != allClosedIds.end())
|
||||
{
|
||||
nextIdForSequence++;
|
||||
}
|
||||
|
||||
result = writeBookmarkEnd(nextIdForSequence);
|
||||
allClosedIds.insert(nextIdForSequence);
|
||||
nextIdForSequence++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (para)
|
||||
{
|
||||
while (allClosedIds.find(nextIdForSequence) != allClosedIds.end())
|
||||
{
|
||||
nextIdForSequence++;
|
||||
}
|
||||
|
||||
result = writeBookmarkEnd(nextIdForSequence);
|
||||
allClosedIds.insert(nextIdForSequence);
|
||||
nextIdForSequence++;
|
||||
}
|
||||
|
||||
if (para)
|
||||
{
|
||||
openedInThisPara.clear();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user