Files
core/MsBinaryFile/PptFile/Records/TextSpecInfoAtom.cpp
2022-11-28 17:37:12 +03:00

67 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "TextSpecInfoAtom.h"
CRecordTextSpecInfoAtom::CRecordTextSpecInfoAtom()
{
m_lCount = 0;
m_lOffsetInStream = 0;
}
CRecordTextSpecInfoAtom::~CRecordTextSpecInfoAtom()
{
m_lCount = 0;
}
void CRecordTextSpecInfoAtom::ReadFromStream(SRecordHeader &oHeader, POLE::Stream *pStream)
{
m_oHeader = oHeader;
StreamUtils::StreamPosition(m_lOffsetInStream, pStream);
_UINT32 lMemCount = 0;
while (true)
{
PPT_FORMAT::CTextSIRun elm;
m_arrSIs.push_back(elm);
NSStreamReader::Read(pStream, m_arrSIs.back());
lMemCount += m_arrSIs.back().lCount;
long sz = (long)(pStream->tell() - m_lOffsetInStream);
if (sz >= (long)m_oHeader.RecLen)
break;
}
// на всякий случай...
// здесь когда текст сначала другой (т.е. например - placeholder в мастере) -
// то у нас неправильно выставился m_lCount... на число m_lCount пилюем .. берем структур si скока прописано
StreamUtils::StreamSeek(m_lOffsetInStream + m_oHeader.RecLen, pStream);
}
void CRecordTextSpecInfoAtom::ApplyProperties(CTextAttributesEx *pText)
{
if (m_arrSIs.size() < 1) return;
int pos_text = 0, pos_si = 0;
size_t ind = 0;
for (size_t i = 0; i < pText->m_arParagraphs.size(); i++)
{
if (ind >= m_arrSIs.size()) break;
for (size_t j = 0 ; j < pText->m_arParagraphs[i].m_arSpans.size(); j++)
{
if (pos_text + pText->m_arParagraphs[i].m_arSpans[j].m_strText.length() > pos_si + m_arrSIs[ind].lCount )
{
pos_si += m_arrSIs[ind].lCount;
ind++;
}
if (ind >= m_arrSIs.size()) break;
if (m_arrSIs[ind].bLang)
pText->m_arParagraphs[i].m_arSpans[j].m_oRun.Language = m_arrSIs[ind].Lang;
pos_text += pText->m_arParagraphs[i].m_arSpans[j].m_strText.length() ;
}
}
}