diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 12:31:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 14:58:51 +0200 |
commit | 29489b33b435683021b72cb2bce27aba8cb7a430 (patch) | |
tree | 8e4e1c59d56d5ed0d0ca4d088419067041e4553a /xmloff/source/text | |
parent | a4244c0f05b95ded277a3a7ed217bf0451daa996 (diff) |
loplugin:flatten
Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/text')
-rw-r--r-- | xmloff/source/text/XMLIndexTOCContext.cxx | 34 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 228 |
2 files changed, 131 insertions, 131 deletions
diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx index 8dd1dac881c7..e7235f093efa 100644 --- a/xmloff/source/text/XMLIndexTOCContext.cxx +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -248,28 +248,28 @@ void XMLIndexTOCContext::endFastElement(sal_Int32 ) { // complete import of index by removing the markers (if the index // was actually inserted, that is) - if( bValid ) - { - // preliminaries - rtl::Reference<XMLTextImportHelper> rHelper= GetImport().GetTextImport(); + if( !bValid ) + return; - // get rid of last paragraph (unless it's the only paragraph) - rHelper->GetCursor()->goRight(1, false); - if( xBodyContextRef.is() && xBodyContextRef->HasContent() ) - { - rHelper->GetCursor()->goLeft(1, true); - rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), - "", true); - } + // preliminaries + rtl::Reference<XMLTextImportHelper> rHelper= GetImport().GetTextImport(); - // and delete second marker - rHelper->GetCursor()->goRight(1, true); + // get rid of last paragraph (unless it's the only paragraph) + rHelper->GetCursor()->goRight(1, false); + if( xBodyContextRef.is() && xBodyContextRef->HasContent() ) + { + rHelper->GetCursor()->goLeft(1, true); rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), "", true); - - // check for Redlines on our end node - GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(); } + + // and delete second marker + rHelper->GetCursor()->goRight(1, true); + rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), + "", true); + + // check for Redlines on our end node + GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(); } css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexTOCContext::createFastChildContext( diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 01ac94d097f2..9c05e72f9708 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -715,33 +715,33 @@ void XMLTextImportHelper::InsertString( const OUString& rChars, { assert(m_xImpl->m_xText.is()); assert(m_xImpl->m_xCursorAsRange.is()); - if (m_xImpl->m_xText.is()) - { - sal_Int32 nLen = rChars.getLength(); - OUStringBuffer sChars( nLen ); + if (!m_xImpl->m_xText.is()) + return; + + sal_Int32 nLen = rChars.getLength(); + OUStringBuffer sChars( nLen ); - for( sal_Int32 i=0; i < nLen; i++ ) + for( sal_Int32 i=0; i < nLen; i++ ) + { + sal_Unicode c = rChars[i]; + switch( c ) { - sal_Unicode c = rChars[i]; - switch( c ) - { - case 0x20: - case 0x09: - case 0x0a: - case 0x0d: - if( !rIgnoreLeadingSpace ) - sChars.append( u' ' ); - rIgnoreLeadingSpace = true; - break; - default: - rIgnoreLeadingSpace = false; - sChars.append( c ); - break; - } + case 0x20: + case 0x09: + case 0x0a: + case 0x0d: + if( !rIgnoreLeadingSpace ) + sChars.append( u' ' ); + rIgnoreLeadingSpace = true; + break; + default: + rIgnoreLeadingSpace = false; + sChars.append( c ); + break; } - m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange, - sChars.makeStringAndClear(), false); } + m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange, + sChars.makeStringAndClear(), false); } void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl ) @@ -1458,46 +1458,46 @@ void XMLTextImportHelper::FindOutlineStyleName( OUString& rStyleName, sal_Int8 nOutlineLevel ) { // style name empty? - if( rStyleName.isEmpty() ) + if( !rStyleName.isEmpty() ) + return; + + // Empty? Then we need o do stuff. Let's do error checking first. + if (m_xImpl->m_xChapterNumbering.is() && + ( nOutlineLevel > 0 ) && + (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount())) { - // Empty? Then we need o do stuff. Let's do error checking first. - if (m_xImpl->m_xChapterNumbering.is() && - ( nOutlineLevel > 0 ) && - (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount())) - { - nOutlineLevel--; // for the remainder, the level's are 0-based + nOutlineLevel--; // for the remainder, the level's are 0-based - // empty style name: look-up previously used name + // empty style name: look-up previously used name - // if we don't have a previously used name, we'll use the default - m_xImpl->InitOutlineStylesCandidates(); - if (m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].empty()) + // if we don't have a previously used name, we'll use the default + m_xImpl->InitOutlineStylesCandidates(); + if (m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].empty()) + { + // no other name used previously? Then use default + + // iterate over property value sequence to find the style name + Sequence<PropertyValue> aProperties; + m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel ) + >>= aProperties; + auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), + [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; }); + if (pProp != std::cend(aProperties)) { - // no other name used previously? Then use default - - // iterate over property value sequence to find the style name - Sequence<PropertyValue> aProperties; - m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel ) - >>= aProperties; - auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), - [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; }); - if (pProp != std::cend(aProperties)) - { - OUString aOutlineStyle; - pProp->Value >>= aOutlineStyle; - m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel] - .push_back( aOutlineStyle ); - } + OUString aOutlineStyle; + pProp->Value >>= aOutlineStyle; + m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel] + .push_back( aOutlineStyle ); } - - // finally, we'll use the previously used style name for this - // format (or the default we've just put into that style) - // take last added one (#i71249#) - rStyleName = - m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].back(); } - // else: nothing we can do, so we'll leave it empty + + // finally, we'll use the previously used style name for this + // format (or the default we've just put into that style) + // take last added one (#i71249#) + rStyleName = + m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].back(); } + // else: nothing we can do, so we'll leave it empty // else: we already had a style name, so we let it pass. } @@ -1666,29 +1666,29 @@ void XMLTextImportHelper::SetHyperlink( } } - if (m_xImpl->m_xTextStyles.is()) + if (!m_xImpl->m_xTextStyles.is()) + return; + + OUString sDisplayName( + rImport.GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, rStyleName ) ); + if( !sDisplayName.isEmpty() && + xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) && + m_xImpl->m_xTextStyles->hasByName(sDisplayName)) { - OUString sDisplayName( - rImport.GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, rStyleName ) ); - if( !sDisplayName.isEmpty() && - xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) && - m_xImpl->m_xTextStyles->hasByName(sDisplayName)) - { - xPropSet->setPropertyValue(s_UnvisitedCharStyleName, - makeAny(sDisplayName)); - } + xPropSet->setPropertyValue(s_UnvisitedCharStyleName, + makeAny(sDisplayName)); + } - sDisplayName = - rImport.GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, rVisitedStyleName ); - if( !sDisplayName.isEmpty() && - xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) && - m_xImpl->m_xTextStyles->hasByName(sDisplayName)) - { - xPropSet->setPropertyValue(s_VisitedCharStyleName, - makeAny(sDisplayName)); - } + sDisplayName = + rImport.GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, rVisitedStyleName ); + if( !sDisplayName.isEmpty() && + xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) && + m_xImpl->m_xTextStyles->hasByName(sDisplayName)) + { + xPropSet->setPropertyValue(s_VisitedCharStyleName, + makeAny(sDisplayName)); } } @@ -1704,35 +1704,35 @@ void XMLTextImportHelper::SetRuby( OUString sRubyText("RubyText"); // if we have one Ruby property, we assume all of them are present - if (xPropSet.is() && - xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText )) - { - // the ruby text - xPropSet->setPropertyValue(sRubyText, makeAny(rText)); + if (!xPropSet.is() || + !xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText )) + return; - // the ruby style (ruby-adjust) - if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) - { - const SvXMLStyleContext* pTempStyle = - m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY, - rStyleName, true ); - XMLPropStyleContext *pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); + // the ruby text + xPropSet->setPropertyValue(sRubyText, makeAny(rText)); - if (nullptr != pStyle) - pStyle->FillPropertySet( xPropSet ); - } + // the ruby style (ruby-adjust) + if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) + { + const SvXMLStyleContext* pTempStyle = + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY, + rStyleName, true ); + XMLPropStyleContext *pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); + + if (nullptr != pStyle) + pStyle->FillPropertySet( xPropSet ); + } - // the ruby text character style - if (m_xImpl->m_xTextStyles.is()) + // the ruby text character style + if (m_xImpl->m_xTextStyles.is()) + { + OUString sDisplayName( + rImport.GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, rTextStyleName ) ); + if( (!sDisplayName.isEmpty()) && + m_xImpl->m_xTextStyles->hasByName( sDisplayName )) { - OUString sDisplayName( - rImport.GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, rTextStyleName ) ); - if( (!sDisplayName.isEmpty()) && - m_xImpl->m_xTextStyles->hasByName( sDisplayName )) - { - xPropSet->setPropertyValue("RubyCharStyleName", makeAny(sDisplayName)); - } + xPropSet->setPropertyValue("RubyCharStyleName", makeAny(sDisplayName)); } } } @@ -2191,22 +2191,22 @@ void XMLTextImportHelper::ConnectFrameChains( m_xImpl->m_xNextFrmNames->push_back(sNextFrmName); } } - if (m_xImpl->m_xPrevFrmNames && !m_xImpl->m_xPrevFrmNames->empty()) + if (!m_xImpl->m_xPrevFrmNames || m_xImpl->m_xPrevFrmNames->empty()) + return; + + for(std::vector<OUString>::iterator i = m_xImpl->m_xPrevFrmNames->begin(), j = m_xImpl->m_xNextFrmNames->begin(); i != m_xImpl->m_xPrevFrmNames->end() && j != m_xImpl->m_xNextFrmNames->end(); ++i, ++j) { - for(std::vector<OUString>::iterator i = m_xImpl->m_xPrevFrmNames->begin(), j = m_xImpl->m_xNextFrmNames->begin(); i != m_xImpl->m_xPrevFrmNames->end() && j != m_xImpl->m_xNextFrmNames->end(); ++i, ++j) + if((*j) == rFrmName) { - if((*j) == rFrmName) - { - // The previous frame must exist, because it existing than - // inserting the entry - rFrmPropSet->setPropertyValue("ChainPrevName", makeAny(*i)); + // The previous frame must exist, because it existing than + // inserting the entry + rFrmPropSet->setPropertyValue("ChainPrevName", makeAny(*i)); - i = m_xImpl->m_xPrevFrmNames->erase(i); - j = m_xImpl->m_xNextFrmNames->erase(j); + i = m_xImpl->m_xPrevFrmNames->erase(i); + j = m_xImpl->m_xNextFrmNames->erase(j); - // There cannot be more than one previous frames - break; - } + // There cannot be more than one previous frames + break; } } } |