diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 15:04:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 21:48:16 +0200 |
commit | cd0ab2cf5063242ef3bff3c6899cea4d4bd53485 (patch) | |
tree | 2631f9c128209d178cf2f6b946f5882a5c49e6b2 /basctl/source/basicide/moduldlg.cxx | |
parent | eab4993eab9a2a9e0660a827ed60f0125cf20d53 (diff) |
loplugin:flatten in basctl
Change-Id: I66e3f46fcaae4e15d230a5a7c98c1b20cfb4dbda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92485
Tested-by: Jenkins
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basctl/source/basicide/moduldlg.cxx')
-rw-r--r-- | basctl/source/basicide/moduldlg.cxx | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 2cd8bd8009b3..a4ab2f3fb112 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -164,22 +164,22 @@ void Shell::CopyDialogResources( Reference< io::XInputStream > xInput( io_xISP->createInputStream() ); ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() ); - if( xDialogModel.is() ) + if( !xDialogModel.is() ) + return; + + if( bSourceLocalized && bDestLocalized ) { - if( bSourceLocalized && bDestLocalized ) - { - LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceMgr ); - } - else if( bSourceLocalized ) - { - LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr ); - } - else if( bDestLocalized ) - { - LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr ); - } - io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); + LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceMgr ); } + else if( bSourceLocalized ) + { + LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr ); + } + else if( bDestLocalized ) + { + LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr ); + } + io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); } // OrganizeDialog @@ -776,62 +776,62 @@ void ObjectPage::NewDialog() ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); OUString aLibName; - if ( GetSelection( aDocument, aLibName ) ) - { - aDocument.getOrCreateLibrary( E_DIALOGS, aLibName ); + if ( !GetSelection( aDocument, aLibName ) ) + return; - NewObjectDialog aNewDlg(m_pDialog->getDialog(), ObjectMode::Dialog, true); - aNewDlg.SetObjectName(aDocument.createObjectName(E_DIALOGS, aLibName)); + aDocument.getOrCreateLibrary( E_DIALOGS, aLibName ); - if (aNewDlg.run() != RET_CANCEL) - { - OUString aDlgName = aNewDlg.GetObjectName(); - if (aDlgName.isEmpty()) - aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName); + NewObjectDialog aNewDlg(m_pDialog->getDialog(), ObjectMode::Dialog, true); + aNewDlg.SetObjectName(aDocument.createObjectName(E_DIALOGS, aLibName)); - if ( aDocument.hasDialog( aLibName, aDlgName ) ) - { - std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_pDialog->getDialog(), - VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2))); - xError->run(); - } - else - { - Reference< io::XInputStreamProvider > xISP; - if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) ) - return; + if (aNewDlg.run() == RET_CANCEL) + return; - SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG ); - if (SfxDispatcher* pDispatcher = GetDispatcher()) - { - pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED, - SfxCallMode::SYNCHRON, { &aSbxItem }); - } - LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); - std::unique_ptr<weld::TreeIter> xIter(m_xBasicBox->make_iterator()); - bool bRootEntry = m_xBasicBox->FindRootEntry(aDocument, eLocation, *xIter); - if (bRootEntry) + OUString aDlgName = aNewDlg.GetObjectName(); + if (aDlgName.isEmpty()) + aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName); + + if ( aDocument.hasDialog( aLibName, aDlgName ) ) + { + std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_pDialog->getDialog(), + VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2))); + xError->run(); + } + else + { + Reference< io::XInputStreamProvider > xISP; + if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) ) + return; + + SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG ); + if (SfxDispatcher* pDispatcher = GetDispatcher()) + { + pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED, + SfxCallMode::SYNCHRON, { &aSbxItem }); + } + LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); + std::unique_ptr<weld::TreeIter> xIter(m_xBasicBox->make_iterator()); + bool bRootEntry = m_xBasicBox->FindRootEntry(aDocument, eLocation, *xIter); + if (bRootEntry) + { + if (!m_xBasicBox->get_row_expanded(*xIter)) + m_xBasicBox->expand_row(*xIter); + bool bLibEntry = m_xBasicBox->FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter); + DBG_ASSERT( bLibEntry, "LibEntry not found!" ); + if (bLibEntry) + { + if (!m_xBasicBox->get_row_expanded(*xIter)) + m_xBasicBox->expand_row(*xIter); + std::unique_ptr<weld::TreeIter> xSubRootEntry(m_xBasicBox->make_iterator(xIter.get())); + bool bDlgEntry = m_xBasicBox->FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xIter); + if (!bDlgEntry) { - if (!m_xBasicBox->get_row_expanded(*xIter)) - m_xBasicBox->expand_row(*xIter); - bool bLibEntry = m_xBasicBox->FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter); - DBG_ASSERT( bLibEntry, "LibEntry not found!" ); - if (bLibEntry) - { - if (!m_xBasicBox->get_row_expanded(*xIter)) - m_xBasicBox->expand_row(*xIter); - std::unique_ptr<weld::TreeIter> xSubRootEntry(m_xBasicBox->make_iterator(xIter.get())); - bool bDlgEntry = m_xBasicBox->FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xIter); - if (!bDlgEntry) - { - m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false, - std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get()); - assert(xIter.get() && "Insert entry failed!"); - } - m_xBasicBox->set_cursor(*xIter); - m_xBasicBox->select(*xIter); - } + m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false, + std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get()); + assert(xIter.get() && "Insert entry failed!"); } + m_xBasicBox->set_cursor(*xIter); + m_xBasicBox->select(*xIter); } } } @@ -852,34 +852,34 @@ void ObjectPage::DeleteCurrent() const OUString& aName( aDesc.GetName() ); EntryType eType = aDesc.GetType(); - if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule(aName, m_pDialog->getDialog()) ) || - ( eType == OBJ_TYPE_DIALOG && QueryDelDialog(aName, m_pDialog->getDialog()) ) ) + if ( !(( eType == OBJ_TYPE_MODULE && QueryDelModule(aName, m_pDialog->getDialog()) ) || + ( eType == OBJ_TYPE_DIALOG && QueryDelDialog(aName, m_pDialog->getDialog()) )) ) + return; + + m_xBasicBox->remove(*xCurEntry); + if (m_xBasicBox->get_cursor(xCurEntry.get())) + m_xBasicBox->select(*xCurEntry); + if (SfxDispatcher* pDispatcher = GetDispatcher()) { - m_xBasicBox->remove(*xCurEntry); - if (m_xBasicBox->get_cursor(xCurEntry.get())) - m_xBasicBox->select(*xCurEntry); - if (SfxDispatcher* pDispatcher = GetDispatcher()) - { - SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, SbTreeListBox::ConvertType( eType ) ); - pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED, - SfxCallMode::SYNCHRON, { &aSbxItem }); - } + SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, SbTreeListBox::ConvertType( eType ) ); + pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED, + SfxCallMode::SYNCHRON, { &aSbxItem }); + } - try - { - bool bSuccess = false; - if ( eType == OBJ_TYPE_MODULE ) - bSuccess = aDocument.removeModule( aLibName, aName ); - else if ( eType == OBJ_TYPE_DIALOG ) - bSuccess = RemoveDialog( aDocument, aLibName, aName ); - - if ( bSuccess ) - MarkDocumentModified( aDocument ); - } - catch (const container::NoSuchElementException& ) - { - DBG_UNHANDLED_EXCEPTION("basctl.basicide"); - } + try + { + bool bSuccess = false; + if ( eType == OBJ_TYPE_MODULE ) + bSuccess = aDocument.removeModule( aLibName, aName ); + else if ( eType == OBJ_TYPE_DIALOG ) + bSuccess = RemoveDialog( aDocument, aLibName, aName ); + + if ( bSuccess ) + MarkDocumentModified( aDocument ); + } + catch (const container::NoSuchElementException& ) + { + DBG_UNHANDLED_EXCEPTION("basctl.basicide"); } } |