Commit 7eee0755 authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatReader - generate replacement text hyperlink if absent

parent c329f29e
...@@ -1381,10 +1381,20 @@ private: ...@@ -1381,10 +1381,20 @@ private:
std::vector<std::wstring> arResult; std::vector<std::wstring> arResult;
boost::algorithm::split(arResult, sField, boost::algorithm::is_any_of(L" \""), boost::algorithm::token_compress_on); boost::algorithm::split(arResult, sField, boost::algorithm::is_any_of(L" \""), boost::algorithm::token_compress_on);
if (arResult.size()< 1) while (!arResult.empty())
{
if (arResult[0].empty())
arResult.erase( arResult.begin(), arResult.begin() + 1 );
else
break;
}
if (arResult.empty())
return; return;
if (L"SYMBOL" != arResult[0])
if (L"SYMBOL" != arResult[0] && L"HYPERLINK" != arResult[0])
return; return;
nStartTokenize = arResult[0].length(); nStartTokenize = arResult[0].length();
for (size_t i = 1 ; i < arResult.size(); i++) for (size_t i = 1 ; i < arResult.size(); i++)
...@@ -1429,42 +1439,55 @@ private: ...@@ -1429,42 +1439,55 @@ private:
nStartTokenize += (int)sResTokenize.length(); nStartTokenize += (int)sResTokenize.length();
} }
if( L"" == sCharCode || L"" == sCharFont )
return;
int nCharCode = Strings::ToInteger( sCharCode );
std::string sCharA; sCharA += char(nCharCode );
RtfFont oSymbolFont; std::wstring sResult;
if( true == oDocument.m_oFontTable.GetFont( sCharFont, oSymbolFont ) ) if ( L"SYMBOL" == arResult[0])
oReader.m_oState->m_oCharProp.m_nFont = oSymbolFont.m_nID;
else
{ {
oSymbolFont.m_sName = sCharFont; if ( L"" == sCharCode || L"" == sCharFont ) return;
oSymbolFont.m_nID = oDocument.m_oFontTable.GetCount() + 1; int nCharCode = Strings::ToInteger( sCharCode );
oSymbolFont.m_nCodePage = CP_SYMBOL; std::string sCharA; sCharA += char(nCharCode );
oReader.m_oState->m_oCharProp.m_nFont = oSymbolFont.m_nID;
oDocument.m_oFontTable.DirectAddItem( oSymbolFont ); RtfFont oSymbolFont;
if( true == oDocument.m_oFontTable.GetFont( sCharFont, oSymbolFont ) )
oReader.m_oState->m_oCharProp.m_nFont = oSymbolFont.m_nID;
else
{
oSymbolFont.m_sName = sCharFont;
oSymbolFont.m_nID = oDocument.m_oFontTable.GetCount() + 1;
oSymbolFont.m_nCodePage = CP_SYMBOL;
oReader.m_oState->m_oCharProp.m_nFont = oSymbolFont.m_nID;
oDocument.m_oFontTable.DirectAddItem( oSymbolFont );
}
int nSkipChar = 0;
RtfAbstractReader reader;
sResult = reader.ExecuteTextInternal( oDocument, oReader, sCharA, false, 0, nSkipChar );
}
else if ( L"HYPERLINK" == arResult[0])
{
sResult = sCharCode;
} }
int nSkipChar = 0; if (sResult.empty()) return;
RtfAbstractReader reader; RtfFieldInstPtr newResult = RtfFieldInstPtr ( new RtfFieldInst() );
newResult->SetDefault();
std::wstring sResultSymbol = reader.ExecuteTextInternal( oDocument, oReader, sCharA, false, 0, nSkipChar );
//свойства копировать ? ващето есть дубль - проверить
m_oField.m_pResult = RtfFieldInstPtr ( new RtfFieldInst() );
m_oField.m_pResult->SetDefault();
RtfParagraphPtr pNewPar ( new RtfParagraph() ); RtfParagraphPtr pNewPar ( new RtfParagraph() );
RtfCharPtr pNewChar( new RtfChar() ); RtfCharPtr pNewChar( new RtfChar() );
pNewChar->setText( sResultSymbol ); pNewChar->setText( sResult);
pNewChar->m_oProperty = oReader.m_oState->m_oCharProp; pNewChar->m_oProperty = m_oField.m_pResult->m_oCharProperty;
pNewPar->AddItem( pNewChar ); pNewPar->AddItem( pNewChar );
m_oField.m_pResult->m_pTextItems->AddItem( pNewPar ); newResult->m_pTextItems->AddItem( pNewPar );
m_oField.m_bTextOnly = true; newResult->m_oCharProperty = m_oField.m_pResult->m_oCharProperty;
m_oField.m_pResult = newResult;
if ( L"SYMBOL" == arResult[0])
m_oField.m_bTextOnly = true;
} }
}; };
......
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