diff options
author | Andre Fischer <af@apache.org> | 2013-06-05 15:40:56 +0000 |
---|---|---|
committer | Andre Fischer <af@apache.org> | 2013-06-05 15:40:56 +0000 |
commit | 7b26aba94e5544937f1e37e34915bcb276bc3c27 (patch) | |
tree | babede9a22ad29ca8ccd9e33acc788348befc6b5 /sfx2 | |
parent | 136976efb17b8617a83c7f26601cd04031b51e7f (diff) |
122470: Fixed programmatic triggered switching of sidebar decks.
Notes
merged as: 50cbbc7f3afdd077e98f416f97390fe93428e8cf
Diffstat (limited to 'sfx2')
-rwxr-xr-x | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/Package_inc.mk | 1 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sidebar/Sidebar.hxx (renamed from sfx2/source/sidebar/Sidebar.hxx) | 50 | ||||
-rwxr-xr-x | sfx2/source/sidebar/AsynchronousCall.cxx | 9 | ||||
-rwxr-xr-x | sfx2/source/sidebar/AsynchronousCall.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/Sidebar.cxx | 65 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 66 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.hxx | 23 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarDockingWindow.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/TabBar.cxx | 12 |
10 files changed, 145 insertions, 84 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 38625caed86d..6200e1807943 100755 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -213,6 +213,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/menu/virtmenu \ sfx2/source/notify/eventsupplier \ sfx2/source/notify/hintpost \ + sfx2/source/sidebar/Sidebar \ sfx2/source/sidebar/SidebarChildWindow \ sfx2/source/sidebar/SidebarDockingWindow \ sfx2/source/sidebar/SidebarController \ diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index f3b113a9c940..22eae63ba01f 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -139,6 +139,7 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/EnumContext.hxx,sfx2 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/IContextChangeReceiver.hxx,sfx2/sidebar/IContextChangeReceiver.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/ILayoutableWindow.hxx,sfx2/sidebar/ILayoutableWindow.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/ResourceDefinitions.hrc,sfx2/sidebar/ResourceDefinitions.hrc)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/Sidebar.hxx,sfx2/sidebar/Sidebar.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/SidebarChildWindow.hxx,sfx2/sidebar/SidebarChildWindow.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/SidebarPanelBase.hxx,sfx2/sidebar/SidebarPanelBase.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/sidebar/SidebarToolBox.hxx,sfx2/sidebar/SidebarToolBox.hxx)) diff --git a/sfx2/source/sidebar/Sidebar.hxx b/sfx2/inc/sfx2/sidebar/Sidebar.hxx index c6c5a928ac22..924b33216a56 100644 --- a/sfx2/source/sidebar/Sidebar.hxx +++ b/sfx2/inc/sfx2/sidebar/Sidebar.hxx @@ -19,50 +19,42 @@ * *************************************************************/ -#ifndef SFX_SIDEBAR_HXX -#define SFX_SIDEBAR_HXX +#ifndef SFX_SIDEBAR_SIDEBAR_HXX +#define SFX_SIDEBAR_SIDEBAR_HXX #include "sfx2/dllapi.h" -#include <vcl/window.hxx> #include <com/sun/star/frame/XFrame.hpp> - namespace css = ::com::sun::star; namespace cssu = ::com::sun::star::uno; -namespace sfx2 { namespace sidebar { +namespace sfx2 { namespace sidebar { -/** SFX-less version of a module dependent task pane, filled with tool panels as specified in the respective - module's configuration +/** Accept requests for switching to certain panels or decks. */ class SFX2_DLLPUBLIC Sidebar - : public Window { public: - /** creates a new instance - @param i_rParentWindow - the parent window - @param i_rDocumentFrame - the frame to which the task pane belongs. Will be passed to any custom tool panels created - via an XUIElementFactory. Also, it is used to determine the module which the task pane is - responsible for, thus controlling which tool panels are actually available. - */ - Sidebar( - Window& rParentWindow, - const cssu::Reference<css::frame::XFrame>& rxDocumentFrame); - - - virtual ~Sidebar (void); - -protected: - virtual void Resize (void); - virtual void GetFocus (void); - -private: + /** Switch to the deck that contains the specified panel and make + sure that the panel is visible (expanded and scrolled into the + visible area.) + Note that most of the work is done asynchronously and that + this function probably returns before the requested panel is visible. + */ + static void ShowPanel ( + const ::rtl::OUString& rsPanelId, + const cssu::Reference<css::frame::XFrame>& rxFrame); + + /** Switch to the specified deck. + Note that most of the work is done asynchronously and that + this function probably returns before the requested deck is visible. + */ + static void ShowDeck ( + const ::rtl::OUString& rsDeckId, + const cssu::Reference<css::frame::XFrame>& rxFrame); }; - } } // end of namespace sfx2::sidebar #endif diff --git a/sfx2/source/sidebar/AsynchronousCall.cxx b/sfx2/source/sidebar/AsynchronousCall.cxx index ad3231aeb99e..557997b9bb3b 100755 --- a/sfx2/source/sidebar/AsynchronousCall.cxx +++ b/sfx2/source/sidebar/AsynchronousCall.cxx @@ -28,6 +28,15 @@ namespace sfx2 { namespace sidebar { +AsynchronousCall::AsynchronousCall (void) + : maAction(), + mnCallId(0) +{ +} + + + + AsynchronousCall::AsynchronousCall (const Action& rAction) : maAction(rAction), mnCallId(0) diff --git a/sfx2/source/sidebar/AsynchronousCall.hxx b/sfx2/source/sidebar/AsynchronousCall.hxx index f6366a061f89..9cc4ab34b3a9 100755 --- a/sfx2/source/sidebar/AsynchronousCall.hxx +++ b/sfx2/source/sidebar/AsynchronousCall.hxx @@ -35,6 +35,7 @@ class AsynchronousCall public: typedef ::boost::function<void(void)> Action; + AsynchronousCall (void); AsynchronousCall (const Action& rAction); ~AsynchronousCall (void); diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx index c6b6d763b1ff..8e2649570b89 100644 --- a/sfx2/source/sidebar/Sidebar.cxx +++ b/sfx2/source/sidebar/Sidebar.cxx @@ -21,7 +21,8 @@ #include "precompiled_sfx2.hxx" -#include "Sidebar.hxx" +#include "sfx2/sidebar/Sidebar.hxx" +#include "SidebarController.hxx" #include "ResourceManager.hxx" using namespace css; @@ -29,53 +30,37 @@ using namespace cssu; namespace sfx2 { namespace sidebar { -Sidebar::Sidebar( - Window& rParentWindow, - const Reference<frame::XFrame>& rxDocumentFrame) - : Window(&rParentWindow, WB_DIALOGCONTROL) -{ - ContentPanelManager::Instance(); -} - - - - -Sidebar::~Sidebar (void) -{ -} - - - -void Sidebar::Resize (void) +void Sidebar::ShowPanel ( + const ::rtl::OUString& rsPanelId, + const Reference<frame::XFrame>& rxFrame) { - Window::Resize(); - // m_pImpl->OnResize(); -} - - - - -void Sidebar::GetFocus (void) -{ - Window::GetFocus(); - // m_pImpl->OnGetFocus(); + SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame); + const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); + if (pController!=NULL && pPanelDescriptor != NULL) + { + // This should be a lot more sophisticated: + // - Make the deck switching asynchronous + // - Make sure that the panel is visible and expanded after + // the switch. + // - Make sure to use a context that really shows the panel + // + // All that is not necessary for the current use cases so lets + // keep it simple for the time being. + pController->RequestSwitchToDeck(pPanelDescriptor->msDeckId); + } } -void Sidebar::DataChanged (const DataChangedEvent& rDataChangedEvent) +void Sidebar::ShowDeck ( + const ::rtl::OUString& rsDeckId, + const Reference<frame::XFrame>& rxFrame) { - if (rDataChangedEvent.GetType() == DATACHANGED_SETTINGS - && (rDataChangedEvent.GetFlags() & SETTINGS_STYLE)!= 0) - { - Invalidate(); - } - else - Window::DataChanged(rDataChangedEvent); + SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame); + if (pController != NULL) + pController->RequestSwitchToDeck(rsDeckId); } - - } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 067349a65a3f..730bbc5d8da4 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -83,6 +83,8 @@ namespace namespace sfx2 { namespace sidebar { +SidebarController::SidebarControllerContainer SidebarController::maSidebarControllerContainer; + namespace { enum MenuId { @@ -119,6 +121,7 @@ SidebarController::SidebarController ( msCurrentDeckTitle(), maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)), + maAsynchronousDeckSwitch(), mbIsDeckRequestedOpen(), mbIsDeckOpen(), mbCanDeckBeOpened(true), @@ -161,6 +164,12 @@ SidebarController::SidebarController ( mxReadOnlyModeDispatch->addStatusListener(this, aURL); SwitchToDeck(A2S("default")); + + WeakReference<SidebarController> xWeakController (this); + maSidebarControllerContainer.insert( + SidebarControllerContainer::value_type( + rxFrame, + xWeakController)); } @@ -173,8 +182,29 @@ SidebarController::~SidebarController (void) +SidebarController* SidebarController::GetSidebarControllerForFrame ( + const cssu::Reference<css::frame::XFrame>& rxFrame) +{ + SidebarControllerContainer::iterator iEntry (maSidebarControllerContainer.find(rxFrame)); + if (iEntry == maSidebarControllerContainer.end()) + return NULL; + + cssu::Reference<XInterface> xController (iEntry->second.get()); + if ( ! xController.is()) + return NULL; + + return dynamic_cast<SidebarController*>(xController.get()); +} + + + + void SAL_CALL SidebarController::disposing (void) { + SidebarControllerContainer::iterator iEntry (maSidebarControllerContainer.find(mxFrame)); + if (iEntry != maSidebarControllerContainer.end()) + maSidebarControllerContainer.erase(iEntry); + maFocusManager.Clear(); cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( @@ -212,6 +242,7 @@ void SAL_CALL SidebarController::disposing (void) static_cast<css::beans::XPropertyChangeListener*>(this)); maContextChangeUpdate.CancelRequest(); + maAsynchronousDeckSwitch.CancelRequest(); } @@ -227,7 +258,10 @@ void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::Contex rEvent.ApplicationName, rEvent.ContextName); if (maRequestedContext != maCurrentContext) + { + maAsynchronousDeckSwitch.CancelRequest(); maContextChangeUpdate.RequestCall(); + } } @@ -270,6 +304,7 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv if ( ! mbIsDocumentReadOnly) msCurrentDeckId = gsDefaultDeckId; mnRequestedForceFlags |= SwitchFlag_ForceSwitch; + maAsynchronousDeckSwitch.CancelRequest(); maContextChangeUpdate.RequestCall(); } } @@ -442,16 +477,6 @@ void SidebarController::UpdateConfigurations (void) SwitchToDeck( *ResourceManager::Instance().GetDeckDescriptor(sNewDeckId), maCurrentContext); - -#ifdef DEBUG - // Show the context name in the deck title bar. - if (mpCurrentDeck) - { - DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); - if (pTitleBar != NULL) - pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")")); - } -#endif } } @@ -463,6 +488,18 @@ void SidebarController::OpenThenSwitchToDeck ( { RequestOpenDeck(); SwitchToDeck(rsDeckId); + mpTabBar->Invalidate(); +} + + + + +void SidebarController::RequestSwitchToDeck ( + const ::rtl::OUString& rsDeckId) +{ + maContextChangeUpdate.CancelRequest(); + maAsynchronousDeckSwitch.RequestCall( + ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, rsDeckId)); } @@ -546,10 +583,18 @@ void SidebarController::SwitchToDeck ( mpParentWindow, ::boost::bind(&SidebarController::RequestCloseDeck, this))); msCurrentDeckTitle = rDeckDescriptor.msTitle; + } if ( ! mpCurrentDeck) return; +#ifdef DEBUG + // Show the context name in the deck title bar. + DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); + if (pTitleBar != NULL) + pTitleBar->SetTitle(rDeckDescriptor.msTitle+A2S(" (")+maCurrentContext.msContext+A2S(")")); +#endif + // Update the panel list. const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size()); SharedPanelContainer aNewPanels; @@ -758,6 +803,7 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) UpdateTitleBarIcons(); mpParentWindow->Invalidate(); mnRequestedForceFlags |= SwitchFlag_ForceNewDeck | SwitchFlag_ForceNewPanels; + maAsynchronousDeckSwitch.CancelRequest(); maContextChangeUpdate.RequestCall(); break; diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx index 36389b6027c2..2b4be322d712 100644 --- a/sfx2/source/sidebar/SidebarController.hxx +++ b/sfx2/source/sidebar/SidebarController.hxx @@ -42,6 +42,9 @@ #include <boost/optional.hpp> #include <cppuhelper/compbase4.hxx> #include <cppuhelper/basemutex.hxx> +#include <cppuhelper/weakref.hxx> +#include <comphelper/stl_types.hxx> + namespace css = ::com::sun::star; namespace cssu = ::com::sun::star::uno; @@ -80,6 +83,15 @@ public: const cssu::Reference<css::frame::XFrame>& rxFrame); virtual ~SidebarController (void); + /** Return the SidebarController object that is associated with + the given XFrame. + @return + When there is no SidebarController object for the given + XFrame then <NULL/> is returned. + */ + static SidebarController* GetSidebarControllerForFrame ( + const cssu::Reference<css::frame::XFrame>& rxFrame); + // ui::XContextChangeEventListener virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) throw(cssu::RuntimeException); @@ -113,7 +125,7 @@ public: const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02; const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02; - void SwitchToDeck ( + void RequestSwitchToDeck ( const ::rtl::OUString& rsDeckId); void OpenThenSwitchToDeck ( const ::rtl::OUString& rsDeckId); @@ -129,6 +141,12 @@ public: FocusManager& GetFocusManager (void); private: + typedef ::std::map< + const cssu::Reference<css::frame::XFrame>, + cssu::WeakReference<SidebarController> + > SidebarControllerContainer; + static SidebarControllerContainer maSidebarControllerContainer; + ::boost::scoped_ptr<Deck> mpCurrentDeck; SidebarDockingWindow* mpParentWindow; ::boost::scoped_ptr<TabBar> mpTabBar; @@ -141,6 +159,7 @@ private: ::rtl::OUString msCurrentDeckTitle; AsynchronousCall maPropertyChangeForwarder; AsynchronousCall maContextChangeUpdate; + AsynchronousCall maAsynchronousDeckSwitch; /** Two flags control whether the deck is displayed or if only the tab bar remains visible. @@ -188,6 +207,8 @@ private: const bool bIsInitiallyExpanded, const Context& rContext); void SwitchToDeck ( + const ::rtl::OUString& rsDeckId); + void SwitchToDeck ( const DeckDescriptor& rDeckDescriptor, const Context& rContext); void ShowPopupMenu ( diff --git a/sfx2/source/sidebar/SidebarDockingWindow.hxx b/sfx2/source/sidebar/SidebarDockingWindow.hxx index 338e31ed1935..1ee9b221ce40 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.hxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.hxx @@ -24,7 +24,6 @@ #include "sfx2/dockwin.hxx" #include "sfx2/dockwin.hxx" -#include "Sidebar.hxx" #include <rtl/ref.hxx> diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index 2da81a5b0351..184e13f7079e 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -236,9 +236,15 @@ void TabBar::Layout (void) void TabBar::HighlightDeck (const ::rtl::OUString& rsDeckId) { - Item* pItem = GetItemForId(rsDeckId); - if (pItem != NULL) - pItem->mpButton->Check(); + for (ItemContainer::iterator iItem(maItems.begin()),iEnd(maItems.end()); + iItem!=iEnd; + ++iItem) + { + if (iItem->msDeckId.equals(rsDeckId)) + iItem->mpButton->Check(sal_True); + else + iItem->mpButton->Check(sal_False); + } } |