From e2644b014005e1c79b0a7eaf1c3c4002464a1cf0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 2 Aug 2020 20:08:17 +0200 Subject: loplugin:flatten in writerfilter Change-Id: Ifaa63738c4e38dddd385821f568911927d834f1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99966 Tested-by: Jenkins Reviewed-by: Noel Grandin --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 100 ++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'writerfilter/source/rtftok/rtfdocumentimpl.cxx') diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 9fcbcf2a2f09..1f4ebda582d7 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -381,25 +381,25 @@ void RTFDocumentImpl::outputSettingsTable() void RTFDocumentImpl::checkFirstRun() { - if (m_bFirstRun) - { - outputSettingsTable(); - // start initial paragraph - m_bFirstRun = false; - assert(!m_bNeedSect || m_bFirstRunException); - setNeedSect(true); // first call that succeeds + if (!m_bFirstRun) + return; - // set the requested default font, if there are none - RTFValue::Pointer_t pFont - = getNestedAttribute(m_aDefaultState.getCharacterSprms(), - NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii); - RTFValue::Pointer_t pCurrentFont - = getNestedAttribute(m_aStates.top().getCharacterSprms(), - NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii); - if (pFont && !pCurrentFont) - putNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, - NS_ooxml::LN_CT_Fonts_ascii, pFont); - } + outputSettingsTable(); + // start initial paragraph + m_bFirstRun = false; + assert(!m_bNeedSect || m_bFirstRunException); + setNeedSect(true); // first call that succeeds + + // set the requested default font, if there are none + RTFValue::Pointer_t pFont + = getNestedAttribute(m_aDefaultState.getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii); + RTFValue::Pointer_t pCurrentFont + = getNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii); + if (pFont && !pCurrentFont) + putNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii, pFont); } void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; } @@ -540,46 +540,46 @@ RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSpr void RTFDocumentImpl::checkNeedPap() { - if (m_bNeedPap) - { - m_bNeedPap = false; // reset early, so we can avoid recursion when calling ourselves + if (!m_bNeedPap) + return; - if (m_aStates.empty()) - return; + m_bNeedPap = false; // reset early, so we can avoid recursion when calling ourselves - if (!m_aStates.top().getCurrentBuffer()) - { - writerfilter::Reference::Pointer_t const pParagraphProperties(getProperties( - m_aStates.top().getParagraphAttributes(), m_aStates.top().getParagraphSprms(), - NS_ooxml::LN_Value_ST_StyleType_paragraph)); + if (m_aStates.empty()) + return; - // Writer will ignore a page break before a text frame, so guard it with empty paragraphs - bool hasBreakBeforeFrame = m_aStates.top().getFrame().hasProperties() - && m_aStates.top().getParagraphSprms().find( - NS_ooxml::LN_CT_PPrBase_pageBreakBefore); - if (hasBreakBeforeFrame) - { - dispatchSymbol(RTF_PAR); - m_bNeedPap = false; - } - Mapper().props(pParagraphProperties); - if (hasBreakBeforeFrame) - dispatchSymbol(RTF_PAR); + if (!m_aStates.top().getCurrentBuffer()) + { + writerfilter::Reference::Pointer_t const pParagraphProperties(getProperties( + m_aStates.top().getParagraphAttributes(), m_aStates.top().getParagraphSprms(), + NS_ooxml::LN_Value_ST_StyleType_paragraph)); - if (m_aStates.top().getFrame().hasProperties()) - { - writerfilter::Reference::Pointer_t const pFrameProperties( - new RTFReferenceProperties(RTFSprms(), m_aStates.top().getFrame().getSprms())); - Mapper().props(pFrameProperties); - } + // Writer will ignore a page break before a text frame, so guard it with empty paragraphs + bool hasBreakBeforeFrame + = m_aStates.top().getFrame().hasProperties() + && m_aStates.top().getParagraphSprms().find(NS_ooxml::LN_CT_PPrBase_pageBreakBefore); + if (hasBreakBeforeFrame) + { + dispatchSymbol(RTF_PAR); + m_bNeedPap = false; } - else + Mapper().props(pParagraphProperties); + if (hasBreakBeforeFrame) + dispatchSymbol(RTF_PAR); + + if (m_aStates.top().getFrame().hasProperties()) { - auto pValue = new RTFValue(m_aStates.top().getParagraphAttributes(), - m_aStates.top().getParagraphSprms()); - bufferProperties(*m_aStates.top().getCurrentBuffer(), pValue, nullptr); + writerfilter::Reference::Pointer_t const pFrameProperties( + new RTFReferenceProperties(RTFSprms(), m_aStates.top().getFrame().getSprms())); + Mapper().props(pFrameProperties); } } + else + { + auto pValue = new RTFValue(m_aStates.top().getParagraphAttributes(), + m_aStates.top().getParagraphSprms()); + bufferProperties(*m_aStates.top().getCurrentBuffer(), pValue, nullptr); + } } void RTFDocumentImpl::runProps() -- cgit v1.2.3