DocFormatReader - дешифрование + поддержка формата 95 года

This commit is contained in:
ElenaSubbotina
2016-06-26 17:37:17 +03:00
parent 0d261b8769
commit de899687bb
118 changed files with 3963 additions and 3492 deletions

View File

@ -80,7 +80,11 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( _T("w:body"), FALSE );
// Convert the document
_lastValidPapx = (*(m_document->AllPapxFkps->begin()))->grppapx[0];
_lastValidPapx = NULL;
if (m_document->AllPapxFkps->empty() == false)
{
_lastValidPapx = (*(m_document->AllPapxFkps->begin()))->grppapx[0];
}
int cp = 0;
int fc = 0;
@ -96,6 +100,7 @@ namespace DocFileFormat
while (cp < countText)
{
fc = m_document->FindFileCharPos(cp);
if (fc < 0) break;
papx = findValidPapx(fc);
@ -120,40 +125,15 @@ namespace DocFileFormat
else
{
//There are no paragraphs, only text
//start paragraph
m_pXmlWriter->WriteNodeBegin( _T( "w:p" ) );
//start run
m_pXmlWriter->WriteNodeBegin( _T( "w:r" ) );
int fc = m_document->FindFileCharPos(0);
int fc = m_document->FindFileCharPos(cp);
int fcEnd = m_document->FindFileCharPos(countTextRel);
if (fc < 0 || fcEnd < 0) break;
// Read the chars
vector<wchar_t>* chpxChars = m_document->m_PieceTable->GetEncodingChars (fc, fcEnd, m_document->WordDocumentStream); //<! NEED OPTIMIZE
wstring text (chpxChars->begin(), chpxChars->end());
//open a new w:t element
m_pXmlWriter->WriteNodeBegin( _T( "w:t" ), TRUE );
//if (text.find(_T("\x20")) != text.npos)
{
m_pXmlWriter->WriteAttribute( _T( "xml:space" ), _T( "preserve" ) );
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
//if (fc < 0 || fcEnd < 0) break;
//
//// Read the chars
//std::vector<wchar_t>* chars = m_document->GetChars (fc, fcEnd, fc);
// Write text
m_pXmlWriter->WriteString(text.c_str());
RELEASEOBJECT(chpxChars);
//close previous w:t ...
m_pXmlWriter->WriteNodeEnd( _T( "w:t" ) );
//close previous w:r ...
m_pXmlWriter->WriteNodeEnd( _T( "w:r" ) );
//close previous w:p ...
m_pXmlWriter->WriteNodeEnd( _T( "w:p" ) );
writeParagraph(cp, countTextRel, false, true );
cp = m_document->FIB->m_RgLw97.ccpText;
}
@ -182,7 +162,7 @@ namespace DocFileFormat
{
int lastSepxCp = 0;
for (map<int, SectionPropertyExceptions*>::iterator iter = m_document->AllSepx->begin(); iter != m_document->AllSepx->end(); ++iter)
for (std::map<int, SectionPropertyExceptions*>::iterator iter = m_document->AllSepx->begin(); iter != m_document->AllSepx->end(); ++iter)
lastSepxCp = iter->first;
SectionPropertyExceptions* lastSepx = m_document->AllSepx->operator []( lastSepxCp );
@ -198,6 +178,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "w:body" ) );
m_pXmlWriter->WriteNodeEnd( _T( "w:document" ) );
m_context->_docx->DocumentXML = wstring(m_pXmlWriter->GetXmlString());
m_context->_docx->DocumentXML = std::wstring(m_pXmlWriter->GetXmlString());
}
}