diff options
Diffstat (limited to 'editeng/source/editeng/eertfpar.cxx')
-rw-r--r-- | editeng/source/editeng/eertfpar.cxx | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index 278699dbfcb1..557081f8496f 100644 --- a/editeng/source/editeng/eertfpar.cxx +++ b/editeng/source/editeng/eertfpar.cxx @@ -31,6 +31,7 @@ #include <svtools/rtftoken.h> #include <svtools/htmltokn.h> +#include <comphelper/configuration.hxx> using namespace com::sun::star; @@ -55,10 +56,6 @@ RtfImportInfo::RtfImportInfo( RtfImportState eSt, SvParser<int>* pPrsrs, const E nTokenValue = 0; } -RtfImportInfo::~RtfImportInfo() -{ -} - constexpr MapUnit gRTFMapUnit = MapUnit::MapTwip; EditRTFParser::EditRTFParser( @@ -206,7 +203,6 @@ void EditRTFParser::NextToken( int nToken ) SkipGroup(); } break; - case RTF_PGDSCTBL: // #i29453# ignore \*\pgdsctbl destination case RTF_LISTTEXT: { SkipGroup(); @@ -307,7 +303,6 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) EditPaM aEndPaM( pEndNode, rSet.GetEndCnt() ); // If possible adjust the Escapement-Item: - const SfxPoolItem* pItem; // #i66167# adapt font heights to destination MapUnit if necessary const MapUnit eDestUnit = mpEditEngine->GetEditDoc().GetItemPool().GetMetric(0); @@ -316,6 +311,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) sal_uInt16 const aFntHeightIems[3] = { EE_CHAR_FONTHEIGHT, EE_CHAR_FONTHEIGHT_CJK, EE_CHAR_FONTHEIGHT_CTL }; for (unsigned short aFntHeightIem : aFntHeightIems) { + const SfxPoolItem* pItem; if (SfxItemState::SET == rSet.GetAttrSet().GetItemState( aFntHeightIem, false, &pItem )) { sal_uInt32 nHeight = static_cast<const SvxFontHeightItem*>(pItem)->GetHeight(); @@ -331,23 +327,29 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) } } - if( SfxItemState::SET == rSet.GetAttrSet().GetItemState( EE_CHAR_ESCAPEMENT, false, &pItem )) + if( const SvxEscapementItem* pItem = rSet.GetAttrSet().GetItemIfSet( EE_CHAR_ESCAPEMENT, false ) ) { // the correct one - tools::Long nEsc = static_cast<const SvxEscapementItem*>(pItem)->GetEsc(); + tools::Long nEsc = pItem->GetEsc(); tools::Long nEscFontHeight = 0; if( ( DFLT_ESC_AUTO_SUPER != nEsc ) && ( DFLT_ESC_AUTO_SUB != nEsc ) ) { nEsc *= 10; //HalfPoints => Twips was embezzled in RTFITEM.CXX! SvxFont aFont; - mpEditEngine->SeekCursor(aStartPaM.GetNode(), aStartPaM.GetIndex()+1, aFont); + if (comphelper::IsFuzzing()) + { + // ofz#24932 detecting RTL vs LTR is slow + aFont = aStartPaM.GetNode()->GetCharAttribs().GetDefFont(); + } + else + mpEditEngine->SeekCursor(aStartPaM.GetNode(), aStartPaM.GetIndex()+1, aFont); nEscFontHeight = aFont.GetFontSize().Height(); } if (nEscFontHeight) { nEsc = nEsc * 100 / nEscFontHeight; - SvxEscapementItem aEscItem( static_cast<short>(nEsc), static_cast<const SvxEscapementItem*>(pItem)->GetProportionalHeight(), EE_CHAR_ESCAPEMENT ); + SvxEscapementItem aEscItem( static_cast<short>(nEsc), pItem->GetProportionalHeight(), EE_CHAR_ESCAPEMENT ); rSet.GetAttrSet().Put( aEscItem ); } } @@ -374,8 +376,8 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) auto const& pS = it->second; mpEditEngine->SetStyleSheet( EditSelection(aStartPaM, aEndPaM), - static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS->sName, SfxStyleFamily::All))); - nOutlLevel = pS->nOutlineNo; + static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS.sName, SfxStyleFamily::All))); + nOutlLevel = pS.nOutlineNo; } } @@ -436,10 +438,10 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) SvxRTFStyleType* EditRTFParser::FindStyleSheet( std::u16string_view rName ) { SvxRTFStyleTbl& rTable = GetStyleTbl(); - for (auto const& iter : rTable) + for (auto & iter : rTable) { - if (iter.second->sName == rName) - return iter.second.get(); + if (iter.second.sName == rName) + return &iter.second; } return nullptr; } @@ -458,9 +460,9 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType const * pRTFStyl SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn ); if ( it != GetStyleTbl().end()) { - SvxRTFStyleType *const pS = it->second.get(); - if ( pS && ( pS !=pRTFStyle ) ) - aParent = pS->sName; + SvxRTFStyleType const& rS = it->second; + if ( &rS != pRTFStyle ) + aParent = rS.sName; } } @@ -492,10 +494,10 @@ void EditRTFParser::CreateStyleSheets() // the SvxRTFParser has now created the template... if (mpEditEngine->GetStyleSheetPool() && mpEditEngine->IsImportRTFStyleSheetsSet()) { - for (auto const& elem : GetStyleTbl()) + for (auto & elem : GetStyleTbl()) { - SvxRTFStyleType* pRTFStyle = elem.second.get(); - CreateStyleSheet( pRTFStyle ); + SvxRTFStyleType& rRTFStyle = elem.second; + CreateStyleSheet( &rRTFStyle ); } } } @@ -510,20 +512,20 @@ void EditRTFParser::CalcValue() void EditRTFParser::ReadField() { // From SwRTFParser::ReadField() - int _nOpenBrakets = 1; // the first was already detected earlier + int _nOpenBrackets = 1; // the first was already detected earlier bool bFldInst = false; bool bFldRslt = false; OUString aFldInst; OUString aFldRslt; - while( _nOpenBrakets && IsParserWorking() ) + while( _nOpenBrackets && IsParserWorking() ) { switch( GetNextToken() ) { case '}': { - _nOpenBrakets--; - if ( _nOpenBrakets == 1 ) + _nOpenBrackets--; + if ( _nOpenBrackets == 1 ) { bFldInst = false; bFldRslt = false; @@ -531,7 +533,7 @@ void EditRTFParser::ReadField() } break; - case '{': _nOpenBrakets++; + case '{': _nOpenBrackets++; break; case RTF_FIELD: SkipGroup(); @@ -578,21 +580,21 @@ void EditRTFParser::ReadField() void EditRTFParser::SkipGroup() { - int _nOpenBrakets = 1; // the first was already detected earlier + int _nOpenBrackets = 1; // the first was already detected earlier - while( _nOpenBrakets && IsParserWorking() ) + while( _nOpenBrackets && IsParserWorking() ) { switch( GetNextToken() ) { case '}': { - _nOpenBrakets--; + _nOpenBrackets--; } break; case '{': { - _nOpenBrakets++; + _nOpenBrackets++; } break; } |