diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-06-03 14:04:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-06-03 14:20:32 +0100 |
commit | fce299fc64fcfe5280966631613edda7e6031c16 (patch) | |
tree | 51fe9c57d5d1266de2e65697250d918febd55b29 | |
parent | a22af0b1702d625f12711e9997daebbddb02b6e0 (diff) |
Resolves: tdf#96008 crash when an extension with legacy decks is installed
ReadLegacyAddons modifies its vectors of maDecks and maPanels in this case, but
a load of things have (c++) references contents of the original contents.
Its such a rats nest that the easiest thing seems to be to make them
vectors of shared_ptrs and hold DeckDescriptor and PanelDescriptor
by shared_ptr and it all works out
Change-Id: I3f628e12c7d5f4224d14d5e0769e450ce893fb54
-rw-r--r-- | include/sfx2/sidebar/ResourceManager.hxx | 15 | ||||
-rw-r--r-- | include/sfx2/sidebar/TabBar.hxx | 14 | ||||
-rw-r--r-- | sfx2/source/sidebar/ResourceManager.cxx | 144 | ||||
-rw-r--r-- | sfx2/source/sidebar/Sidebar.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 57 | ||||
-rw-r--r-- | sfx2/source/sidebar/TabBar.cxx | 42 | ||||
-rw-r--r-- | sfx2/source/sidebar/UnoDeck.cxx | 41 | ||||
-rw-r--r-- | sfx2/source/sidebar/UnoPanel.cxx | 36 |
8 files changed, 174 insertions, 193 deletions
diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx index 3cf0df998333..c5456525f34d 100644 --- a/include/sfx2/sidebar/ResourceManager.hxx +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -43,11 +43,8 @@ public: ResourceManager(); ~ResourceManager(); - const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const; - DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId); - - const PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId) const; - PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId); + std::shared_ptr<DeckDescriptor> GetDeckDescriptor(const OUString& rsDeckId) const; + std::shared_ptr<PanelDescriptor> GetPanelDescriptor(const OUString& rsPanelId) const; void UpdateModel(const css::uno::Reference<css::frame::XModel>& xModel); @@ -96,10 +93,10 @@ public: private: - typedef std::vector<DeckDescriptor> DeckContainer; + typedef std::vector<std::shared_ptr<DeckDescriptor>> DeckContainer; DeckContainer maDecks; - typedef std::vector<PanelDescriptor> PanelContainer; + typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer; PanelContainer maPanels; mutable std::set<rtl::OUString> maProcessedApplications; @@ -119,8 +116,8 @@ private: const Context& rContext, const css::uno::Reference<css::frame::XController>& rxController); - const DeckDescriptor* ImplGetDeckDescriptor(const OUString& rsDeckId) const; - const PanelDescriptor* ImplGetPanelDescriptor(const OUString& rsPanelId) const; + std::shared_ptr<DeckDescriptor> ImplGetDeckDescriptor(const OUString& rsDeckId) const; + std::shared_ptr<PanelDescriptor> ImplGetPanelDescriptor(const OUString& rsPanelId) const; }; } } // end of namespace sfx2::sidebar diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx index 01158960f49a..5a8c0cdeca39 100644 --- a/include/sfx2/sidebar/TabBar.hxx +++ b/include/sfx2/sidebar/TabBar.hxx @@ -55,8 +55,8 @@ public: class DeckMenuData { public: - ::rtl::OUString msDisplayName; - ::rtl::OUString msDeckId; + OUString msDisplayName; + OUString msDeckId; bool mbIsCurrentDeck; bool mbIsActive; bool mbIsEnabled; @@ -67,7 +67,7 @@ public: TabBar ( vcl::Window* pParentWindow, const css::uno::Reference<css::frame::XFrame>& rxFrame, - const ::std::function<void (const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor, + const ::std::function<void (const OUString& rsDeckId)>& rDeckActivationFunctor, const PopupMenuProvider& rPopupMenuProvider, SidebarController* rParentSidebarController); @@ -82,9 +82,9 @@ public: void SetDecks ( const ResourceManager::DeckContextDescriptorContainer& rDecks); - void HighlightDeck (const ::rtl::OUString& rsDeckId); + void HighlightDeck (const OUString& rsDeckId); void RemoveDeckHighlight (); - const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const; + const OUString GetDeckIdForIndex (const sal_Int32 nIndex) const; void ToggleHideFlag (const sal_Int32 nIndex); void RestoreHideFlags(); @@ -99,13 +99,13 @@ private: DECL_LINK_TYPED(HandleClick, Button*, void); VclPtr<RadioButton> mpButton; OUString msDeckId; - ::std::function<void (const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; + ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; bool mbIsHidden; bool mbIsHiddenByDefault; }; typedef ::std::vector<Item> ItemContainer; ItemContainer maItems; - const ::std::function<void (const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; + const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; sal_Int32 mnMenuSeparatorY; PopupMenuProvider maPopupMenuProvider; diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index 6951f7ce5a7c..8958f3b4d5cd 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -109,61 +109,57 @@ void ResourceManager::InitDeckContext(const Context& rContext) DeckContainer::iterator iDeck; for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck) { - bool bIsEnabled; - const ContextList::Entry* pMatchingEntry = iDeck->maContextList.GetMatch(rContext); + std::shared_ptr<DeckDescriptor>& rDeck = *iDeck; + + const ContextList::Entry* pMatchingEntry = rDeck->maContextList.GetMatch(rContext); + bool bIsEnabled; if (pMatchingEntry) bIsEnabled = pMatchingEntry->mbIsInitiallyVisible; else bIsEnabled = false; - iDeck->mbIsEnabled = bIsEnabled; + rDeck->mbIsEnabled = bIsEnabled; } } -const DeckDescriptor* ResourceManager::ImplGetDeckDescriptor(const OUString& rsDeckId) const +std::shared_ptr<DeckDescriptor> ResourceManager::ImplGetDeckDescriptor(const OUString& rsDeckId) const { DeckContainer::const_iterator iDeck; for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck) { - if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode()) + const std::shared_ptr<DeckDescriptor>& rDeck = *iDeck; + + if (rDeck->mbExperimental && !maMiscOptions.IsExperimentalMode()) continue; - if (iDeck->msId.equals(rsDeckId)) - return &*iDeck; + if (rDeck->msId.equals(rsDeckId)) + return rDeck; } return nullptr; } -const DeckDescriptor* ResourceManager::GetDeckDescriptor(const OUString& rsDeckId) const -{ - return ImplGetDeckDescriptor( rsDeckId ); -} -DeckDescriptor* ResourceManager::GetDeckDescriptor(const OUString& rsDeckId) +std::shared_ptr<DeckDescriptor> ResourceManager::GetDeckDescriptor(const OUString& rsDeckId) const { - const ResourceManager* constMe = this; - return const_cast<DeckDescriptor*>( constMe->ImplGetDeckDescriptor(rsDeckId) ); + return ImplGetDeckDescriptor( rsDeckId ); } -const PanelDescriptor* ResourceManager::ImplGetPanelDescriptor(const OUString& rsPanelId) const +std::shared_ptr<PanelDescriptor> ResourceManager::ImplGetPanelDescriptor(const OUString& rsPanelId) const { PanelContainer::const_iterator iPanel; for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel) { - if (iPanel->msId.equals(rsPanelId)) - return &*iPanel; + const std::shared_ptr<PanelDescriptor>& rPanel = *iPanel; + + if (rPanel->msId.equals(rsPanelId)) + return rPanel; } return nullptr; } -const PanelDescriptor* ResourceManager::GetPanelDescriptor(const OUString& rsPanelId) const -{ - return ImplGetPanelDescriptor( rsPanelId ); -} -PanelDescriptor* ResourceManager::GetPanelDescriptor(const OUString& rsPanelId) +std::shared_ptr<PanelDescriptor> ResourceManager::GetPanelDescriptor(const OUString& rsPanelId) const { - const ResourceManager* constMe = this; - return const_cast<PanelDescriptor*>( constMe->ImplGetPanelDescriptor(rsPanelId) ); + return ImplGetPanelDescriptor( rsPanelId ); } const ResourceManager::DeckContextDescriptorContainer& ResourceManager::GetMatchingDecks ( @@ -178,10 +174,12 @@ const ResourceManager::DeckContextDescriptorContainer& ResourceManager::GetMatch DeckContainer::const_iterator iDeck; for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck) { - if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode()) + const std::shared_ptr<DeckDescriptor>& rDeck = *iDeck; + + if (rDeck->mbExperimental && !maMiscOptions.IsExperimentalMode()) continue; - const DeckDescriptor& rDeckDescriptor (*iDeck); + const DeckDescriptor& rDeckDescriptor (*rDeck); if (rDeckDescriptor.maContextList.GetMatch(rContext) == nullptr) continue; @@ -212,16 +210,18 @@ const ResourceManager::PanelContextDescriptorContainer& ResourceManager::GetMatc const OUString& rsDeckId, const Reference<frame::XController>& rxController) { + OUString sDeckId(rsDeckId); ReadLegacyAddons(rxController); std::multimap<sal_Int32, PanelContextDescriptor> aOrderedIds; PanelContainer::const_iterator iPanel; for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel) { - const PanelDescriptor& rPanelDescriptor (*iPanel); + const std::shared_ptr<PanelDescriptor>& rPanel = *iPanel; + const PanelDescriptor& rPanelDescriptor (*rPanel); if (rPanelDescriptor.mbExperimental && !maMiscOptions.IsExperimentalMode()) continue; - if ( ! rPanelDescriptor.msDeckId.equals(rsDeckId)) + if ( ! rPanelDescriptor.msDeckId.equals(sDeckId)) continue; const ContextList::Entry* pEntry = rPanelDescriptor.maContextList.GetMatch(rContext); @@ -258,15 +258,15 @@ void ResourceManager::ReadDeckList() const Sequence<OUString> aDeckNodeNames (aDeckRootNode.getNodeNames()); const sal_Int32 nCount(aDeckNodeNames.getLength()); - maDecks.resize(nCount); - sal_Int32 nWriteIndex(0); + maDecks.clear(); for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) { const utl::OConfigurationNode aDeckNode(aDeckRootNode.openNode(aDeckNodeNames[nReadIndex])); if (!aDeckNode.isValid()) continue; - DeckDescriptor& rDeckDescriptor (maDecks[nWriteIndex++]); + maDecks.push_back(std::make_shared<DeckDescriptor>()); + DeckDescriptor& rDeckDescriptor (*maDecks.back()); rDeckDescriptor.msTitle = getString(aDeckNode, "Title"); rDeckDescriptor.msId = getString(aDeckNode, "Id"); @@ -276,7 +276,6 @@ void ResourceManager::ReadDeckList() rDeckDescriptor.msHighContrastTitleBarIconURL = getString(aDeckNode, "HighContrastTitleBarIconURL"); rDeckDescriptor.msHelpURL = getString(aDeckNode, "HelpURL"); rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle; - // rDeckDescriptor.mbIsEnabled = true; // TODO ??? update rDeckDescriptor.mbIsEnabled according to context , see IsDeckEnabled ? rDeckDescriptor.mnOrderIndex = getInt32(aDeckNode, "OrderIndex"); rDeckDescriptor.mbExperimental = getBool(aDeckNode, "IsExperimental"); @@ -288,25 +287,21 @@ void ResourceManager::ReadDeckList() OUString()); } - - // When there where invalid nodes then we have to adapt the size - // of the deck vector. - if (nWriteIndex<nCount) - maDecks.resize(nWriteIndex); } void ResourceManager::SaveDecksSettings(const Context& rContext) { - DeckContainer::const_iterator iDeck; for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck) { - const ContextList::Entry* pMatchingEntry = iDeck->maContextList.GetMatch(rContext); + const std::shared_ptr<DeckDescriptor>& rDeck = *iDeck; + + const ContextList::Entry* pMatchingEntry = rDeck->maContextList.GetMatch(rContext); if (pMatchingEntry) { - const DeckDescriptor* pDeckDesc = GetDeckDescriptor(iDeck->msId); - if (pDeckDesc) - SaveDeckSettings(pDeckDesc); + std::shared_ptr<DeckDescriptor> xDeckDesc = GetDeckDescriptor(rDeck->msId); + if (xDeckDesc) + SaveDeckSettings(xDeckDesc.get()); } } @@ -350,20 +345,20 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc) for ( SharedPanelContainer::iterator iPanel(rPanels.begin()), iEnd(rPanels.end()); iPanel!=iEnd; ++iPanel) - { - Panel* aPanel = *iPanel; - OUString panelId = aPanel->GetId(); - const PanelDescriptor* pPanelDesc = GetPanelDescriptor(panelId); + { + Panel* aPanel = *iPanel; + OUString panelId = aPanel->GetId(); + std::shared_ptr<PanelDescriptor> xPanelDesc = GetPanelDescriptor(panelId); - ::uno::Sequence< OUString > sPanelContextList = BuildContextList(pPanelDesc->maContextList); + ::uno::Sequence< OUString > sPanelContextList = BuildContextList(xPanelDesc->maContextList); - utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(pPanelDesc->msNodeName)); + utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(xPanelDesc->msNodeName)); - aPanelNode.setNodeValue("Title", makeAny(pPanelDesc->msTitle)); - aPanelNode.setNodeValue("OrderIndex", makeAny(pPanelDesc->mnOrderIndex)); - aPanelNode.setNodeValue("ContextList", makeAny( sPanelContextList )); + aPanelNode.setNodeValue("Title", makeAny(xPanelDesc->msTitle)); + aPanelNode.setNodeValue("OrderIndex", makeAny(xPanelDesc->mnOrderIndex)); + aPanelNode.setNodeValue("ContextList", makeAny( sPanelContextList )); - } + } aPanelRootNode.commit(); @@ -380,15 +375,15 @@ void ResourceManager::ReadPanelList() const Sequence<OUString> aPanelNodeNames (aPanelRootNode.getNodeNames()); const sal_Int32 nCount (aPanelNodeNames.getLength()); - maPanels.resize(nCount); - sal_Int32 nWriteIndex (0); + maPanels.clear(); for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) { const utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(aPanelNodeNames[nReadIndex])); if (!aPanelNode.isValid()) continue; - PanelDescriptor& rPanelDescriptor (maPanels[nWriteIndex++]); + maPanels.push_back(std::make_shared<PanelDescriptor>()); + PanelDescriptor& rPanelDescriptor(*maPanels.back()); rPanelDescriptor.msTitle = getString(aPanelNode, "Title"); rPanelDescriptor.mbIsTitleBarOptional = getBool(aPanelNode, "TitleBarIsOptional"); @@ -408,11 +403,6 @@ void ResourceManager::ReadPanelList() ReadContextList(aPanelNode, rPanelDescriptor.maContextList, sDefaultMenuCommand); } - - // When there where invalid nodes then we have to adapt the size - // of the deck vector. - if (nWriteIndex<nCount) - maPanels.resize(nWriteIndex); } void ResourceManager::ReadContextList ( @@ -591,10 +581,6 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XController>& rxC std::vector<OUString> aMatchingNodeNames; GetToolPanelNodeNames(aMatchingNodeNames, aLegacyRootNode); const sal_Int32 nCount (aMatchingNodeNames.size()); - size_t nDeckWriteIndex (maDecks.size()); - size_t nPanelWriteIndex (maPanels.size()); - maDecks.resize(maDecks.size() + nCount); - maPanels.resize(maPanels.size() + nCount); for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) { const OUString& rsNodeName (aMatchingNodeNames[nReadIndex]); @@ -609,7 +595,8 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XController>& rxC rsNodeName == "private:resource/toolpanel/DrawingFramework/TableDesign" ) continue; - DeckDescriptor& rDeckDescriptor (maDecks[nDeckWriteIndex++]); + maDecks.push_back(std::make_shared<DeckDescriptor>()); + DeckDescriptor& rDeckDescriptor(*maDecks.back()); rDeckDescriptor.msTitle = getString(aChildNode, "UIName"); rDeckDescriptor.msId = rsNodeName; rDeckDescriptor.msIconURL = getString(aChildNode, "ImageURL"); @@ -622,7 +609,8 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XController>& rxC rDeckDescriptor.mnOrderIndex = 100000 + nReadIndex; rDeckDescriptor.maContextList.AddContextDescription(Context(sModuleName, OUString("any")), true, OUString()); - PanelDescriptor& rPanelDescriptor (maPanels[nPanelWriteIndex++]); + maPanels.push_back(std::make_shared<PanelDescriptor>()); + PanelDescriptor& rPanelDescriptor(*maPanels.back()); rPanelDescriptor.msTitle = getString(aChildNode, "UIName"); rPanelDescriptor.mbIsTitleBarOptional = true; rPanelDescriptor.msId = rsNodeName; @@ -636,13 +624,6 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XController>& rxC rPanelDescriptor.mbWantsCanvas = false; rPanelDescriptor.maContextList.AddContextDescription(Context(sModuleName, OUString("any")), true, OUString()); } - - // When there where invalid nodes then we have to adapt the size - // of the deck and panel vectors. - if (nDeckWriteIndex < maDecks.size()) - maDecks.resize(nDeckWriteIndex); - if (nPanelWriteIndex < maPanels.size()) - maPanels.resize(nPanelWriteIndex); } void ResourceManager::StorePanelExpansionState ( @@ -653,9 +634,11 @@ void ResourceManager::StorePanelExpansionState ( PanelContainer::iterator iPanel; for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel) { - if (iPanel->msId.equals(rsPanelId)) + const std::shared_ptr<PanelDescriptor>& rPanel = *iPanel; + + if (rPanel->msId.equals(rsPanelId)) { - ContextList::Entry* pEntry(iPanel->maContextList.GetMatch(rContext)); + ContextList::Entry* pEntry(rPanel->maContextList.GetMatch(rContext)); if (pEntry != nullptr) pEntry->mbIsInitiallyVisible = bExpansionState; } @@ -726,10 +709,12 @@ void ResourceManager::UpdateModel(const css::uno::Reference<css::frame::XModel>& { for (DeckContainer::iterator itr = maDecks.begin(); itr != maDecks.end(); ++itr) { - if (!itr->mpDeck) + std::shared_ptr<DeckDescriptor>& rDeck = *itr; + + if (!rDeck->mpDeck) continue; - const SharedPanelContainer& rContainer = itr->mpDeck->GetPanels(); + const SharedPanelContainer& rContainer = rDeck->mpDeck->GetPanels(); for (SharedPanelContainer::const_iterator it = rContainer.begin(); it != rContainer.end(); ++it) { @@ -742,7 +727,10 @@ void ResourceManager::UpdateModel(const css::uno::Reference<css::frame::XModel>& void ResourceManager::disposeDecks() { for (DeckContainer::iterator itr = maDecks.begin(); itr != maDecks.end(); ++itr) - itr->mpDeck.disposeAndClear(); + { + std::shared_ptr<DeckDescriptor>& rDeck = *itr; + rDeck->mpDeck.disposeAndClear(); + } } } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx index eaa8a510c00f..dda31e4bbaec 100644 --- a/sfx2/source/sidebar/Sidebar.cxx +++ b/sfx2/source/sidebar/Sidebar.cxx @@ -33,9 +33,9 @@ void Sidebar::ShowPanel ( if (!pController) return; - const PanelDescriptor* pPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId); + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId); - if (!pPanelDescriptor) + if (!xPanelDescriptor) return; // This should be a lot more sophisticated: @@ -44,7 +44,7 @@ void Sidebar::ShowPanel ( // All that is not necessary for the current use cases so lets // keep it simple for the time being. - pController->OpenThenSwitchToDeck(pPanelDescriptor->msDeckId); + pController->OpenThenSwitchToDeck(xPanelDescriptor->msDeckId); } void Sidebar::TogglePanel ( @@ -55,9 +55,9 @@ void Sidebar::TogglePanel ( if (!pController) return; - const PanelDescriptor* pPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId); + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId); - if (!pPanelDescriptor) + if (!xPanelDescriptor) return; // This should be a lot more sophisticated: @@ -66,7 +66,7 @@ void Sidebar::TogglePanel ( // All that is not necessary for the current use cases so lets // keep it simple for the time being. - pController->OpenThenToggleDeck(pPanelDescriptor->msDeckId); + pController->OpenThenToggleDeck(xPanelDescriptor->msDeckId); } bool Sidebar::IsPanelVisible( @@ -77,11 +77,11 @@ bool Sidebar::IsPanelVisible( if (!pController) return false; - const PanelDescriptor* pPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId); - if (!pPanelDescriptor) + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId); + if (!xPanelDescriptor) return false; - return pController->IsDeckVisible(pPanelDescriptor->msDeckId); + return pController->IsDeckVisible(xPanelDescriptor->msDeckId); } } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 002bcc49e672..1dc3ffbb8013 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -220,7 +220,7 @@ void SAL_CALL SidebarController::disposing() iDeck(aDecks.begin()), iEnd(aDecks.end()); iDeck!=iEnd; ++iDeck) { - const DeckDescriptor* deckDesc = mpResourceManager->GetDeckDescriptor(iDeck->msId); + std::shared_ptr<DeckDescriptor> deckDesc = mpResourceManager->GetDeckDescriptor(iDeck->msId); VclPtr<Deck> aDeck = deckDesc->mpDeck; if (aDeck) @@ -492,13 +492,11 @@ void SidebarController::UpdateConfigurations() // with the deck. mpTabBar->HighlightDeck(sNewDeckId); - const DeckDescriptor* pDescriptor = mpResourceManager->GetDeckDescriptor(sNewDeckId); + std::shared_ptr<DeckDescriptor> xDescriptor = mpResourceManager->GetDeckDescriptor(sNewDeckId); - if (pDescriptor) + if (xDescriptor) { - SwitchToDeck( - *pDescriptor, - maCurrentContext); + SwitchToDeck(*xDescriptor, maCurrentContext); } } } @@ -551,10 +549,10 @@ void SidebarController::SwitchToDeck ( || ! mbIsDeckOpen || mnRequestedForceFlags!=SwitchFlag_NoForce) { - const DeckDescriptor* pDeckDescriptor = mpResourceManager->GetDeckDescriptor(rsDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = mpResourceManager->GetDeckDescriptor(rsDeckId); - if (pDeckDescriptor != nullptr) - SwitchToDeck(*pDeckDescriptor, maCurrentContext); + if (xDeckDescriptor) + SwitchToDeck(*xDeckDescriptor, maCurrentContext); } } @@ -564,34 +562,33 @@ void SidebarController::CreateDeck(const ::rtl::OUString& rDeckId) { void SidebarController::CreateDeck(const ::rtl::OUString& rDeckId, const Context& rContext, bool bForceCreate) { - DeckDescriptor* pDeckDescriptor = mpResourceManager->GetDeckDescriptor(rDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = mpResourceManager->GetDeckDescriptor(rDeckId); - if (pDeckDescriptor) + if (xDeckDescriptor) { - VclPtr<Deck> aDeck = pDeckDescriptor->mpDeck; + VclPtr<Deck> aDeck = xDeckDescriptor->mpDeck; if (aDeck.get()==nullptr || bForceCreate) { if (aDeck.get()!=nullptr) aDeck.disposeAndClear(); aDeck = VclPtr<Deck>::Create( - *pDeckDescriptor, + *xDeckDescriptor, mpParentWindow, [this]() { return this->RequestCloseDeck(); }); } - pDeckDescriptor->mpDeck = aDeck; + xDeckDescriptor->mpDeck = aDeck; CreatePanels(rDeckId, rContext); } } void SidebarController::CreatePanels(const ::rtl::OUString& rDeckId, const Context& rContext) { - - DeckDescriptor* pDeckDescriptor = mpResourceManager->GetDeckDescriptor(rDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = mpResourceManager->GetDeckDescriptor(rDeckId); // init panels bounded to that deck, do not wait them being displayed as may be accessed through API - VclPtr<Deck> pDeck = pDeckDescriptor->mpDeck; + VclPtr<Deck> pDeck = xDeckDescriptor->mpDeck; ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors; @@ -781,14 +778,14 @@ VclPtr<Panel> SidebarController::CreatePanel ( const Context& rContext, const VclPtr<Deck>& pDeck) { - const PanelDescriptor* pPanelDescriptor = mpResourceManager->GetPanelDescriptor(rsPanelId); + std::shared_ptr<PanelDescriptor> xPanelDescriptor = mpResourceManager->GetPanelDescriptor(rsPanelId); - if (pPanelDescriptor == nullptr) + if (!xPanelDescriptor) return nullptr; // Create the panel which is the parent window of the UIElement. VclPtr<Panel> pPanel = VclPtr<Panel>::Create( - *pPanelDescriptor, + *xPanelDescriptor, pParentWindow, bIsInitiallyExpanded, [pDeck]() { return pDeck.get()->RequestLayout(); }, @@ -798,8 +795,8 @@ VclPtr<Panel> SidebarController::CreatePanel ( // Create the XUIElement. Reference<ui::XUIElement> xUIElement (CreateUIElement( pPanel->GetComponentInterface(), - pPanelDescriptor->msImplementationURL, - pPanelDescriptor->mbWantsCanvas, + xPanelDescriptor->msImplementationURL, + xPanelDescriptor->mbWantsCanvas, rContext)); if (xUIElement.is()) { @@ -1246,13 +1243,13 @@ void SidebarController::UpdateTitleBarIcons() const ResourceManager& rResourceManager = *mpResourceManager; // Update the deck icon. - const DeckDescriptor* pDeckDescriptor = rResourceManager.GetDeckDescriptor(mpCurrentDeck->GetId()); - if (pDeckDescriptor != nullptr && mpCurrentDeck->GetTitleBar()) + std::shared_ptr<DeckDescriptor> xDeckDescriptor = rResourceManager.GetDeckDescriptor(mpCurrentDeck->GetId()); + if (xDeckDescriptor && mpCurrentDeck->GetTitleBar()) { const OUString sIconURL( bIsHighContrastModeActive - ? pDeckDescriptor->msHighContrastTitleBarIconURL - : pDeckDescriptor->msTitleBarIconURL); + ? xDeckDescriptor->msHighContrastTitleBarIconURL + : xDeckDescriptor->msTitleBarIconURL); mpCurrentDeck->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame)); } @@ -1267,13 +1264,13 @@ void SidebarController::UpdateTitleBarIcons() continue; if ((*iPanel)->GetTitleBar() == nullptr) continue; - const PanelDescriptor* pPanelDescriptor = rResourceManager.GetPanelDescriptor((*iPanel)->GetId()); - if (pPanelDescriptor == nullptr) + std::shared_ptr<PanelDescriptor> xPanelDescriptor = rResourceManager.GetPanelDescriptor((*iPanel)->GetId()); + if (!xPanelDescriptor) continue; const OUString sIconURL ( bIsHighContrastModeActive - ? pPanelDescriptor->msHighContrastTitleBarIconURL - : pPanelDescriptor->msTitleBarIconURL); + ? xPanelDescriptor->msHighContrastTitleBarIconURL + : xPanelDescriptor->msTitleBarIconURL); (*iPanel)->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame)); } } diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index ef6e18557b29..c16f9d190a14 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -119,20 +119,20 @@ void TabBar::SetDecks(const ResourceManager::DeckContextDescriptorContainer& rDe for (ResourceManager::DeckContextDescriptorContainer::const_iterator iDeck(rDecks.begin()); iDeck != rDecks.end(); ++iDeck) { - const DeckDescriptor* pDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId); - if (pDescriptor == nullptr) + std::shared_ptr<DeckDescriptor> xDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId); + if (xDescriptor == nullptr) { - OSL_ASSERT(pDescriptor!=nullptr); + OSL_ASSERT(xDescriptor!=nullptr); continue; } Item& rItem (maItems[nIndex++]); - rItem.msDeckId = pDescriptor->msId; + rItem.msDeckId = xDescriptor->msId; rItem.mpButton.disposeAndClear(); - rItem.mpButton = CreateTabItem(*pDescriptor); + rItem.mpButton = CreateTabItem(*xDescriptor); rItem.mpButton->SetClickHdl(LINK(&rItem, TabBar::Item, HandleClick)); rItem.maDeckActivationFunctor = maDeckActivationFunctor; - rItem.mbIsHidden = ! pDescriptor->mbIsEnabled; + rItem.mbIsHidden = ! xDescriptor->mbIsEnabled; rItem.mbIsHiddenByDefault = rItem.mbIsHidden; // the default is the state while creating rItem.mpButton->Enable(iDeck->mbIsEnabled); @@ -158,11 +158,11 @@ void TabBar::UpdateButtonIcons() iItem!=iEnd; ++iItem) { - const DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId); - if (pDeckDescriptor != nullptr) + if (xDeckDescriptor) { - aImage = GetItemImage(*pDeckDescriptor); + aImage = GetItemImage(*xDeckDescriptor); if ( mpMenuButton->GetDPIScaleFactor() > 1 ) { BitmapEx b = aImage.GetBitmapEx(); @@ -335,18 +335,18 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex) { maItems[nIndex].mbIsHidden = ! maItems[nIndex].mbIsHidden; - DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(maItems[nIndex].msDeckId); - if (pDeckDescriptor) + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(maItems[nIndex].msDeckId); + if (xDeckDescriptor) { - pDeckDescriptor->mbIsEnabled = ! maItems[nIndex].mbIsHidden; + xDeckDescriptor->mbIsEnabled = ! maItems[nIndex].mbIsHidden; Context aContext; aContext.msApplication = pParentSidebarController->GetCurrentContext().msApplication; // leave aContext.msContext on default 'any' ... this func is used only for decks // and we don't have context-sensitive decks anyway - pDeckDescriptor->maContextList.ToggleVisibilityForContext( - aContext, pDeckDescriptor->mbIsEnabled ); + xDeckDescriptor->maContextList.ToggleVisibilityForContext( + aContext, xDeckDescriptor->mbIsEnabled ); } Layout(); @@ -363,9 +363,9 @@ void TabBar::RestoreHideFlags() iItem->mbIsHidden = iItem->mbIsHiddenByDefault; bNeedsLayout = true; - DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId); - if (pDeckDescriptor) - pDeckDescriptor->mbIsEnabled = ! iItem->mbIsHidden; + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId); + if (xDeckDescriptor) + xDeckDescriptor->mbIsEnabled = ! iItem->mbIsHidden; } } @@ -395,13 +395,13 @@ IMPL_LINK_NOARG_TYPED(TabBar, OnToolboxClicked, Button*, void) for (ItemContainer::const_iterator iItem(maItems.begin()); iItem != maItems.end(); ++iItem) { - const DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId); - if (pDeckDescriptor != nullptr) + if (xDeckDescriptor) { DeckMenuData aData; - aData.msDisplayName = pDeckDescriptor->msTitle; - aData.msDeckId = pDeckDescriptor->msId; + aData.msDisplayName = xDeckDescriptor->msTitle; + aData.msDeckId = xDeckDescriptor->msId; aData.mbIsCurrentDeck = iItem->mpButton->IsChecked(); aData.mbIsActive = !iItem->mbIsHidden; aData.mbIsEnabled = iItem->mpButton->IsEnabled(); diff --git a/sfx2/source/sidebar/UnoDeck.cxx b/sfx2/source/sidebar/UnoDeck.cxx index 9305d449ed77..4fc0e158f07f 100644 --- a/sfx2/source/sidebar/UnoDeck.cxx +++ b/sfx2/source/sidebar/UnoDeck.cxx @@ -67,16 +67,16 @@ void SAL_CALL SfxUnoDeck::setTitle( const OUString& newTitle ) SidebarController* pSidebarController = getSidebarController(); pSidebarController->CreateDeck(mDeckId); - DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); - if (pDeckDescriptor) + if (xDeckDescriptor) { - Deck* pDeck = pDeckDescriptor->mpDeck; + Deck* pDeck = xDeckDescriptor->mpDeck; DeckTitleBar* pTitleBar = pDeck->GetTitleBar(); pTitleBar->SetTitle(newTitle); - pDeckDescriptor->msTitle = newTitle; - pDeckDescriptor->msHelpText = newTitle; + xDeckDescriptor->msTitle = newTitle; + xDeckDescriptor->msHelpText = newTitle; pSidebarController->notifyDeckTitle(mDeckId); } @@ -133,11 +133,11 @@ void SAL_CALL SfxUnoDeck::setOrderIndex( const sal_Int32 newOrderIndex ) SolarMutexGuard aGuard; SidebarController* pSidebarController = getSidebarController(); - DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); - if (pDeckDescriptor) + if (xDeckDescriptor) { - pDeckDescriptor->mnOrderIndex = newOrderIndex; + xDeckDescriptor->mnOrderIndex = newOrderIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -157,10 +157,10 @@ void SAL_CALL SfxUnoDeck::moveFirst() if (curOrderIndex != minIndex) // is deck already in place ? { minIndex -= 1; - DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); - if (pDeckDescriptor) + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); + if (xDeckDescriptor) { - pDeckDescriptor->mnOrderIndex = minIndex; + xDeckDescriptor->mnOrderIndex = minIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -181,10 +181,10 @@ void SAL_CALL SfxUnoDeck::moveLast() if (curOrderIndex != maxIndex) // is deck already in place ? { maxIndex += 1; - DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); - if (pDeckDescriptor) + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); + if (xDeckDescriptor) { - pDeckDescriptor->mnOrderIndex = maxIndex; + xDeckDescriptor->mnOrderIndex = maxIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -214,10 +214,10 @@ void SAL_CALL SfxUnoDeck::moveUp() if (curOrderIndex != previousIndex) // is deck already in place ? { previousIndex -= 1; - DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); - if (pDeckDescriptor) + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); + if (xDeckDescriptor) { - pDeckDescriptor->mnOrderIndex = previousIndex; + xDeckDescriptor->mnOrderIndex = previousIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -248,17 +248,16 @@ void SAL_CALL SfxUnoDeck::moveDown() if (curOrderIndex != nextIndex) // is deck already in place ? { nextIndex += 1; - DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); - if (pDeckDescriptor) + std::shared_ptr<DeckDescriptor> xDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId); + if (xDeckDescriptor) { - pDeckDescriptor->mnOrderIndex = nextIndex; + xDeckDescriptor->mnOrderIndex = nextIndex; // update the sidebar pSidebarController->NotifyResize(); } } } - sal_Int32 SfxUnoDeck::GetMinOrderIndex(ResourceManager::DeckContextDescriptorContainer aDecks) { SidebarController* pSidebarController = getSidebarController(); diff --git a/sfx2/source/sidebar/UnoPanel.cxx b/sfx2/source/sidebar/UnoPanel.cxx index 3fd124b459d5..917a23692919 100644 --- a/sfx2/source/sidebar/UnoPanel.cxx +++ b/sfx2/source/sidebar/UnoPanel.cxx @@ -64,11 +64,11 @@ void SAL_CALL SfxUnoPanel::setTitle( const OUString& newTitle ) SolarMutexGuard aGuard; SidebarController* pSidebarController = getSidebarController(); - PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); - if (pPanelDescriptor) + if (xPanelDescriptor) { - pPanelDescriptor->msTitle = newTitle; + xPanelDescriptor->msTitle = newTitle; PanelTitleBar* pTitleBar = mpPanel->GetTitleBar(); if (pTitleBar) pTitleBar->SetTitle(newTitle); @@ -145,11 +145,11 @@ void SAL_CALL SfxUnoPanel::setOrderIndex( const sal_Int32 newOrderIndex ) SolarMutexGuard aGuard; SidebarController* pSidebarController = getSidebarController(); - PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); - if (pPanelDescriptor) + if (xPanelDescriptor) { - pPanelDescriptor->mnOrderIndex = newOrderIndex; + xPanelDescriptor->mnOrderIndex = newOrderIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -169,10 +169,10 @@ void SAL_CALL SfxUnoPanel::moveFirst() if (curOrderIndex != minIndex) // is current panel already in place ? { minIndex -= 1; - PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); - if (pPanelDescriptor) + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); + if (xPanelDescriptor) { - pPanelDescriptor->mnOrderIndex = minIndex; + xPanelDescriptor->mnOrderIndex = minIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -193,10 +193,10 @@ void SAL_CALL SfxUnoPanel::moveLast() if (curOrderIndex != maxIndex) // is current panel already in place ? { maxIndex += 1; - PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); - if (pPanelDescriptor) + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); + if (xPanelDescriptor) { - pPanelDescriptor->mnOrderIndex = maxIndex; + xPanelDescriptor->mnOrderIndex = maxIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -226,10 +226,10 @@ void SAL_CALL SfxUnoPanel::moveUp() if (curOrderIndex != previousIndex) // is current panel already in place ? { previousIndex -= 1; - PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); - if (pPanelDescriptor) + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); + if (xPanelDescriptor) { - pPanelDescriptor->mnOrderIndex = previousIndex; + xPanelDescriptor->mnOrderIndex = previousIndex; // update the sidebar pSidebarController->NotifyResize(); } @@ -259,10 +259,10 @@ void SAL_CALL SfxUnoPanel::moveDown() if (curOrderIndex != nextIndex) // is current panel already in place ? { nextIndex += 1; - PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); - if (pPanelDescriptor) + std::shared_ptr<PanelDescriptor> xPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId); + if (xPanelDescriptor) { - pPanelDescriptor->mnOrderIndex = nextIndex; + xPanelDescriptor->mnOrderIndex = nextIndex; // update the sidebar pSidebarController->NotifyResize(); } |