From 04a5157e9526c1570034fc88973a061138b133ea Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Wed, 22 May 2024 12:26:46 +0200 Subject: Add SfxItemType to SfxPoolItem The SfxPoolItem has a new member SfxItemType m_eItemType to compare types based on enums instead of typeinfo() which consumes a lot of time e.g. while AutoFormat is running Change-Id: I033ce67bc9a28ee4790f162380314de85fb4154e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166452 Tested-by: Jenkins Reviewed-by: Thorsten Behrens Reviewed-by: Armin Le Grand Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169185 Tested-by: Thorsten Behrens --- basctl/source/basicide/baside2.cxx | 4 ++-- basctl/source/basicide/baside2.hxx | 2 +- basctl/source/basicide/baside3.cxx | 4 ++-- basctl/source/basicide/basides1.cxx | 20 ++++++++++---------- basctl/source/basicide/basides2.cxx | 2 +- basctl/source/basicide/basides3.cxx | 2 +- basctl/source/basicide/basidesh.cxx | 4 ++-- basctl/source/basicide/bastype3.cxx | 14 +++++++------- basctl/source/basicide/bastypes.cxx | 12 ++++++------ basctl/source/basicide/moduldl2.cxx | 2 +- basctl/source/basicide/moduldlg.cxx | 4 ++-- basctl/source/basicide/sbxitem.cxx | 14 +++++++------- basctl/source/inc/baside3.hxx | 2 +- basctl/source/inc/basidesh.hxx | 2 +- basctl/source/inc/bastype2.hxx | 2 +- basctl/source/inc/bastypes.hxx | 12 ++++++------ basctl/source/inc/sbxitem.hxx | 22 +++++++++++----------- 17 files changed, 62 insertions(+), 62 deletions(-) (limited to 'basctl/source') diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index b01e5c238a6c..e53f5fad7728 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1400,9 +1400,9 @@ OUString ModulWindow::GetHid () const { return HID_BASICIDE_MODULWINDOW; } -ItemType ModulWindow::GetType () const +SbxItemType ModulWindow::GetSbxType () const { - return TYPE_MODULE; + return SBX_TYPE_MODULE; } bool ModulWindow::HasActiveEditor () const diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 116dab2bb905..e94ccfbb391b 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -388,7 +388,7 @@ public: virtual void OnNewDocument () override; virtual OUString GetHid () const override; - virtual ItemType GetType () const override; + virtual SbxItemType GetSbxType () const override; virtual bool HasActiveEditor () const override; void UpdateModule (); diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 4a6b1dfbfb5c..eee94719c45a 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -1190,9 +1190,9 @@ OUString DialogWindow::GetHid () const return HID_BASICIDE_DIALOGWINDOW; } -ItemType DialogWindow::GetType () const +SbxItemType DialogWindow::GetSbxType () const { - return TYPE_DIALOG; + return SBX_TYPE_DIALOG; } diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 9ef9f75e3f40..70c0342ec574 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -627,9 +627,9 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) const OUString& aName( rSbxItem.GetName() ); if ( m_aCurLibName.isEmpty() || ( aDocument == m_aCurDocument && aLibName == m_aCurLibName ) ) { - if ( rSbxItem.GetType() == TYPE_MODULE ) + if ( rSbxItem.GetSbxType() == SBX_TYPE_MODULE ) FindBasWin( aDocument, aLibName, aName, true ); - else if ( rSbxItem.GetType() == TYPE_DIALOG ) + else if ( rSbxItem.GetSbxType() == SBX_TYPE_DIALOG ) FindDlgWin( aDocument, aLibName, aName, true ); } } @@ -639,7 +639,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) DBG_ASSERT( rReq.GetArgs(), "arguments expected" ); const SbxItem& rSbxItem = rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX ); const ScriptDocument& aDocument( rSbxItem.GetDocument() ); - VclPtr pWin = FindWindow( aDocument, rSbxItem.GetLibName(), rSbxItem.GetName(), rSbxItem.GetType(), true ); + VclPtr pWin = FindWindow( aDocument, rSbxItem.GetLibName(), rSbxItem.GetName(), rSbxItem.GetSbxType(), true ); if ( pWin ) RemoveWindow( pWin, true ); } @@ -653,15 +653,15 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) const OUString& aName( rSbxItem.GetName() ); SetCurLib( aDocument, aLibName ); BaseWindow* pWin = nullptr; - if ( rSbxItem.GetType() == TYPE_DIALOG ) + if ( rSbxItem.GetSbxType() == SBX_TYPE_DIALOG ) { pWin = FindDlgWin( aDocument, aLibName, aName, true ); } - else if ( rSbxItem.GetType() == TYPE_MODULE ) + else if ( rSbxItem.GetSbxType() == SBX_TYPE_MODULE ) { pWin = FindBasWin( aDocument, aLibName, aName, true ); } - else if ( rSbxItem.GetType() == TYPE_METHOD ) + else if ( rSbxItem.GetSbxType() == SBX_TYPE_METHOD ) { pWin = FindBasWin( aDocument, aLibName, aName, true ); static_cast(pWin)->EditMacro( rSbxItem.GetMethodName() ); @@ -1278,7 +1278,7 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe pLayout->Deactivating(); if (pCurWin) { - if (pCurWin->GetType() == TYPE_MODULE) + if (pCurWin->GetSbxType() == SBX_TYPE_MODULE) pLayout = pModulLayout.get(); else pLayout = pDialogLayout.get(); @@ -1385,19 +1385,19 @@ void Shell::ManageToolbars() VclPtr Shell::FindApplicationWindow() { - return FindWindow( ScriptDocument::getApplicationScriptDocument(), u"", u"", TYPE_UNKNOWN ); + return FindWindow( ScriptDocument::getApplicationScriptDocument(), u"", u"", SBX_TYPE_UNKNOWN ); } VclPtr Shell::FindWindow( ScriptDocument const& rDocument, std::u16string_view rLibName, std::u16string_view rName, - ItemType eType, bool bFindSuspended + SbxItemType eSbxItemType, bool bFindSuspended ) { for (auto const& window : aWindowTable) { BaseWindow* const pWin = window.second; - if (pWin->Is(rDocument, rLibName, rName, eType, bFindSuspended)) + if (pWin->Is(rDocument, rLibName, rName, eSbxItemType, bFindSuspended)) return pWin; } return nullptr; diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 5bd69b76f380..249b3e6f43c7 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -208,7 +208,7 @@ VclPtr Shell::FindBasWin ( bool bCreateIfNotExist, bool bFindSuspended ) { - if (VclPtr pWin = FindWindow(rDocument, rLibName, rName, TYPE_MODULE, bFindSuspended)) + if (VclPtr pWin = FindWindow(rDocument, rLibName, rName, SBX_TYPE_MODULE, bFindSuspended)) return VclPtr(static_cast(pWin.get())); return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rName) : nullptr; } diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx index 44bc54ba624f..acc6dbf0273f 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -117,7 +117,7 @@ VclPtr Shell::FindDlgWin ( bool bCreateIfNotExist, bool bFindSuspended ) { - if (VclPtr pWin = FindWindow(rDocument, rLibName, rName, TYPE_DIALOG, bFindSuspended)) + if (VclPtr pWin = FindWindow(rDocument, rLibName, rName, SBX_TYPE_DIALOG, bFindSuspended)) return static_cast(pWin.get()); return bCreateIfNotExist ? CreateDlgWin(rDocument, rLibName, rName) : nullptr; } diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index d23da94d268f..765b22ddefd6 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -715,7 +715,7 @@ void Shell::UpdateWindows() if ( !pWin ) pWin = CreateBasWin( doc, aLibName, aModName ); if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName && - pLibInfoItem->GetCurrentType() == TYPE_MODULE ) + pLibInfoItem->GetCurrentType() == SBX_TYPE_MODULE ) { pNextActiveWindow = pWin; } @@ -747,7 +747,7 @@ void Shell::UpdateWindows() if ( !pWin ) pWin = CreateDlgWin( doc, aLibName, aDlgName ); if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName && - pLibInfoItem->GetCurrentType() == TYPE_DIALOG ) + pLibInfoItem->GetCurrentType() == SBX_TYPE_DIALOG ) { pNextActiveWindow = pWin; } diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx index d26ae83252f6..b025859a611c 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -341,17 +341,17 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry) return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType ); } -ItemType SbTreeListBox::ConvertType (EntryType eType) +SbxItemType SbTreeListBox::ConvertType (EntryType eType) { switch (eType) { - case OBJ_TYPE_DOCUMENT: return TYPE_SHELL; - case OBJ_TYPE_LIBRARY: return TYPE_LIBRARY; - case OBJ_TYPE_MODULE: return TYPE_MODULE; - case OBJ_TYPE_DIALOG: return TYPE_DIALOG; - case OBJ_TYPE_METHOD: return TYPE_METHOD; + 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; default: - return static_cast(OBJ_TYPE_UNKNOWN); + return static_cast(OBJ_TYPE_UNKNOWN); } } diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index e436bc9f7e0a..868dd3fea230 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -279,22 +279,22 @@ void BaseWindow::OnNewDocument () void BaseWindow::InsertLibInfo () const { if (ExtraData* pData = GetExtraData()) - pData->GetLibInfo().InsertInfo(m_aDocument, m_aLibName, m_aName, GetType()); + pData->GetLibInfo().InsertInfo(m_aDocument, m_aLibName, m_aName, GetSbxType()); } bool BaseWindow::Is ( ScriptDocument const& rDocument, std::u16string_view rLibName, std::u16string_view rName, - ItemType eType, bool bFindSuspended + SbxItemType eSbxType, bool bFindSuspended ) { if (bFindSuspended || !IsSuspended()) { // any non-suspended window is ok - if (rLibName.empty() || rName.empty() || eType == TYPE_UNKNOWN) + if (rLibName.empty() || rName.empty() || eSbxType == SBX_TYPE_UNKNOWN) return true; // ok if the parameters match - if (m_aDocument == rDocument && m_aLibName == rLibName && m_aName == rName && GetType() == eType) + if (m_aDocument == rDocument && m_aLibName == rLibName && m_aName == rName && GetSbxType() == eSbxType) return true; } return false; @@ -694,7 +694,7 @@ void LibInfo::InsertInfo ( ScriptDocument const& rDocument, OUString const& rLibName, OUString const& rCurrentName, - ItemType eCurrentType + SbxItemType eCurrentType ) { Key aKey(rDocument, rLibName); @@ -737,7 +737,7 @@ size_t LibInfo::Key::Hash::operator () (Key const& rKey) const LibInfo::Item::Item ( OUString aCurrentName, - ItemType eCurrentType + SbxItemType eCurrentType ) : m_aCurrentName(std::move(aCurrentName)), m_eCurrentType(eCurrentType) diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 1221b0094218..41f353533ccc 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -1336,7 +1336,7 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument, if (xDlgPersLibContainer.is()) xDlgPersLibContainer->storeLibraries(); - SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE ); + SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, SBX_TYPE_MODULE ); if (SfxDispatcher* pDispatcher = GetDispatcher()) pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED, SfxCallMode::SYNCHRON, { &aSbxItem }); diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 4b67e320b5ac..1d32d8455987 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -839,7 +839,7 @@ void ObjectPage::NewDialog() if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) ) return; - SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG ); + SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, SBX_TYPE_DIALOG ); if (SfxDispatcher* pDispatcher = GetDispatcher()) { pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED, @@ -987,7 +987,7 @@ SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument, StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : nullptr; if ( pBasic ) pModule = pBasic->FindModule( aModName ); - SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE ); + SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, SBX_TYPE_MODULE ); if (SfxDispatcher* pDispatcher = GetDispatcher()) { pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED, diff --git a/basctl/source/basicide/sbxitem.cxx b/basctl/source/basicide/sbxitem.cxx index 39c86b1d0893..b3ceccc4727d 100644 --- a/basctl/source/basicide/sbxitem.cxx +++ b/basctl/source/basicide/sbxitem.cxx @@ -29,13 +29,13 @@ SbxItem::SbxItem ( ScriptDocument aDocument, OUString aLibName, OUString aName, - ItemType eType + SbxItemType eSbxType ) : - SfxPoolItem(nWhichItem), + SfxPoolItem(nWhichItem, SfxItemType::SbxItemType), m_aDocument(std::move(aDocument)), m_aLibName(std::move(aLibName)), m_aName(std::move(aName)), - m_eType(eType) + m_eSbxType(eSbxType) { } SbxItem::SbxItem ( @@ -44,14 +44,14 @@ SbxItem::SbxItem ( OUString aLibName, OUString aName, OUString aMethodName, - ItemType eType + SbxItemType eSbxType ) : - SfxPoolItem(nWhichItem), + SfxPoolItem(nWhichItem, SfxItemType::SbxItemType), m_aDocument(std::move(aDocument)), m_aLibName(std::move(aLibName)), m_aName(std::move(aName)), m_aMethodName(std::move(aMethodName)), - m_eType(eType) + m_eSbxType(eSbxType) { } SbxItem* SbxItem::Clone(SfxItemPool*) const @@ -68,7 +68,7 @@ bool SbxItem::operator==(const SfxPoolItem& rCmp) const m_aLibName == pSbxItem->m_aLibName && m_aName == pSbxItem->m_aName && m_aMethodName == pSbxItem->m_aMethodName && - m_eType == pSbxItem->m_eType; + m_eSbxType == pSbxItem->m_eSbxType; } } // namespace basctl diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx index 14fc68f07951..23bffd38eba3 100644 --- a/basctl/source/inc/baside3.hxx +++ b/basctl/source/inc/baside3.hxx @@ -108,7 +108,7 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; virtual OUString GetHid () const override; - virtual ItemType GetType () const override; + virtual SbxItemType GetSbxType () const override; }; diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index f907abe6f214..a8b3b9061b7c 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -196,7 +196,7 @@ public: bool CallBasicErrorHdl( StarBASIC const * pBasic ); BasicDebugFlags CallBasicBreakHdl( StarBASIC const * pBasic ); - VclPtr FindWindow( const ScriptDocument& rDocument, std::u16string_view rLibName, std::u16string_view rName, ItemType nType, bool bFindSuspended = false ); + VclPtr FindWindow( const ScriptDocument& rDocument, std::u16string_view rLibName, std::u16string_view rName, SbxItemType nSbxType, bool bFindSuspended = false ); VclPtr FindDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rName, bool bCreateIfNotExist = false, bool bFindSuspended = false ); VclPtr FindBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName, bool bCreateIfNotExist = false, bool bFindSuspended = false ); VclPtr FindApplicationWindow(); diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx index 0161797f16a2..dc9526ce3256 100644 --- a/basctl/source/inc/bastype2.hxx +++ b/basctl/source/inc/bastype2.hxx @@ -221,7 +221,7 @@ public: bool FindEntry(std::u16string_view rText, EntryType eType, weld::TreeIter& rIter); EntryDescriptor GetEntryDescriptor(const weld::TreeIter* pEntry); - static ItemType ConvertType (EntryType eType); + static SbxItemType ConvertType (EntryType eType); bool IsValidEntry(const weld::TreeIter& rEntry); void AddEntry(const OUString& rText, const OUString& rImage, const weld::TreeIter* pParent, bool bChildrenOnDemand, diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index 513fbce3a41c..ecd744528056 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -238,9 +238,9 @@ public: virtual void OnNewDocument (); virtual OUString GetHid () const = 0; - virtual ItemType GetType () const = 0; + virtual SbxItemType GetSbxType () const = 0; void InsertLibInfo () const; - bool Is (ScriptDocument const&, std::u16string_view, std::u16string_view, ItemType, bool bFindSuspended); + bool Is (ScriptDocument const&, std::u16string_view, std::u16string_view, SbxItemType, bool bFindSuspended); virtual bool HasActiveEditor () const; }; @@ -252,7 +252,7 @@ public: LibInfo (); ~LibInfo (); public: - void InsertInfo (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, ItemType eCurrentType); + void InsertInfo (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, SbxItemType eCurrentType); void RemoveInfoFor (ScriptDocument const&); Item const* GetInfo (ScriptDocument const&, OUString const& rLibName); @@ -279,12 +279,12 @@ public: { private: OUString m_aCurrentName; - ItemType m_eCurrentType; + SbxItemType m_eCurrentType; public: - Item (OUString aCurrentName, ItemType eCurrentType); + Item (OUString aCurrentName, SbxItemType eCurrentType); const OUString& GetCurrentName() const { return m_aCurrentName; } - ItemType GetCurrentType() const { return m_eCurrentType; } + SbxItemType GetCurrentType() const { return m_eCurrentType; } }; private: typedef std::unordered_map Map; diff --git a/basctl/source/inc/sbxitem.hxx b/basctl/source/inc/sbxitem.hxx index 941ffd3e0ee9..a21e792742ca 100644 --- a/basctl/source/inc/sbxitem.hxx +++ b/basctl/source/inc/sbxitem.hxx @@ -24,14 +24,14 @@ namespace basctl { -enum ItemType +enum SbxItemType { - TYPE_UNKNOWN, - TYPE_SHELL, - TYPE_LIBRARY, - TYPE_MODULE, - TYPE_DIALOG, - TYPE_METHOD + SBX_TYPE_UNKNOWN, + SBX_TYPE_SHELL, + SBX_TYPE_LIBRARY, + SBX_TYPE_MODULE, + SBX_TYPE_DIALOG, + SBX_TYPE_METHOD }; class SbxItem : public SfxPoolItem @@ -40,12 +40,12 @@ class SbxItem : public SfxPoolItem const OUString m_aLibName; const OUString m_aName; const OUString m_aMethodName; - ItemType m_eType; + SbxItemType m_eSbxType; public: static SfxPoolItem* CreateDefault(); - SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, ItemType); - SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, OUString aMethodName, ItemType eType); + SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, SbxItemType); + SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, OUString aMethodName, SbxItemType eSbxType); virtual SbxItem* Clone(SfxItemPool *pPool = nullptr) const override; virtual bool operator==(const SfxPoolItem&) const override; @@ -54,7 +54,7 @@ public: OUString const& GetLibName () const { return m_aLibName; } OUString const& GetName () const { return m_aName; } OUString const& GetMethodName () const { return m_aMethodName; } - ItemType GetType () const { return m_eType; } + SbxItemType GetSbxType () const { return m_eSbxType; } }; } // namespace basctl -- cgit