diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-17 14:48:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-17 15:50:58 +0200 |
commit | 3e57aad962c9d24c535daff893db203314709cfc (patch) | |
tree | 5744fcaae69751cdd4174f5da6024ba656e77ccc /cui/source/tabpages/tpcolor.cxx | |
parent | bb3ea0ae51bb943f7bb3dca80eee153f9c55c03e (diff) |
loplugin:flatten in cui
Change-Id: I0ea0784ab8c4542747da1e15fa7c60c60bccb602
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92423
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui/source/tabpages/tpcolor.cxx')
-rw-r--r-- | cui/source/tabpages/tpcolor.cxx | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 24a8199e12f4..456897ee28d6 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -185,29 +185,29 @@ void SvxColorTabPage::Construct() void SvxColorTabPage::ActivatePage( const SfxItemSet& ) { - if( pColorList.is() ) + if( !pColorList.is() ) + return; + + const SfxPoolItem* pPoolItem = nullptr; + if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) - { - SetColorModel( ColorModel::RGB ); - ChangeColorModel(); + SetColorModel( ColorModel::RGB ); + ChangeColorModel(); - const Color aColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); - ChangeColor( aColor ); - sal_Int32 nPos = FindInPalette( aColor ); + const Color aColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); + ChangeColor( aColor ); + sal_Int32 nPos = FindInPalette( aColor ); - if ( nPos != -1 ) - m_xValSetColorList->SelectItem(m_xValSetColorList->GetItemId(nPos)); - // else search in other palettes? + if ( nPos != -1 ) + m_xValSetColorList->SelectItem(m_xValSetColorList->GetItemId(nPos)); + // else search in other palettes? - } + } - m_aCtlPreviewOld.SetAttributes(aXFillAttr.GetItemSet()); - m_aCtlPreviewOld.Invalidate(); + m_aCtlPreviewOld.SetAttributes(aXFillAttr.GetItemSet()); + m_aCtlPreviewOld.Invalidate(); - SelectValSetHdl_Impl(m_xValSetColorList.get()); - } + SelectValSetHdl_Impl(m_xValSetColorList.get()); } DeactivateRC SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet ) @@ -396,32 +396,32 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) { sal_uInt16 nId = m_xValSetColorList->GetSelectedItemId(); size_t nPos = m_xValSetColorList->GetSelectItemPos(); - if (m_xSelectPalette->get_active() == 0 && nPos != VALUESET_ITEM_NOTFOUND ) + if (!(m_xSelectPalette->get_active() == 0 && nPos != VALUESET_ITEM_NOTFOUND) ) + return; + + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); + css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); + css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); + sal_Int32 nSize = aCustomColorList.getLength() - 1; + for(sal_Int32 nIndex = static_cast<sal_Int32>(nPos);nIndex < nSize;nIndex++) { - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); - css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); - css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); - sal_Int32 nSize = aCustomColorList.getLength() - 1; - for(sal_Int32 nIndex = static_cast<sal_Int32>(nPos);nIndex < nSize;nIndex++) - { - aCustomColorList[nIndex] = aCustomColorList[nIndex+1]; - aCustomColorNameList[nIndex] = aCustomColorNameList[nIndex+1]; - } - aCustomColorList.realloc(nSize); - aCustomColorNameList.realloc(nSize); - officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); - officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); - batch->commit(); - m_xValSetColorList->RemoveItem(nId); - if (m_xValSetColorList->GetItemCount() != 0) - { - nId = m_xValSetColorList->GetItemId(0); - m_xValSetColorList->SelectItem(nId); - SelectValSetHdl_Impl(m_xValSetColorList.get()); - } - else - m_xBtnDelete->set_sensitive(false); + aCustomColorList[nIndex] = aCustomColorList[nIndex+1]; + aCustomColorNameList[nIndex] = aCustomColorNameList[nIndex+1]; } + aCustomColorList.realloc(nSize); + aCustomColorNameList.realloc(nSize); + officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); + officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); + batch->commit(); + m_xValSetColorList->RemoveItem(nId); + if (m_xValSetColorList->GetItemCount() != 0) + { + nId = m_xValSetColorList->GetItemId(0); + m_xValSetColorList->SelectItem(nId); + SelectValSetHdl_Impl(m_xValSetColorList.get()); + } + else + m_xBtnDelete->set_sensitive(false); } IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBox&, void) @@ -462,28 +462,28 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBox&, void) IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, SvtValueSet*, pValSet, void) { sal_Int32 nPos = pValSet->GetSelectedItemId(); - if( nPos != 0 ) - { - Color aColor = pValSet->GetItemColor( nPos ); + if( nPos == 0 ) + return; - rXFSet.Put( XFillColorItem( OUString(), aColor ) ); - m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); - m_aCtlPreviewNew.Invalidate(); - ChangeColor(aColor, false); + Color aColor = pValSet->GetItemColor( nPos ); - if (pValSet == m_xValSetColorList.get()) - { - m_xValSetRecentList->SetNoSelection(); - if (m_xSelectPalette->get_active() == 0 && m_xValSetColorList->GetSelectedItemId() != 0) - m_xBtnDelete->set_sensitive(true); - else - m_xBtnDelete->set_sensitive(false); - } - if (pValSet == m_xValSetRecentList.get()) - { - m_xValSetColorList->SetNoSelection(); + rXFSet.Put( XFillColorItem( OUString(), aColor ) ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlPreviewNew.Invalidate(); + ChangeColor(aColor, false); + + if (pValSet == m_xValSetColorList.get()) + { + m_xValSetRecentList->SetNoSelection(); + if (m_xSelectPalette->get_active() == 0 && m_xValSetColorList->GetSelectedItemId() != 0) + m_xBtnDelete->set_sensitive(true); + else m_xBtnDelete->set_sensitive(false); - } + } + if (pValSet == m_xValSetRecentList.get()) + { + m_xValSetColorList->SetNoSelection(); + m_xBtnDelete->set_sensitive(false); } } |