mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
fix bug #61456
This commit is contained in:
@ -203,6 +203,7 @@ public:
|
||||
template<class T> class ItemSingleContainer: public ItemContainer<T>
|
||||
{
|
||||
public:
|
||||
//todooo -> to map with hash
|
||||
int AddItem( T piRend)
|
||||
{
|
||||
for( int i = 0; i < (int)ItemContainer<T>::m_aArray.size(); i++ )
|
||||
|
||||
@ -2345,7 +2345,7 @@ void RtfFieldReader::TryToPepairResult( RtfDocument& oDocument, RtfReader& oRead
|
||||
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 );
|
||||
oDocument.m_oFontTable.AddFont( oSymbolFont );
|
||||
}
|
||||
|
||||
int nSkipChar = 0;
|
||||
@ -3298,7 +3298,7 @@ void RtfFontTableReader::ExecuteTextInternal2( RtfDocument& oDocument, RtfReader
|
||||
oDocument.m_oProperty.m_nAnsiCodePage = m_oFont.m_nCodePage;
|
||||
}
|
||||
|
||||
if (m_oFont.m_nCharset > 2 && oDocument.m_oProperty.m_nAnsiCodePage == 0)
|
||||
if (m_oFont.m_nCharset != PROP_DEF && m_oFont.m_nCharset >= 0 && oDocument.m_oProperty.m_nAnsiCodePage == 0)
|
||||
{
|
||||
oDocument.m_oProperty.m_nAnsiCodePage = RtfUtility::CharsetToCodepage(m_oFont.m_nCharset);
|
||||
}
|
||||
@ -3345,7 +3345,7 @@ void RtfFontTableReader::ExecuteText(RtfDocument& oDocument, RtfReader& oReader,
|
||||
}
|
||||
|
||||
//todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf
|
||||
oDocument.m_oFontTable.DirectAddItem( m_oFont );
|
||||
oDocument.m_oFontTable.AddFont( m_oFont );
|
||||
|
||||
m_oFont.SetDefaultRtf();
|
||||
}
|
||||
@ -3414,7 +3414,7 @@ void RtfColorTableReader::ExecuteText( RtfDocument& oDocument, RtfReader& oReade
|
||||
{
|
||||
if( true == m_bIsSet )
|
||||
{
|
||||
oDocument.m_oColorTable.DirectAddItem( oCurColor );
|
||||
oDocument.m_oColorTable.AddColor( oCurColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3422,7 +3422,7 @@ void RtfColorTableReader::ExecuteText( RtfDocument& oDocument, RtfReader& oReade
|
||||
//{\colortbl\red0\blue159\green82;\red0\blue0\green0;\red255\blue255\green255;\red0\blue156\green90;\red169\blue86\green0;}
|
||||
//{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;
|
||||
oCurColor.SetAuto();
|
||||
oDocument.m_oColorTable.DirectAddItem( oCurColor );
|
||||
oDocument.m_oColorTable.AddColor( oCurColor );
|
||||
}
|
||||
oCurColor.SetDefaultRtf();
|
||||
m_bIsSet = false;
|
||||
|
||||
@ -32,10 +32,9 @@
|
||||
#include "RtfGlobalTables.h"
|
||||
#include "RtfDocument.h"
|
||||
|
||||
int RtfFontTable::DirectAddItem( RtfFont piRend)
|
||||
void RtfFontTable::AddFont( RtfFont piRend)
|
||||
{
|
||||
m_aArray.push_back(piRend);
|
||||
return (int)m_aArray.size() - 1;
|
||||
}
|
||||
bool RtfFontTable::GetFont( int nId, RtfFont& oFont)
|
||||
{
|
||||
@ -43,6 +42,7 @@ bool RtfFontTable::GetFont( int nId, RtfFont& oFont)
|
||||
{
|
||||
if( nId == m_aArray[i].m_nID )
|
||||
{
|
||||
m_aArray[i].m_bUsed = true;
|
||||
oFont = m_aArray[i];
|
||||
return true;
|
||||
}
|
||||
@ -55,6 +55,7 @@ bool RtfFontTable::GetFont( std::wstring sName, RtfFont& oFont )
|
||||
{
|
||||
if( sName == m_aArray[i].m_sName )
|
||||
{
|
||||
m_aArray[i].m_bUsed = true;
|
||||
oFont = m_aArray[i];
|
||||
return true;
|
||||
}
|
||||
@ -66,8 +67,11 @@ std::wstring RtfFontTable::RenderToOOX(RenderParameter oRenderParameter)
|
||||
std::wstring sResult;
|
||||
if( !m_aArray.empty())
|
||||
{
|
||||
for (size_t i = 0; i < m_aArray.size(); i++ )
|
||||
sResult += m_aArray[i].RenderToOOX(oRenderParameter);
|
||||
for (size_t i = 0; i < m_aArray.size(); i++)
|
||||
{
|
||||
if (m_aArray[i].m_bUsed)
|
||||
sResult += m_aArray[i].RenderToOOX(oRenderParameter);
|
||||
}
|
||||
|
||||
}
|
||||
return sResult;
|
||||
@ -106,10 +110,9 @@ std::wstring RtfFontTable::RenderToRtf(RenderParameter oRenderParameter)
|
||||
RtfColorTable::RtfColorTable()
|
||||
{
|
||||
}
|
||||
int RtfColorTable::DirectAddItem( RtfColor piRend)
|
||||
void RtfColorTable::AddColor( RtfColor piRend)
|
||||
{
|
||||
m_aArray.push_back(piRend);
|
||||
return (int)m_aArray.size() - 1;
|
||||
}
|
||||
int RtfColorTable::AddItem( RtfColor piRend)
|
||||
{
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
class RtfFontTable : public IDocumentElement, public ItemSingleContainer<RtfFont>
|
||||
{
|
||||
public:
|
||||
int DirectAddItem( RtfFont piRend);
|
||||
void AddFont( RtfFont piRend);
|
||||
|
||||
bool GetFont( int nId, RtfFont& oFont);
|
||||
bool GetFont( std::wstring sName, RtfFont& oFont );
|
||||
@ -50,7 +50,7 @@ class RtfColorTable : public IDocumentElement, public ItemSingleContainer<RtfCol
|
||||
public:
|
||||
RtfColorTable();
|
||||
|
||||
int DirectAddItem( RtfColor piRend);
|
||||
void AddColor( RtfColor piRend);
|
||||
int AddItem( RtfColor piRend);
|
||||
|
||||
bool GetColor( int nId, RtfColor& oColor);
|
||||
|
||||
@ -142,18 +142,13 @@ std::wstring RtfFont::RenderToRtf(RenderParameter oRenderParameter)
|
||||
}
|
||||
std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
if( IsValid() == false) return L"";
|
||||
if ( IsValid() == false) return L"";
|
||||
|
||||
std::wstring sResult;
|
||||
|
||||
RtfDocument* poRtfDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
|
||||
std::wstring sFontName = m_sName;
|
||||
|
||||
if ((sFontName.length() > 0 ) && (sFontName[0] == 0x00b9 || sFontName[0] > 0xff00) )//fondj.rtf
|
||||
{
|
||||
if (m_sAltName.length() > 0) sFontName = m_sAltName;
|
||||
else sFontName.clear();
|
||||
}
|
||||
if( sFontName.empty() )
|
||||
{
|
||||
if( PROP_DEF != poRtfDocument->m_oProperty.m_nDefFont )
|
||||
|
||||
@ -132,15 +132,17 @@ public:
|
||||
|
||||
typedef enum {ff_none, ff_fnil ,ff_froman ,ff_fswiss ,ff_fmodern ,ff_fscript ,ff_fdecor ,ff_ftech ,ff_fbidi} FontFamily;
|
||||
|
||||
bool m_bUsed = false;
|
||||
|
||||
FontTheme m_eFontTheme;
|
||||
FontFamily m_eFontFamily;
|
||||
std::wstring m_sPanose;
|
||||
_INT32 m_nID;
|
||||
_INT32 m_nID;
|
||||
std::wstring m_sName;
|
||||
std::wstring m_sAltName;
|
||||
_INT32 m_nCharset;
|
||||
_INT32 m_nCodePage;
|
||||
_INT32 m_nPitch;
|
||||
_INT32 m_nCharset;
|
||||
_INT32 m_nCodePage;
|
||||
_INT32 m_nPitch;
|
||||
|
||||
RtfFont();
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@ std::wstring RtfAbstractReader::ExecuteTextInternal(RtfDocument& oDocument, RtfR
|
||||
}
|
||||
void RtfAbstractReader::ExecuteTextInternal2(RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, int& nSkipChars)
|
||||
{
|
||||
if (oReader.m_oState->m_sCurText.length() > 0)
|
||||
if (false == oReader.m_oState->m_sCurText.empty())
|
||||
{
|
||||
std::string str;
|
||||
ExecuteTextInternalSkipChars(oReader.m_oState->m_sCurText, oReader, str, nSkipChars);
|
||||
@ -393,7 +393,14 @@ std::wstring RtfAbstractReader::ExecuteTextInternalCodePage( std::string& sCharS
|
||||
nCodepage = msLCID2DefCodePage(oDocument.m_nUserLCID);
|
||||
}
|
||||
|
||||
sResult = RtfUtility::convert_string_icu(sCharString.begin(), sCharString.end(), nCodepage);
|
||||
if (m_bUseGlobalCodepage && nCodepage == 0)
|
||||
{
|
||||
sResult = std::wstring(sCharString.begin(), sCharString.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = RtfUtility::convert_string_icu(sCharString.begin(), sCharString.end(), nCodepage);
|
||||
}
|
||||
|
||||
//if (!sCharString.empty() && sResult.empty())
|
||||
//{
|
||||
|
||||
@ -1008,7 +1008,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
|
||||
{
|
||||
oCurFont.m_nID = oParam.oRtf->m_oFontTable.GetCount() + 1;
|
||||
oCurFont.m_sName = sFont;
|
||||
oParam.oRtf->m_oFontTable.DirectAddItem( oCurFont );
|
||||
oParam.oRtf->m_oFontTable.AddFont( oCurFont );
|
||||
}
|
||||
RtfFieldPtr oNewField ( new RtfField() );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user