basctl/source/basicide/baside2.cxx | 2 basctl/source/basicide/baside3.cxx | 21 +++---- basctl/source/basicide/basobj2.cxx | 8 +- basctl/source/basicide/bastype2.cxx | 68 +++++++++++------------ basctl/source/basicide/bastype3.cxx | 82 ++++++++++++++-------------- basctl/source/basicide/doceventnotifier.cxx | 8 +- basctl/source/basicide/macrodlg.cxx | 42 +++++++------- basctl/source/basicide/macrodlg.hxx | 4 - basctl/source/basicide/moduldl2.cxx | 4 - basctl/source/basicide/moduldlg.cxx | 44 +++++++-------- basctl/source/inc/bastype2.hxx | 39 ++++++------- 11 files changed, 160 insertions(+), 162 deletions(-)
New commits: commit 5331de43f79c44e58465f4a8d43b9b759d8e6108 Author: Chiggy Wiggy <[email protected]> AuthorDate: Mon Dec 29 06:45:38 2025 +0100 Commit: Hossein <[email protected]> CommitDate: Tue Jan 13 18:08:08 2026 +0100 tdf#168771 basctl: Convert traditional enums to enum class Converted traditional enums to enum class in basctl for type safety Change-Id: Ie0e7c00cedeae5cc3caa0c9f4b654a30fe9e6670 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196274 Reviewed-by: Hossein <[email protected]> Tested-by: Jenkins diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 9d2e8beb224c..20469dd7faba 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1375,7 +1375,7 @@ EntryDescriptor ModulWindow::CreateEntryDescriptor() break; } } - return EntryDescriptor( std::move(aDocument), eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE ); + return EntryDescriptor( std::move(aDocument), eLocation, aLibName, aLibSubName, aModName, EntryType::Module ); } void ModulWindow::SetReadOnly (bool b) diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 28b3dec93d18..25e587cc95c4 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -840,13 +840,14 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const bool bDialogAlreadyExists = rDocument.hasDialog( aLibName, aXmlDlgName ); OUString aNewDlgName = aXmlDlgName; - enum NameClashMode + enum class NameClashMode { - NO_CLASH, - CLASH_OVERWRITE_DIALOG, - CLASH_RENAME_DIALOG, + None, + OverwriteDialog, + RenameDialog, }; - NameClashMode eNameClashMode = NO_CLASH; + + NameClashMode eNameClashMode = NameClashMode::None; if( bDialogAlreadyExists ) { OUString aQueryBoxTitle(IDEResId(RID_STR_DLGIMP_CLASH_TITLE)); @@ -858,14 +859,14 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const if( nRet == RET_YES ) { // RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox - eNameClashMode = CLASH_RENAME_DIALOG; + eNameClashMode = NameClashMode::RenameDialog; aNewDlgName = rDocument.createObjectName( E_DIALOGS, aLibName ); } else if( nRet == RET_NO ) { // RET_NO == Replace, see NameClashQueryBox::NameClashQueryBox - eNameClashMode = CLASH_OVERWRITE_DIALOG; + eNameClashMode = NameClashMode::OverwriteDialog; } else if( nRet == RET_CANCEL ) { @@ -985,7 +986,7 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const LocalizationMgr::setStringResourceAtDialog( rDocument, aLibName, aNewDlgName, xDialogModel ); - if( eNameClashMode == CLASH_OVERWRITE_DIALOG ) + if( eNameClashMode == NameClashMode::OverwriteDialog ) { if (basctl::RemoveDialog( rDocument, aLibName, aNewDlgName ) ) { @@ -1001,7 +1002,7 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const } } - if( eNameClashMode == CLASH_RENAME_DIALOG ) + if( eNameClashMode == NameClashMode::RenameDialog ) { bool bRenamed = false; if( xDialogModelPropSet.is() ) @@ -1086,7 +1087,7 @@ EntryDescriptor DialogWindow::CreateEntryDescriptor() ScriptDocument aDocument( GetDocument() ); OUString aLibName( GetLibName() ); LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); - return EntryDescriptor( std::move(aDocument), eLocation, aLibName, OUString(), GetName(), OBJ_TYPE_DIALOG ); + return EntryDescriptor( std::move(aDocument), eLocation, aLibName, OUString(), GetName(), EntryType::Dialog ); } void DialogWindow::SetReadOnly (bool bReadOnly) diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index 45251748f855..92433bd5fe66 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -239,12 +239,12 @@ OUString ChooseMacro(weld::Window* pParent, MacroChooser aChooser(pParent, xDocFrame); if (bChooseOnly || !SvtModuleOptions::IsBasicIDEInstalled()) - aChooser.SetMode(MacroChooser::ChooseOnly); + aChooser.SetMode(MacroChooser::Mode::ChooseOnly); if ( !bChooseOnly && rxLimitToDocument.is() ) { // Hack! - aChooser.SetMode(MacroChooser::Recording); + aChooser.SetMode(MacroChooser::Mode::Recording); } short nRetValue = aChooser.run(); @@ -253,12 +253,12 @@ OUString ChooseMacro(weld::Window* pParent, switch ( nRetValue ) { - case Macro_OkRun: + case static_cast<int>(MacroExitCode::Macro_OkRun): { bool bError = false; pMethod = aChooser.GetMacro(); - if ( !pMethod && aChooser.GetMode() == MacroChooser::Recording ) + if ( !pMethod && aChooser.GetMode() == MacroChooser::Mode::Recording ) pMethod = aChooser.CreateMacro(); if ( !pMethod ) diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 1d0b3c009c49..fe514df641f8 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -113,7 +113,7 @@ LibEntry::LibEntry ( LibraryLocation eLocation, OUString aLibName ) : - DocumentEntry(rDocument, eLocation, OBJ_TYPE_LIBRARY), + DocumentEntry(rDocument, eLocation, EntryType::Library), m_aLibName(std::move(aLibName)) { } @@ -123,7 +123,7 @@ LibEntry::~LibEntry() EntryDescriptor::EntryDescriptor () : m_aDocument(ScriptDocument::getApplicationScriptDocument()), m_eLocation(LIBRARY_LOCATION_UNKNOWN), - m_eType(OBJ_TYPE_UNKNOWN) + m_eType(EntryType::Unknown) { } EntryDescriptor::EntryDescriptor ( @@ -249,7 +249,7 @@ void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const Scrip else sId = bLoaded ? RID_BMP_MODLIB : RID_BMP_MODLIBNOTLOADED; std::unique_ptr<weld::TreeIter> xLibRootEntry(m_xControl->make_iterator(&rIter)); - bool bLibRootEntry = FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xLibRootEntry); + bool bLibRootEntry = FindEntry(aLibName, EntryType::Library, *xLibRootEntry); if (bLibRootEntry) { SetEntryBitmaps(*xLibRootEntry, sId); @@ -260,7 +260,7 @@ void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const Scrip } else { - AddEntry(aLibName, sId, &rIter, true, std::make_unique<Entry>(OBJ_TYPE_LIBRARY)); + AddEntry(aLibName, sId, &rIter, true, std::make_unique<Entry>(EntryType::Library)); } } } @@ -289,10 +289,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, for (auto& aModName : rDocument.getObjectNames(E_SCRIPTS, rLibName)) { m_xControl->copy_iterator(rLibRootEntry, *xTreeIter); - bool bModuleEntry = FindEntry(aModName, OBJ_TYPE_MODULE, *xTreeIter); + bool bModuleEntry = FindEntry(aModName, EntryType::Module, *xTreeIter); if (!bModuleEntry) { - AddEntry(aModName, RID_BMP_MODULE, &rLibRootEntry, false, std::make_unique<Entry>(OBJ_TYPE_MODULE), xTreeIter.get()); + AddEntry(aModName, RID_BMP_MODULE, &rLibRootEntry, false, std::make_unique<Entry>(EntryType::Module), xTreeIter.get()); } // methods @@ -303,10 +303,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, for (auto& aName : GetMethodNames(rDocument, rLibName, aModName)) { m_xControl->copy_iterator(*xTreeIter, *xSubTreeIter); - bool bEntry = FindEntry(aName, OBJ_TYPE_METHOD, *xSubTreeIter); + bool bEntry = FindEntry(aName, EntryType::Method, *xSubTreeIter); if (!bEntry) { - AddEntry(aName, RID_BMP_MACRO, xTreeIter.get(), false, std::make_unique<Entry>(OBJ_TYPE_METHOD)); + AddEntry(aName, RID_BMP_MACRO, xTreeIter.get(), false, std::make_unique<Entry>(EntryType::Method)); } } } @@ -337,10 +337,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, for (auto& aDlgName : rDocument.getObjectNames(E_DIALOGS, rLibName)) { m_xControl->copy_iterator(rLibRootEntry, *xTreeIter); - bool bDialogEntry = FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xTreeIter); + bool bDialogEntry = FindEntry(aDlgName, EntryType::Dialog, *xTreeIter); if (!bDialogEntry) { - AddEntry(aDlgName, RID_BMP_DIALOG, &rLibRootEntry, false, std::make_unique<Entry>(OBJ_TYPE_DIALOG)); + AddEntry(aDlgName, RID_BMP_DIALOG, &rLibRootEntry, false, std::make_unique<Entry>(EntryType::Dialog)); } } } @@ -353,10 +353,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, void SbTreeListBox::ImpCreateLibSubEntriesInVBAMode(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName ) { auto const aEntries = { - std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, IDEResId(RID_STR_DOCUMENT_OBJECTS) ), - std::make_pair( OBJ_TYPE_USERFORMS, IDEResId(RID_STR_USERFORMS) ), - std::make_pair( OBJ_TYPE_NORMAL_MODULES, IDEResId(RID_STR_NORMAL_MODULES) ), - std::make_pair( OBJ_TYPE_CLASS_MODULES, IDEResId(RID_STR_CLASS_MODULES) ) }; + std::make_pair( EntryType::DocumentObjects, IDEResId(RID_STR_DOCUMENT_OBJECTS) ), + std::make_pair( EntryType::UserForms, IDEResId(RID_STR_USERFORMS) ), + std::make_pair( EntryType::NormalModules, IDEResId(RID_STR_NORMAL_MODULES) ), + std::make_pair( EntryType::ClassModules, IDEResId(RID_STR_CLASS_MODULES) ) }; for( auto const & iter: aEntries ) { EntryType eType = iter.first; @@ -391,20 +391,20 @@ void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLi for (auto& aModName : rDocument.getObjectNames(E_SCRIPTS, rLibName)) { - EntryType eType = OBJ_TYPE_UNKNOWN; + EntryType eType = EntryType::Unknown; switch( ModuleInfoHelper::getModuleType( xLib, aModName ) ) { case script::ModuleType::DOCUMENT: - eType = OBJ_TYPE_DOCUMENT_OBJECTS; + eType = EntryType::DocumentObjects; break; case script::ModuleType::FORM: - eType = OBJ_TYPE_USERFORMS; + eType = EntryType::UserForms; break; case script::ModuleType::NORMAL: - eType = OBJ_TYPE_NORMAL_MODULES; + eType = EntryType::NormalModules; break; case script::ModuleType::CLASS: - eType = OBJ_TYPE_CLASS_MODULES; + eType = EntryType::ClassModules; break; } if( eType != eCurrentType ) @@ -413,7 +413,7 @@ void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLi // display a nice friendly name in the ObjectModule tab, // combining the objectname and module name, e.g. Sheet1 ( Financials ) OUString aEntryName = aModName; - if( eType == OBJ_TYPE_DOCUMENT_OBJECTS ) + if( eType == EntryType::DocumentObjects ) { OUString sObjName; ModuleInfoHelper::getObjectName( xLib, aModName, sObjName ); @@ -423,12 +423,12 @@ void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLi } } std::unique_ptr<weld::TreeIter> xModuleEntry(m_xControl->make_iterator(&rLibSubRootEntry)); - bool bModuleEntry = FindEntry(aEntryName, OBJ_TYPE_MODULE, *xModuleEntry); + bool bModuleEntry = FindEntry(aEntryName, EntryType::Module, *xModuleEntry); if (!bModuleEntry) { m_xControl->copy_iterator(rLibSubRootEntry, *xModuleEntry); AddEntry(aEntryName, RID_BMP_MODULE, xModuleEntry.get(), false, - std::make_unique<Entry>(OBJ_TYPE_MODULE)); + std::make_unique<Entry>(EntryType::Module)); } // methods @@ -437,10 +437,10 @@ void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLi for (auto& aName : GetMethodNames(rDocument, rLibName, aModName)) { std::unique_ptr<weld::TreeIter> xEntry(m_xControl->make_iterator(xModuleEntry.get())); - bool bEntry = FindEntry(aName, OBJ_TYPE_METHOD, *xEntry); + bool bEntry = FindEntry(aName, EntryType::Method, *xEntry); if (!bEntry) { - AddEntry(aName, RID_BMP_MACRO, xModuleEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_METHOD)); + AddEntry(aName, RID_BMP_MACRO, xModuleEntry.get(), false, std::make_unique<Entry>(EntryType::Method)); } } } @@ -796,12 +796,12 @@ void SbTreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc) bool bCurEntry = false; auto xCurIter = m_xControl->make_iterator(); EntryDescriptor aDesc = rDesc; - if ( aDesc.GetType() == OBJ_TYPE_UNKNOWN ) + if ( aDesc.GetType() == EntryType::Unknown ) { aDesc = EntryDescriptor( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER, u"Standard"_ustr, - OUString(), u"."_ustr, OBJ_TYPE_UNKNOWN + OUString(), u"."_ustr, EntryType::Unknown ); } ScriptDocument aDocument = aDesc.GetDocument(); @@ -817,7 +817,7 @@ void SbTreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc) { m_xControl->expand_row(*m_xScratchIter); auto xLibIter = m_xControl->make_iterator(m_xScratchIter.get()); - bool bLibEntry = FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xLibIter); + bool bLibEntry = FindEntry(aLibName, EntryType::Library, *xLibIter); if (bLibEntry) { m_xControl->copy_iterator(*xLibIter, *xCurIter); @@ -832,9 +832,9 @@ void SbTreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc) if ( !aName.isEmpty() ) { m_xControl->expand_row(*xCurIter); - EntryType eType = OBJ_TYPE_MODULE; - if ( aDesc.GetType() == OBJ_TYPE_DIALOG ) - eType = OBJ_TYPE_DIALOG; + EntryType eType = EntryType::Module; + if ( aDesc.GetType() == EntryType::Dialog ) + eType = EntryType::Dialog; auto xEntryIter = m_xControl->make_iterator(xCurIter.get()); bool bEntry = FindEntry(aName, eType, *xEntryIter); if (bEntry) @@ -845,7 +845,7 @@ void SbTreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc) { m_xControl->expand_row(*xCurIter); auto xSubEntryIter = m_xControl->make_iterator(xCurIter.get()); - bool bSubEntry = FindEntry(aMethodName, OBJ_TYPE_METHOD, *xSubEntryIter); + bool bSubEntry = FindEntry(aMethodName, EntryType::Method, *xSubEntryIter); if (bSubEntry) { m_xControl->copy_iterator(*xSubEntryIter, *xCurIter); @@ -898,9 +898,9 @@ IMPL_LINK_NOARG(SbTreeListBox, OpenCurrentHdl, weld::TreeView&, bool) EntryDescriptor aDesc = GetEntryDescriptor(pCursor.get()); switch (aDesc.GetType()) { - case OBJ_TYPE_METHOD: - case OBJ_TYPE_MODULE: - case OBJ_TYPE_DIALOG: + case EntryType::Method: + case EntryType::Module: + case EntryType::Dialog: if (SfxDispatcher* pDispatcher = GetDispatcher()) { SbxItem aSbxItem( diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx index 6eedbd3affbc..0f3004dc7f2e 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -48,11 +48,11 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b LibraryLocation eLocation = aDesc.GetLocation(); EntryType eType = aDesc.GetType(); - if ( eType == OBJ_TYPE_DOCUMENT ) + if ( eType == EntryType::Document ) { ImpCreateLibEntries( rEntry, aDocument, eLocation ); } - else if ( eType == OBJ_TYPE_LIBRARY ) + else if ( eType == EntryType::Library ) { const OUString& aOULibName( aDesc.GetLibName() ); @@ -112,10 +112,10 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b } } } - else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS - || eType == OBJ_TYPE_USERFORMS - || eType == OBJ_TYPE_NORMAL_MODULES - || eType == OBJ_TYPE_CLASS_MODULES ) + else if ( eType == EntryType::DocumentObjects + || eType == EntryType::UserForms + || eType == EntryType::NormalModules + || eType == EntryType::ClassModules ) { const OUString& aLibName( aDesc.GetLibName() ); ImpCreateLibSubSubEntriesInVBAMode( rEntry, aDocument, aLibName ); @@ -191,11 +191,11 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry) switch ( pBE->GetType() ) { - case OBJ_TYPE_LIBRARY: + case EntryType::Library: if (BasicManager* pBasMgr = aDocument.getBasicManager()) pVar = pBasMgr->GetLib( aName ); break; - case OBJ_TYPE_MODULE: + case EntryType::Module: DBG_ASSERT(dynamic_cast<StarBASIC*>(pVar), "FindVariable: invalid Basic"); if(!pVar) { @@ -208,7 +208,7 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry) } pVar = static_cast<StarBASIC*>(pVar)->FindModule( aName ); break; - case OBJ_TYPE_METHOD: + case EntryType::Method: DBG_ASSERT(dynamic_cast<SbxObject*>(pVar), "FindVariable: invalid module/object"); if(!pVar) { @@ -216,15 +216,15 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry) } pVar = static_cast<SbxObject*>(pVar)->GetMethods()->Find(aName, SbxClassType::Method); break; - case OBJ_TYPE_DIALOG: + case EntryType::Dialog: // sbx dialogs removed break; - case OBJ_TYPE_DOCUMENT_OBJECTS: + case EntryType::DocumentObjects: bDocumentObjects = true; [[fallthrough]]; - case OBJ_TYPE_USERFORMS: - case OBJ_TYPE_NORMAL_MODULES: - case OBJ_TYPE_CLASS_MODULES: + case EntryType::UserForms: + case EntryType::NormalModules: + case EntryType::ClassModules: // skip, to find the child entry. continue; default: @@ -247,7 +247,7 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry) OUString aLibSubName; OUString aName; OUString aMethodName; - EntryType eType = OBJ_TYPE_UNKNOWN; + EntryType eType = EntryType::Unknown; if ( !pEntry ) return EntryDescriptor(std::move(aDocument), eLocation, aLibName, aLibSubName, aName, aMethodName, eType); @@ -276,7 +276,7 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry) { aDocument = pDocumentEntry->GetDocument(); eLocation = pDocumentEntry->GetLocation(); - eType = OBJ_TYPE_DOCUMENT; + eType = EntryType::Document; } } break; @@ -294,29 +294,29 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry) switch ( pBE->GetType() ) { - case OBJ_TYPE_LIBRARY: + case EntryType::Library: { aLibName = pair.second; eType = pBE->GetType(); } break; - case OBJ_TYPE_MODULE: - case OBJ_TYPE_DIALOG: + case EntryType::Module: + case EntryType::Dialog: { aName = pair.second; eType = pBE->GetType(); } break; - case OBJ_TYPE_METHOD: + case EntryType::Method: { aMethodName = pair.second; eType = pBE->GetType(); } break; - case OBJ_TYPE_DOCUMENT_OBJECTS: - case OBJ_TYPE_USERFORMS: - case OBJ_TYPE_NORMAL_MODULES: - case OBJ_TYPE_CLASS_MODULES: + case EntryType::DocumentObjects: + case EntryType::UserForms: + case EntryType::NormalModules: + case EntryType::ClassModules: { aLibSubName = pair.second; eType = pBE->GetType(); @@ -325,12 +325,12 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry) default: { OSL_FAIL( "GetEntryDescriptor: unknown type" ); - eType = OBJ_TYPE_UNKNOWN; + eType = EntryType::Unknown; } break; } - if ( eType == OBJ_TYPE_UNKNOWN ) + if ( eType == EntryType::Unknown ) break; } } @@ -343,13 +343,13 @@ SbxItemType SbTreeListBox::ConvertType (EntryType eType) { switch (eType) { - case OBJ_TYPE_DOCUMENT: return SBX_TYPE_SHELL; - case OBJ_TYPE_LIBRARY: return SBX_TYPE_LIBRARY; - case OBJ_TYPE_MODULE: return SBX_TYPE_MODULE; - case OBJ_TYPE_DIALOG: return SBX_TYPE_DIALOG; - case OBJ_TYPE_METHOD: return SBX_TYPE_METHOD; + case EntryType::Document: return SBX_TYPE_SHELL; + case EntryType::Library: return SBX_TYPE_LIBRARY; + case EntryType::Module: return SBX_TYPE_MODULE; + case EntryType::Dialog: return SBX_TYPE_DIALOG; + case EntryType::Method: return SBX_TYPE_METHOD; default: - return static_cast<SbxItemType>(OBJ_TYPE_UNKNOWN); + return static_cast<SbxItemType>(EntryType::Unknown); } } @@ -367,37 +367,37 @@ bool SbTreeListBox::IsValidEntry(const weld::TreeIter& rEntry) switch ( eType ) { - case OBJ_TYPE_DOCUMENT: + case EntryType::Document: { bIsValid = aDocument.isAlive() && (aDocument.isApplication() || GetRootEntryName(aDocument, eLocation) == m_xControl->get_text(rEntry)); } break; - case OBJ_TYPE_LIBRARY: + case EntryType::Library: { bIsValid = aDocument.hasLibrary( E_SCRIPTS, aLibName ) || aDocument.hasLibrary( E_DIALOGS, aLibName ); } break; - case OBJ_TYPE_MODULE: + case EntryType::Module: { bIsValid = aDocument.hasModule( aLibName, aName ); } break; - case OBJ_TYPE_DIALOG: + case EntryType::Dialog: { bIsValid = aDocument.hasDialog( aLibName, aName ); } break; - case OBJ_TYPE_METHOD: + case EntryType::Method: { bIsValid = HasMethod( aDocument, aLibName, aName, aMethodName ); } break; - case OBJ_TYPE_DOCUMENT_OBJECTS: - case OBJ_TYPE_USERFORMS: - case OBJ_TYPE_NORMAL_MODULES: - case OBJ_TYPE_CLASS_MODULES: + case EntryType::DocumentObjects: + case EntryType::UserForms: + case EntryType::NormalModules: + case EntryType::ClassModules: { bIsValid = true; } diff --git a/basctl/source/basicide/doceventnotifier.cxx b/basctl/source/basicide/doceventnotifier.cxx index 2365aef2ee16..c50aa061c338 100644 --- a/basctl/source/basicide/doceventnotifier.cxx +++ b/basctl/source/basicide/doceventnotifier.cxx @@ -49,7 +49,7 @@ namespace basctl namespace { - enum ListenerAction + enum class ListenerAction { RegisterListener, RemoveListener @@ -99,7 +99,7 @@ namespace basctl { std::unique_lock aGuard(m_aMutex); osl_atomic_increment( &m_refCount ); - impl_listenerAction_nothrow( aGuard, RegisterListener ); + impl_listenerAction_nothrow( aGuard, ListenerAction::RegisterListener ); osl_atomic_decrement( &m_refCount ); } @@ -178,7 +178,7 @@ namespace basctl void DocumentEventNotifier::Impl::disposing(std::unique_lock<std::mutex>& rGuard) { - impl_listenerAction_nothrow( rGuard, RemoveListener ); + impl_listenerAction_nothrow( rGuard, ListenerAction::RemoveListener ); impl_dispose_nothrow(rGuard); } @@ -203,7 +203,7 @@ namespace basctl } void ( SAL_CALL XDocumentEventBroadcaster::*listenerAction )( const Reference< XDocumentEventListener >& ) = - ( _eAction == RegisterListener ) ? &XDocumentEventBroadcaster::addDocumentEventListener : &XDocumentEventBroadcaster::removeDocumentEventListener; + ( _eAction == ListenerAction::RegisterListener ) ? &XDocumentEventBroadcaster::addDocumentEventListener : &XDocumentEventBroadcaster::removeDocumentEventListener; rGuard.unlock(); (xBroadcaster.get()->*listenerAction)( this ); diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx index 0bdadf0da00c..9a9e4918fc02 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -59,7 +59,7 @@ MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< frame::XFrame // the Sfx doesn't ask the BasicManager whether modified or not // => start saving in case of a change without a into the BasicIDE. , bForceStoreBasic(false) - , nMode(All) + , nMode(Mode::All) , m_xMacroNameEdit(m_xBuilder->weld_entry(u"macronameedit"_ustr)) , m_xMacroLibsFrame(m_xBuilder->weld_frame(u"librariesframe"_ustr)) , m_xBasicBox(new SbTreeListBox(m_xBuilder->weld_tree_view(u"libraries"_ustr), m_xDialog.get())) @@ -136,7 +136,7 @@ void MacroChooser::StoreMacroDescription() if ( !aMethodName.isEmpty() ) { aDesc.SetMethodName( aMethodName ); - aDesc.SetType( OBJ_TYPE_METHOD ); + aDesc.SetType( EntryType::Method ); } if (ExtraData* pData = basctl::GetExtraData()) @@ -231,7 +231,7 @@ void MacroChooser::EnableButton(weld::Button& rButton, bool bEnable) { if ( bEnable ) { - if (nMode == ChooseOnly || nMode == Recording) + if (nMode == Mode::ChooseOnly || nMode == Mode::Recording) rButton.set_sensitive(&rButton == m_xRunButton.get()); else rButton.set_sensitive(true); @@ -403,11 +403,11 @@ void MacroChooser::CheckButtons() } } - if (nMode != Recording) + if (nMode != Mode::Recording) { // Run... bool bEnable = pMethod != nullptr; - if (nMode != ChooseOnly && StarBASIC::IsRunning()) + if (nMode != Mode::ChooseOnly && StarBASIC::IsRunning()) bEnable = false; EnableButton(*m_xRunButton, bEnable); } @@ -421,15 +421,15 @@ void MacroChooser::CheckButtons() EnableButton(*m_xEditButton, bMacroEntry); // Organizer... - EnableButton(*m_xOrganizeButton, !StarBASIC::IsRunning() && nMode == All); + EnableButton(*m_xOrganizeButton, !StarBASIC::IsRunning() && nMode == Mode::All); // m_xDelButton/m_xNewButton ->... bool bProtected = pCursor && m_xBasicBox->IsEntryProtected(pCursor.get()); bool bShare = ( aDesc.GetLocation() == LIBRARY_LOCATION_SHARE ); - bool bEnable = !StarBASIC::IsRunning() && nMode == All && !bProtected && !bReadOnly && !bShare; + bool bEnable = !StarBASIC::IsRunning() && nMode == Mode::All && !bProtected && !bReadOnly && !bShare; EnableButton(*m_xDelButton, bEnable); EnableButton(*m_xNewButton, bEnable); - if (nMode == All) + if (nMode == Mode::All) { if (pMethod) { @@ -443,7 +443,7 @@ void MacroChooser::CheckButtons() } } - if (nMode == Recording) + if (nMode == Mode::Recording) { // save button m_xRunButton->set_sensitive(!bProtected && !bReadOnly && !bShare); @@ -471,13 +471,13 @@ IMPL_LINK_NOARG(MacroChooser, MacroDoubleClickHdl, weld::TreeView&, bool) } StoreMacroDescription(); - if (nMode == Recording) + if (nMode == Mode::Recording) { if (pMethod && !QueryReplaceMacro(pMethod->GetName(), m_xDialog.get())) return true; } - m_xDialog->response(Macro_OkRun); + m_xDialog->response(static_cast<int>(MacroExitCode::Macro_OkRun)); return true; } @@ -586,7 +586,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) StoreMacroDescription(); // #116444# check security settings before macro execution - if (nMode == All) + if (nMode == Mode::All) { SbMethod* pMethod = GetMacro(); SbModule* pModule = pMethod ? pMethod->GetModule() : nullptr; @@ -604,7 +604,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) } } } - else if (nMode == Recording ) + else if (nMode == Mode::Recording ) { if ( !IsValidSbxName(m_xMacroNameEdit->get_text()) ) { @@ -621,12 +621,12 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) return; } - m_xDialog->response(Macro_OkRun); + m_xDialog->response(static_cast<int>(MacroExitCode::Macro_OkRun)); } else if (&rButton == m_xCloseButton.get()) { StoreMacroDescription(); - m_xDialog->response(Macro_Close); + m_xDialog->response(static_cast<int>(MacroExitCode::Macro_Close)); } else if (&rButton == m_xEditButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xNewButton.get()) { @@ -672,7 +672,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) pDispatcher->ExecuteList(SID_BASICIDE_EDITMACRO, SfxCallMode::ASYNCHRON, { &aInfoItem }); } - m_xDialog->response(Macro_Edit); + m_xDialog->response(static_cast<int>(MacroExitCode::Macro_Close)); } else { @@ -716,7 +716,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) SfxCallMode::ASYNCHRON, { &aInfoItem }); } StoreMacroDescription(); - m_xDialog->response(Macro_New); + m_xDialog->response(static_cast<int>(MacroExitCode::Macro_New)); } } } @@ -798,7 +798,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) weld::DialogController::runAsync(xDlg, [this](sal_Int32 nRet) { if (nRet == RET_OK) // not only closed { - m_xDialog->response(Macro_Edit); + m_xDialog->response(static_cast<int>(MacroExitCode::Macro_Close)); return; } @@ -853,7 +853,7 @@ void MacroChooser::SetMode (Mode nM) nMode = nM; switch (nMode) { - case All: + case Mode::All: { m_xRunButton->set_label(IDEResId(RID_STR_RUN)); EnableButton(*m_xDelButton, true); @@ -862,7 +862,7 @@ void MacroChooser::SetMode (Mode nM) break; } - case ChooseOnly: + case Mode::ChooseOnly: { m_xRunButton->set_label(IDEResId(RID_STR_CHOOSE)); EnableButton(*m_xDelButton, false); @@ -871,7 +871,7 @@ void MacroChooser::SetMode (Mode nM) break; } - case Recording: + case Mode::Recording: { m_xRunButton->set_label(IDEResId(RID_STR_RECORD)); EnableButton(*m_xDelButton, false); diff --git a/basctl/source/basicide/macrodlg.hxx b/basctl/source/basicide/macrodlg.hxx index f34fbdd40145..608ac3003cef 100644 --- a/basctl/source/basicide/macrodlg.hxx +++ b/basctl/source/basicide/macrodlg.hxx @@ -30,7 +30,7 @@ namespace basctl { -enum MacroExitCode { +enum class MacroExitCode { Macro_Close = 110, Macro_OkRun = 111, Macro_New = 112, @@ -40,7 +40,7 @@ enum MacroExitCode { class MacroChooser : public SfxDialogController { public: - enum Mode { + enum class Mode { All = 1, ChooseOnly = 2, Recording = 3, diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index d47a5de7d3f0..85cf23ac4759 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -1405,8 +1405,8 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument, BrowseMode nMode = pBasicBox->GetMode(); bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules ); const auto sId = bDlgMode ? RID_BMP_DLGLIB : RID_BMP_MODLIB; - pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY)); - pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_MODULE)); + pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(EntryType::Library)); + pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(EntryType::Module)); pBasicBox->set_cursor(*xRootEntry); pBasicBox->select(*xRootEntry); } diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 453b78ba2ea8..9eb9cc6c9a2c 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -106,7 +106,7 @@ IMPL_LINK(ObjectPage, EditedEntryHdl, const IterString&, rIterString, bool) const OUString& aLibName( aDesc.GetLibName() ); EntryType eType = aDesc.GetType(); - bool bSuccess = eType == OBJ_TYPE_MODULE ? + bool bSuccess = eType == EntryType::Module ? RenameModule(m_pDialog->getDialog(), aDocument, aLibName, aCurText, sNewText) : RenameDialog(m_pDialog->getDialog(), aDocument, aLibName, aCurText, sNewText); @@ -196,7 +196,7 @@ void OrganizeDialog::SetCurrentEntry(const css::uno::Reference<css::frame::XFram Reference<css::frame::XModel> xModel(xController->getModel()); if (!xModel) return; - EntryDescriptor aDesc(ScriptDocument(xModel), LIBRARY_LOCATION_DOCUMENT, OUString(), OUString(), OUString(), OBJ_TYPE_DOCUMENT); + EntryDescriptor aDesc(ScriptDocument(xModel), LIBRARY_LOCATION_DOCUMENT, OUString(), OUString(), OUString(), EntryType::Module); m_xModulePage->SetCurrentEntry(aDesc); m_xDialogPage->SetCurrentEntry(aDesc); } @@ -381,8 +381,8 @@ private: } // check, if module/dialog with this name is already existing in target library - if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( aDestLibName, aSourceName ) ) || - ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( aDestLibName, aSourceName ) ) ) + if ( ( eSourceType == EntryType::Module && rDestDoc.hasModule( aDestLibName, aSourceName ) ) || + ( eSourceType == EntryType::Dialog && rDestDoc.hasDialog( aDestLibName, aSourceName ) ) ) { bValid = false; } @@ -440,7 +440,7 @@ private: try { - if ( eType == OBJ_TYPE_MODULE ) // module + if ( eType == EntryType::Module ) // module { // get module OUString aModule; @@ -457,7 +457,7 @@ private: } } } - else if ( eType == OBJ_TYPE_DIALOG ) // dialog + else if ( eType == EntryType::Dialog ) // dialog { // get dialog Reference< io::XInputStreamProvider > xISP; @@ -487,7 +487,7 @@ private: { try { - if ( eType == OBJ_TYPE_MODULE ) // module + if ( eType == EntryType::Module ) // module { // get module OUString aModule; @@ -498,7 +498,7 @@ private: MarkDocumentModified( rDestDoc ); } } - else if ( eType == OBJ_TYPE_DIALOG ) // dialog + else if ( eType == EntryType::Dialog ) // dialog { // get dialog Reference< io::XInputStreamProvider > xISP; @@ -524,15 +524,15 @@ private: /// if copying then clone the userdata if (Entry* pEntry = bMove ? nullptr : weld::fromId<Entry*>(sId)) { - assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT); + assert(pEntry->GetType() != EntryType::Document); std::unique_ptr<Entry> xNewUserData(std::make_unique<Entry>(*pEntry)); sId = weld::toId(xNewUserData.release()); } std::unique_ptr<weld::TreeIter> xRet(m_rTreeView.make_iterator()); m_rTreeView.get_widget().insert(xNewParent.get(), nNewChildPos, &sText, &sId, nullptr, nullptr, false, xRet.get()); - if (eType == OBJ_TYPE_MODULE) + if (eType == EntryType::Module) m_rTreeView.get_widget().set_image(*xRet, RID_BMP_MODULE); - else if (eType == OBJ_TYPE_DIALOG) + else if (eType == EntryType::Dialog) m_rTreeView.get_widget().set_image(*xRet, RID_BMP_DIALOG); if (!m_rTreeView.get_row_expanded(*xNewParent)) m_rTreeView.expand_row(*xNewParent); @@ -847,18 +847,18 @@ void ObjectPage::NewDialog() { if (!m_xBasicBox->get_row_expanded(*xIter)) m_xBasicBox->expand_row(*xIter); - bool bLibEntry = m_xBasicBox->FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter); + bool bLibEntry = m_xBasicBox->FindEntry(aLibName, EntryType::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); + bool bDlgEntry = m_xBasicBox->FindEntry(aDlgName, EntryType::Dialog, *xIter); if (!bDlgEntry) { m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false, - std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get()); + std::make_unique<Entry>(EntryType::Dialog), xIter.get()); assert(xIter && "Insert entry failed!"); } m_xBasicBox->set_cursor(*xIter); @@ -883,8 +883,8 @@ 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 == EntryType::Module && QueryDelModule(aName, m_pDialog->getDialog()) ) || + ( eType == EntryType::Dialog && QueryDelDialog(aName, m_pDialog->getDialog()) )) ) return; m_xBasicBox->remove(*xCurEntry); @@ -901,9 +901,9 @@ void ObjectPage::DeleteCurrent() try { bool bSuccess = false; - if ( eType == OBJ_TYPE_MODULE ) + if ( eType == EntryType::Module ) bSuccess = aDocument.removeModule( aLibName, aName ); - else if ( eType == OBJ_TYPE_DIALOG ) + else if ( eType == EntryType::Dialog ) bSuccess = RemoveDialog( aDocument, aLibName, aName ); if ( bSuccess ) @@ -995,7 +995,7 @@ SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument, { if (!rBasicBox.get_row_expanded(*xIter)) rBasicBox.expand_row(*xIter); - bool bLibEntry = rBasicBox.FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter); + bool bLibEntry = rBasicBox.FindEntry(aLibName, EntryType::Library, *xIter); DBG_ASSERT( bLibEntry, "LibEntry not found!" ); if (bLibEntry) { @@ -1006,7 +1006,7 @@ SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument, { // add the new module in the "Modules" entry std::unique_ptr<weld::TreeIter> xLibSubEntry(rBasicBox.make_iterator(xIter.get())); - bool bLibSubEntry = rBasicBox.FindEntry(IDEResId(RID_STR_NORMAL_MODULES) , OBJ_TYPE_NORMAL_MODULES, *xLibSubEntry); + bool bLibSubEntry = rBasicBox.FindEntry(IDEResId(RID_STR_NORMAL_MODULES) , EntryType::NormalModules, *xLibSubEntry); if (bLibSubEntry) { if (!rBasicBox.get_row_expanded(*xLibSubEntry)) @@ -1016,11 +1016,11 @@ SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument, } std::unique_ptr<weld::TreeIter> xEntry(rBasicBox.make_iterator(xSubRootEntry.get())); - bool bEntry = rBasicBox.FindEntry(aModName, OBJ_TYPE_MODULE, *xEntry); + bool bEntry = rBasicBox.FindEntry(aModName, EntryType::Module, *xEntry); if (!bEntry) { rBasicBox.AddEntry(aModName, RID_BMP_MODULE, xSubRootEntry.get(), false, - std::make_unique<Entry>(OBJ_TYPE_MODULE), xEntry.get()); + std::make_unique<Entry>(EntryType::Module), xEntry.get()); } rBasicBox.set_cursor(*xEntry); rBasicBox.select(*xEntry); diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx index 632a4ac94407..f66dc8641903 100644 --- a/basctl/source/inc/bastype2.hxx +++ b/basctl/source/inc/bastype2.hxx @@ -49,18 +49,18 @@ namespace o3tl { namespace basctl { -enum EntryType +enum class EntryType { - OBJ_TYPE_UNKNOWN, - OBJ_TYPE_DOCUMENT, - OBJ_TYPE_LIBRARY, - OBJ_TYPE_MODULE, - OBJ_TYPE_DIALOG, - OBJ_TYPE_METHOD, - OBJ_TYPE_DOCUMENT_OBJECTS, - OBJ_TYPE_USERFORMS, - OBJ_TYPE_NORMAL_MODULES, - OBJ_TYPE_CLASS_MODULES + Unknown, + Document, + Library, + Module, + Dialog, + Method, + DocumentObjects, + UserForms, + NormalModules, + ClassModules }; class Entry @@ -94,7 +94,7 @@ public: DocumentEntry ( ScriptDocument aDocument, LibraryLocation eLocation, - EntryType eType = OBJ_TYPE_DOCUMENT + EntryType eType = EntryType::Document ); virtual ~DocumentEntry () override; @@ -163,16 +163,13 @@ public: friend bool operator==(const basctl::EntryDescriptor& aDesc1, const basctl::EntryDescriptor& aDesc2) = default; }; - /* Classification of types and pointers in the Entries: - - OBJ_TYPE_DOCUMENT DocumentEntry - OBJ_TYPE_LIBRARY Entry - OBJ_TYPE_MODULE Entry - OBJ_TYPE_DIALOG Entry - OBJ_TYPE_METHOD Entry - + EntryType::Document DocumentEntry + EntryType::Library Entry + EntryType::Module Entry + EntryType::Dialog Entry + EntryType::Method Entry */ class SbTreeListBox : public DocumentEventListener @@ -308,7 +305,7 @@ template<> class hash<basctl::EntryDescriptor> rDesc.GetLibSubName() + "|" + rDesc.GetName() + "|" + rDesc.GetMethodName() + "|" + - OUString::number(rDesc.GetType()); + OUString::number(static_cast<int>(rDesc.GetType())); return sDescSerial.hashCode(); }
