From 29489b33b435683021b72cb2bce27aba8cb7a430 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 21 Oct 2021 12:31:03 +0200 Subject: loplugin:flatten Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/core/xmlexp.cxx | 48 ++--- xmloff/source/style/PageMasterImportPropMapper.cxx | 94 ++++----- xmloff/source/style/XMLPageExport.cxx | 34 +-- xmloff/source/style/xmlnumfi.cxx | 104 +++++----- xmloff/source/text/XMLIndexTOCContext.cxx | 34 +-- xmloff/source/text/txtimp.cxx | 228 ++++++++++----------- 6 files changed, 271 insertions(+), 271 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 5e0e46dabeb0..2fa78344835b 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -399,33 +399,33 @@ void SvXMLExport::DetermineModelType_() { meModelType = SvtModuleOptions::EFactory::UNKNOWN_FACTORY; - if ( mxModel.is() ) - { - meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel ); + if ( !mxModel.is() ) + return; + + meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel ); - // note: MATH documents will throw NotInitializedException; maybe unit test problem - if (meModelType == SvtModuleOptions::EFactory::WRITER) + // note: MATH documents will throw NotInitializedException; maybe unit test problem + if (meModelType == SvtModuleOptions::EFactory::WRITER) + { + uno::Reference const xModule(mxModel, uno::UNO_QUERY); + bool const isBaseForm(xModule.is() && + xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); + if (isBaseForm) { - uno::Reference const xModule(mxModel, uno::UNO_QUERY); - bool const isBaseForm(xModule.is() && - xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); - if (isBaseForm) + switch (GetODFSaneDefaultVersion()) { - switch (GetODFSaneDefaultVersion()) - { - case SvtSaveOptions::ODFSVER_013_EXTENDED: - SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); - mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED; - maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012_EXTENDED); - break; - case SvtSaveOptions::ODFSVER_013: - SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); - mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012; - maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012); - break; - default: - break; - } + case SvtSaveOptions::ODFSVER_013_EXTENDED: + SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); + mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED; + maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012_EXTENDED); + break; + case SvtSaveOptions::ODFSVER_013: + SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); + mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012; + maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012); + break; + default: + break; } } } diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx index cee84997dfdd..b9850eaec618 100644 --- a/xmloff/source/style/PageMasterImportPropMapper.cxx +++ b/xmloff/source/style/PageMasterImportPropMapper.cxx @@ -446,65 +446,65 @@ void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& r xFooterDynamic.reset(); } - if (pMarginGutter) - { - sal_Int32 nGutterMargin{}; - pMarginGutter->maValue >>= nGutterMargin; + if (!pMarginGutter) + return; + + sal_Int32 nGutterMargin{}; + pMarginGutter->maValue >>= nGutterMargin; - bool bGutterAtTop{}; - uno::Reference xSI(GetImport().GetModel(), uno::UNO_QUERY); - if (xSI.is() && xSI->supportsService("com.sun.star.text.TextDocument")) + bool bGutterAtTop{}; + uno::Reference xSI(GetImport().GetModel(), uno::UNO_QUERY); + if (xSI.is() && xSI->supportsService("com.sun.star.text.TextDocument")) + { + uno::Reference xFac(GetImport().GetModel(), uno::UNO_QUERY); + if (xFac.is()) { - uno::Reference xFac(GetImport().GetModel(), uno::UNO_QUERY); - if (xFac.is()) + uno::Reference xProps( + xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + if (xProps.is()) { - uno::Reference xProps( - xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); - if (xProps.is()) - { - xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; - } + xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; } } - if (bGutterAtTop) + } + if (bGutterAtTop) + { + if (nGutterMargin && pMargins[XML_LINE_TOP]) + { + // Decrease top margin to not include gutter. + sal_Int32 nTopMargin{}; + pMargins[XML_LINE_TOP]->maValue >>= nTopMargin; + nTopMargin -= nGutterMargin; + pMargins[XML_LINE_TOP]->maValue <<= nTopMargin; + } + } + else + { + bool bRtlGutter{}; + if (nGutterMargin && pRtlGutter) + { + pRtlGutter->maValue >>= bRtlGutter; + } + if (bRtlGutter) { - if (nGutterMargin && pMargins[XML_LINE_TOP]) + if (nGutterMargin && pMargins[XML_LINE_RIGHT]) { - // Decrease top margin to not include gutter. - sal_Int32 nTopMargin{}; - pMargins[XML_LINE_TOP]->maValue >>= nTopMargin; - nTopMargin -= nGutterMargin; - pMargins[XML_LINE_TOP]->maValue <<= nTopMargin; + // Decrease right margin to not include gutter. + sal_Int32 nRightMargin{}; + pMargins[XML_LINE_RIGHT]->maValue >>= nRightMargin; + nRightMargin -= nGutterMargin; + pMargins[XML_LINE_RIGHT]->maValue <<= nRightMargin; } } else { - bool bRtlGutter{}; - if (nGutterMargin && pRtlGutter) - { - pRtlGutter->maValue >>= bRtlGutter; - } - if (bRtlGutter) - { - if (nGutterMargin && pMargins[XML_LINE_RIGHT]) - { - // Decrease right margin to not include gutter. - sal_Int32 nRightMargin{}; - pMargins[XML_LINE_RIGHT]->maValue >>= nRightMargin; - nRightMargin -= nGutterMargin; - pMargins[XML_LINE_RIGHT]->maValue <<= nRightMargin; - } - } - else + if (nGutterMargin && pMargins[XML_LINE_LEFT]) { - if (nGutterMargin && pMargins[XML_LINE_LEFT]) - { - // Decrease left margin to not include gutter. - sal_Int32 nLeftMargin{}; - pMargins[XML_LINE_LEFT]->maValue >>= nLeftMargin; - nLeftMargin -= nGutterMargin; - pMargins[XML_LINE_LEFT]->maValue <<= nLeftMargin; - } + // Decrease left margin to not include gutter. + sal_Int32 nLeftMargin{}; + pMargins[XML_LINE_LEFT]->maValue >>= nLeftMargin; + nLeftMargin -= nGutterMargin; + pMargins[XML_LINE_LEFT]->maValue <<= nLeftMargin; } } } diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx index 87de784951cb..042a703982ba 100644 --- a/xmloff/source/style/XMLPageExport.cxx +++ b/xmloff/source/style/XMLPageExport.cxx @@ -226,24 +226,24 @@ XMLPageExport::XMLPageExport(SvXMLExport & rExp) } } - if (GetExport().GetModelType() == SvtModuleOptions::EFactory::WRITER) + if (GetExport().GetModelType() != SvtModuleOptions::EFactory::WRITER) + return; + + uno::Reference xFac(GetExport().GetModel(), uno::UNO_QUERY); + if (!xFac.is()) + return; + + uno::Reference xProps( + xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + if (!xProps.is()) + return; + + bool bGutterAtTop{}; + xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; + if (bGutterAtTop) { - uno::Reference xFac(GetExport().GetModel(), uno::UNO_QUERY); - if (xFac.is()) - { - uno::Reference xProps( - xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); - if (xProps.is()) - { - bool bGutterAtTop{}; - xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; - if (bGutterAtTop) - { - static_cast(xPageMasterExportPropMapper.get()) - ->SetGutterAtTop(true); - } - } - } + static_cast(xPageMasterExportPropMapper.get()) + ->SetGutterAtTop(true); } } diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 823cdf79e904..bc2f7f948130 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -2069,68 +2069,68 @@ void SvXMLNumFormatContext::AddColor( Color const nColor ) void SvXMLNumFormatContext::UpdateCalendar( const OUString& rNewCalendar ) { - if ( rNewCalendar != sCalendar ) + if ( rNewCalendar == sCalendar ) + return; + + if (rNewCalendar.isEmpty() || rNewCalendar == aImplicitCalendar[0]) { - if (rNewCalendar.isEmpty() || rNewCalendar == aImplicitCalendar[0]) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); - } - else if (aImplicitCalendar[0].isEmpty() && rNewCalendar == GetLocaleData().getDefaultCalendar()->Name) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); - aImplicitCalendar[0] = rNewCalendar; - } - else if (rNewCalendar == aImplicitCalendar[1]) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); - } - else if (aImplicitCalendar[1].isEmpty() && GetLocaleData().doesSecondaryCalendarUseEC( rNewCalendar)) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); - aImplicitCalendar[1] = rNewCalendar; - } - else + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); + } + else if (aImplicitCalendar[0].isEmpty() && rNewCalendar == GetLocaleData().getDefaultCalendar()->Name) + { + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); + aImplicitCalendar[0] = rNewCalendar; + } + else if (rNewCalendar == aImplicitCalendar[1]) + { + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); + } + else if (aImplicitCalendar[1].isEmpty() && GetLocaleData().doesSecondaryCalendarUseEC( rNewCalendar)) + { + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); + aImplicitCalendar[1] = rNewCalendar; + } + else + { + eImplicitCalendar = ImplicitCalendar::OTHER; + } + + if (eImplicitCalendar != ImplicitCalendar::DEFAULT && eImplicitCalendar != ImplicitCalendar::SECONDARY) + { + // A switch from empty default calendar to named default calendar or + // vice versa is not a switch. + bool bSameDefault = false; + if (sCalendar.isEmpty() || rNewCalendar.isEmpty()) { - eImplicitCalendar = ImplicitCalendar::OTHER; + // As both are not equal, only one can be empty here, the other + // can not. + const OUString& rDefaultCalendar = GetLocaleData().getDefaultCalendar()->Name; + // So if one is the named default calendar the other is the + // empty default calendar. + bSameDefault = (rNewCalendar == rDefaultCalendar || sCalendar == rDefaultCalendar); } - - if (eImplicitCalendar != ImplicitCalendar::DEFAULT && eImplicitCalendar != ImplicitCalendar::SECONDARY) + if (!bSameDefault) { - // A switch from empty default calendar to named default calendar or - // vice versa is not a switch. - bool bSameDefault = false; - if (sCalendar.isEmpty() || rNewCalendar.isEmpty()) + aFormatCode.append( "[~" ); // intro for calendar code + if (rNewCalendar.isEmpty()) { - // As both are not equal, only one can be empty here, the other - // can not. - const OUString& rDefaultCalendar = GetLocaleData().getDefaultCalendar()->Name; - // So if one is the named default calendar the other is the - // empty default calendar. - bSameDefault = (rNewCalendar == rDefaultCalendar || sCalendar == rDefaultCalendar); + // Empty calendar name here means switching to default calendar + // from a different calendar. Needs to be explicitly stated in + // format code. + aFormatCode.append( GetLocaleData().getDefaultCalendar()->Name ); } - if (!bSameDefault) + else { - aFormatCode.append( "[~" ); // intro for calendar code - if (rNewCalendar.isEmpty()) - { - // Empty calendar name here means switching to default calendar - // from a different calendar. Needs to be explicitly stated in - // format code. - aFormatCode.append( GetLocaleData().getDefaultCalendar()->Name ); - } - else - { - aFormatCode.append( rNewCalendar ); - } - aFormatCode.append( ']' ); // end of calendar code + aFormatCode.append( rNewCalendar ); } + aFormatCode.append( ']' ); // end of calendar code } - sCalendar = rNewCalendar; } + sCalendar = rNewCalendar; } bool SvXMLNumFormatContext::IsSystemLanguage() const 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 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 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 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 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(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(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::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::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; } } } -- cgit