diff --git a/RtfFile/Format/Basic.h b/RtfFile/Format/Basic.h index 4330d337f9..17e44bdcc4 100644 --- a/RtfFile/Format/Basic.h +++ b/RtfFile/Format/Basic.h @@ -203,6 +203,7 @@ public: template class ItemSingleContainer: public ItemContainer { public: + //todooo -> to map with hash int AddItem( T piRend) { for( int i = 0; i < (int)ItemContainer::m_aArray.size(); i++ ) diff --git a/RtfFile/Format/DestinationCommand.cpp b/RtfFile/Format/DestinationCommand.cpp index bf2c8f2bec..fbab984526 100644 --- a/RtfFile/Format/DestinationCommand.cpp +++ b/RtfFile/Format/DestinationCommand.cpp @@ -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; diff --git a/RtfFile/Format/RtfGlobalTables.cpp b/RtfFile/Format/RtfGlobalTables.cpp index 4527a0f187..a7915e7369 100644 --- a/RtfFile/Format/RtfGlobalTables.cpp +++ b/RtfFile/Format/RtfGlobalTables.cpp @@ -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) { diff --git a/RtfFile/Format/RtfGlobalTables.h b/RtfFile/Format/RtfGlobalTables.h index d2977f0906..6f70c5ad82 100644 --- a/RtfFile/Format/RtfGlobalTables.h +++ b/RtfFile/Format/RtfGlobalTables.h @@ -36,7 +36,7 @@ class RtfFontTable : public IDocumentElement, public ItemSingleContainer { 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(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 ) diff --git a/RtfFile/Format/RtfProperty.h b/RtfFile/Format/RtfProperty.h index 5a6848e4d0..12db7e4560 100644 --- a/RtfFile/Format/RtfProperty.h +++ b/RtfFile/Format/RtfProperty.h @@ -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(); diff --git a/RtfFile/Format/RtfReader.cpp b/RtfFile/Format/RtfReader.cpp index 6098702b41..a876b4f79e 100644 --- a/RtfFile/Format/RtfReader.cpp +++ b/RtfFile/Format/RtfReader.cpp @@ -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()) //{ diff --git a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp index 5ab4deb6d5..5921ffa9f2 100644 --- a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp +++ b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp @@ -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() );