diff options
author | Serge Krot <Serge.Krot@cib.de> | 2017-09-19 12:43:26 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-09-20 03:49:57 +0200 |
commit | 8abc7ba9784f7898576fbdd7a48f0ff9e4445a68 (patch) | |
tree | 0c7b185be62c9b48305026b988fe06ce1def66ec /sd | |
parent | e73961022d8efda407c3f5ed806f78bb7cc0e0b4 (diff) |
tdf#98980 Update selection inside control when new slide layout is selected
Change-Id: Ibf8fe8d2fcdb5efef6df657607e65a791b67d4a0
Reviewed-on: https://gerrit.libreoffice.org/42462
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.cxx | 46 | ||||
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.hxx | 2 |
2 files changed, 27 insertions, 21 deletions
diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index 12a3c02e3866..3b52103c4404 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -129,7 +129,6 @@ LayoutMenu::LayoutMenu ( DropTargetHelper(this), mrBase(rViewShellBase), mxListener(nullptr), - mbSelectionUpdatePending(true), mbIsMainViewChangePending(false), mxSidebar(rxSidebar), mbIsDisposed(false) @@ -253,16 +252,6 @@ ui::LayoutSize LayoutMenu::GetHeightForWidth (const sal_Int32 nWidth) return ui::LayoutSize(nPreferredHeight,nPreferredHeight,nPreferredHeight); } -void LayoutMenu::Paint (vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) -{ - if (mbSelectionUpdatePending) - { - mbSelectionUpdatePending = false; - UpdateSelection(); - } - ValueSet::Paint(rRenderContext, rRect); -} - void LayoutMenu::Resize() { Size aWindowSize = GetOutputSizePixel(); @@ -342,6 +331,9 @@ void LayoutMenu::InvalidateContent() if (mxSidebar.is()) mxSidebar->requestLayout(); + + // set selection inside the control during Impress start up + UpdateSelection(); } int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount) @@ -547,8 +539,6 @@ void LayoutMenu::Fill() SetItemData (i, new AutoLayout(pInfo->maAutoLayout)); } } - - mbSelectionUpdatePending = true; } void LayoutMenu::Clear() @@ -653,6 +643,11 @@ IMPL_LINK(LayoutMenu, OnMenuItemSelected, Menu*, pMenu, bool) return false; } +// Selects an appropriate layout of the slide inside control. +// +// Method may be called several times with the same item-id to be selected - +// only once the actually state of the control will be changed. +// void LayoutMenu::UpdateSelection() { bool bItemSelected = false; @@ -674,14 +669,19 @@ void LayoutMenu::UpdateSelection() break; // Find the entry of the menu for to the layout. - SetNoSelection(); - sal_uInt16 nItemCount (GetItemCount()); + const sal_uInt16 nItemCount = GetItemCount(); for (sal_uInt16 nId=1; nId<=nItemCount; nId++) { if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout) { - SelectItem(nId); - bItemSelected = true; + // do not set selection twice to the same item + if (GetSelectItemId() != nId) + { + SetNoSelection(); + SelectItem(nId); + } + + bItemSelected = true; // no need to call SetNoSelection() break; } } @@ -696,10 +696,18 @@ IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEve { switch (rEvent.meEventId) { + // tdf#89890 During changes of the Layout of the slide when focus is not set inside main area + // we do not receive notification EventMultiplexerEventId::CurrentPageChanged, but we receive the following 3 notification types. + // => let's make UpdateSelection() also when some shape is changed (during Layout changes) + case EventMultiplexerEventId::ShapeChanged: + case EventMultiplexerEventId::ShapeInserted: + case EventMultiplexerEventId::ShapeRemoved: + UpdateSelection(); + break; + case EventMultiplexerEventId::CurrentPageChanged: case EventMultiplexerEventId::SlideSortedSelection: - if ( ! mbSelectionUpdatePending) - UpdateSelection(); + UpdateSelection(); break; case EventMultiplexerEventId::MainViewAdded: diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx b/sd/source/ui/sidebar/LayoutMenu.hxx index 2b5823f9f92f..bdb06cc5c9c0 100644 --- a/sd/source/ui/sidebar/LayoutMenu.hxx +++ b/sd/source/ui/sidebar/LayoutMenu.hxx @@ -87,7 +87,6 @@ public: virtual css::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth) override; // From vcl::Window - virtual void Paint (vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override; virtual void Resize() override; /** Show a context menu when the right mouse button is pressed. @@ -126,7 +125,6 @@ private: many columns for the calculation. */ css::uno::Reference<css::frame::XStatusListener> mxListener; - bool mbSelectionUpdatePending; bool mbIsMainViewChangePending; css::uno::Reference<css::ui::XSidebar> mxSidebar; bool mbIsDisposed; |