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/tplneend.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/tplneend.cxx')
-rw-r--r-- | cui/source/tabpages/tplneend.cxx | 200 |
1 files changed, 100 insertions, 100 deletions
diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx index d537b7ea1ac9..a9db979bcda5 100644 --- a/cui/source/tabpages/tplneend.cxx +++ b/cui/source/tabpages/tplneend.cxx @@ -121,24 +121,24 @@ void SvxLineEndDefTabPage::Construct() void SvxLineEndDefTabPage::ActivatePage( const SfxItemSet& ) { - if( nDlgType == 0 ) // area dialog - { - // ActivatePage() is called before the dialog receives PageCreated() !!! - if( pLineEndList.is() ) - { - if( *pPosLineEndLb != -1) - { - m_xLbLineEnds->set_active(*pPosLineEndLb); - SelectLineEndHdl_Impl(); - } - INetURLObject aURL( pLineEndList->GetPath() ); + if( nDlgType != 0 ) // area dialog + return; - aURL.Append( pLineEndList->GetName() ); - DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - *pPageType = PageType::Area; // 3 - *pPosLineEndLb = -1; - } + // ActivatePage() is called before the dialog receives PageCreated() !!! + if( !pLineEndList.is() ) + return; + + if( *pPosLineEndLb != -1) + { + m_xLbLineEnds->set_active(*pPosLineEndLb); + SelectLineEndHdl_Impl(); } + INetURLObject aURL( pLineEndList->GetPath() ); + + aURL.Append( pLineEndList->GetName() ); + DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); + *pPageType = PageType::Area; // 3 + *pPosLineEndLb = -1; } @@ -237,25 +237,25 @@ std::unique_ptr<SfxTabPage> SvxLineEndDefTabPage::Create(weld::Container* pPage, void SvxLineEndDefTabPage::SelectLineEndHdl_Impl() { - if( pLineEndList->Count() > 0 ) - { - int nPos = m_xLbLineEnds->get_active(); + if( pLineEndList->Count() <= 0 ) + return; - const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); + int nPos = m_xLbLineEnds->get_active(); - m_xEdtName->set_text(m_xLbLineEnds->get_active_text()); + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); - rXLSet.Put( XLineStartItem( OUString(), pEntry->GetLineEnd() ) ); - rXLSet.Put( XLineEndItem( OUString(), pEntry->GetLineEnd() ) ); + m_xEdtName->set_text(m_xLbLineEnds->get_active_text()); - // #i34740# - m_aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); - m_aCtlPreview.Invalidate(); + rXLSet.Put( XLineStartItem( OUString(), pEntry->GetLineEnd() ) ); + rXLSet.Put( XLineEndItem( OUString(), pEntry->GetLineEnd() ) ); - // Is not set before, in order to only take the new style, - // if there is an entry selected in the ListBox - *pPageType = PageType::Bitmap; - } + // #i34740# + m_aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); + m_aCtlPreview.Invalidate(); + + // Is not set before, in order to only take the new style, + // if there is an entry selected in the ListBox + *pPageType = PageType::Bitmap; } IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, weld::ComboBox&, void) @@ -266,72 +266,72 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, weld::ComboBox&, vo IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) { int nPos = m_xLbLineEnds->get_active(); - if (nPos != -1) + if (nPos == -1) + return; + + OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); + OUString aName(m_xEdtName->get_text()); + long nCount = pLineEndList->Count(); + bool bDifferent = true; + + // check whether the name is existing already + for ( long i = 0; i < nCount && bDifferent; i++ ) + if ( aName == pLineEndList->GetLineEnd( i )->GetName() ) + bDifferent = false; + + // if yes, repeat and demand a new name + if ( !bDifferent ) { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); - OUString aName(m_xEdtName->get_text()); - long nCount = pLineEndList->Count(); - bool bDifferent = true; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xWarningBox->run(); - // check whether the name is existing already - for ( long i = 0; i < nCount && bDifferent; i++ ) - if ( aName == pLineEndList->GetLineEnd( i )->GetName() ) - bDifferent = false; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + bool bLoop = true; - // if yes, repeat and demand a new name - if ( !bDifferent ) + while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xWarningBox->run(); - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - bool bLoop = true; + pDlg->GetName( aName ); + bDifferent = true; - while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) + for( long i = 0; i < nCount && bDifferent; i++ ) { - pDlg->GetName( aName ); - bDifferent = true; - - for( long i = 0; i < nCount && bDifferent; i++ ) - { - if( aName == pLineEndList->GetLineEnd( i )->GetName() ) - bDifferent = false; - } - - if( bDifferent ) - bLoop = false; - else - xWarningBox->run(); + if( aName == pLineEndList->GetLineEnd( i )->GetName() ) + bDifferent = false; } + + if( bDifferent ) + bLoop = false; + else + xWarningBox->run(); } + } - // if not existing, enter the entry - if( bDifferent ) - { - const XLineEndEntry* pOldEntry = pLineEndList->GetLineEnd(nPos); + // if not existing, enter the entry + if( !bDifferent ) + return; - if(pOldEntry) - { - // #123497# Need to replace the existing entry with a new one - pLineEndList->Replace(std::make_unique<XLineEndEntry>(pOldEntry->GetLineEnd(), aName), nPos); + const XLineEndEntry* pOldEntry = pLineEndList->GetLineEnd(nPos); - m_xEdtName->set_text(aName); + if(pOldEntry) + { + // #123497# Need to replace the existing entry with a new one + pLineEndList->Replace(std::make_unique<XLineEndEntry>(pOldEntry->GetLineEnd(), aName), nPos); - m_xLbLineEnds->Modify(*pLineEndList->GetLineEnd(nPos), nPos, pLineEndList->GetUiBitmap(nPos)); - m_xLbLineEnds->set_active(nPos); + m_xEdtName->set_text(aName); - // set flag for modified - *pnLineEndListState |= ChangeType::MODIFIED; + m_xLbLineEnds->Modify(*pLineEndList->GetLineEnd(nPos), nPos, pLineEndList->GetUiBitmap(nPos)); + m_xLbLineEnds->set_active(nPos); - *pPageType = PageType::Bitmap; - } - else - { - OSL_ENSURE(false, "LineEnd to be modified not existing (!)"); - } - } + // set flag for modified + *pnLineEndListState |= ChangeType::MODIFIED; + + *pPageType = PageType::Bitmap; + } + else + { + OSL_ENSURE(false, "LineEnd to be modified not existing (!)"); } } @@ -582,27 +582,27 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickSaveHdl_Impl, weld::Button&, void) } aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - if ( aDlg.Execute() == ERRCODE_NONE ) - { - INetURLObject aURL( aDlg.GetPath() ); - INetURLObject aPathURL( aURL ); + if ( aDlg.Execute() != ERRCODE_NONE ) + return; - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); + INetURLObject aURL( aDlg.GetPath() ); + INetURLObject aPathURL( aURL ); - pLineEndList->SetName( aURL.getName() ); - pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + aPathURL.removeSegment(); + aPathURL.removeFinalSlash(); - if( pLineEndList->Save() ) - { - *pnLineEndListState &= ~ChangeType::MODIFIED; - } - else - { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui")); - std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("NoSaveFileDialog")); - xBox->run(); - } + pLineEndList->SetName( aURL.getName() ); + pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + + if( pLineEndList->Save() ) + { + *pnLineEndListState &= ~ChangeType::MODIFIED; + } + else + { + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui")); + std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("NoSaveFileDialog")); + xBox->run(); } } |