From ac9db25da2d78f8ecc2ce68ad622cc6012972494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 22 Jun 2018 14:49:06 +0100 Subject: [PATCH] Resolves: tdf#118251 decide what parent colorpicker should have... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit depending on if launched from a listbox within a dialog, or from a (potentially) ephemeral toolbar Change-Id: I5d3b5cc6dd501490b99b46250e2729fb8bc2a2e2 Reviewed-on: https://gerrit.libreoffice.org/56297 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svx/colorwindow.hxx | 6 ++++++ reportdesign/source/ui/dlg/Condition.cxx | 1 + svx/source/tbxctrls/tbcontrl.cxx | 19 +++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx index d6c0e01239bf..16fb45da4ff3 100644 --- a/include/svx/colorwindow.hxx +++ b/include/svx/colorwindow.hxx @@ -69,6 +69,7 @@ private: BorderColorStatus& mrBorderColorStatus; ColorSelectFunction maColorSelectFunction; + bool mbReuseParentForPicker; DECL_LINK( SelectHdl, ValueSet*, void ); DECL_LINK( SelectPaletteHdl, ListBox&, void); @@ -86,6 +87,11 @@ public: sal_uInt16 nSlotId, const css::uno::Reference< css::frame::XFrame >& rFrame, vcl::Window* pParentWindow, + // tdf#118251 When true, reuse pParentWindow as the parent of the color picker + // that appears from the 'custom color' button. When false use the window of + // rFrame. true is helpful when launched from a dialog, false for launched + // from a toolbar + bool bReuseParentForPicker, ColorSelectFunction const& rColorSelectFunction); virtual ~SvxColorWindow() override; virtual void dispose() override; diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 5a934f9bd0fa..8d4e76ba23b2 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -231,6 +231,7 @@ IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void) nSlotId, nullptr, pToolBox, + false, m_aColorWrapper); m_pColorFloat->EnableDocking(); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 7842897b42fa..5a9b89af6551 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1257,6 +1257,7 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, sal_uInt16 nSlotId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow, + bool bReuseParentForPicker, std::function const & aFunction): ToolbarPopup( rFrame, pParentWindow, "palette_popup_window", "svx/ui/colorwindow.ui" ), @@ -1265,7 +1266,8 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, mxParentWindow(pParentWindow), mxPaletteManager( rPaletteManager ), mrBorderColorStatus( rBorderColorStatus ), - maColorSelectFunction(aFunction) + maColorSelectFunction(aFunction), + mbReuseParentForPicker(bReuseParentForPicker) { get(mpPaletteListBox, "palette_listbox"); get(mpButtonAutoColor, "auto_color_button"); @@ -1513,7 +1515,18 @@ IMPL_LINK_NOARG(SvxColorWindow, OpenPickerClickHdl, Button*, void) if ( IsInPopupMode() ) EndPopupMode(); - mxPaletteManager->PopupColorPicker(mxParentWindow->GetFrameWeld(), maCommand, GetSelectEntryColor().first); + + weld::Window* pParentFrame; + if (mbReuseParentForPicker) + { + pParentFrame = mxParentWindow->GetFrameWeld(); + } + else + { + const css::uno::Reference xParent(mxFrame->getContainerWindow(), uno::UNO_QUERY); + pParentFrame = Application::GetFrameWeld(xParent); + } + mxPaletteManager->PopupColorPicker(pParentFrame, maCommand, GetSelectEntryColor().first); } void SvxColorWindow::StartSelection() @@ -2866,6 +2879,7 @@ VclPtr SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar m_nSlotId, m_xFrame, pParent, + false, m_aColorSelectFunction); OUString aWindowTitle = vcl::CommandInfoProvider::GetLabelForCommand( m_aCommandURL, m_sModuleName ); @@ -3386,6 +3400,7 @@ void SvxColorListBox::createColorWindow() m_nSlotId, xFrame, this, + true, m_aColorWrapper); m_xColorWindow->AddEventListener(LINK(this, SvxColorListBox, WindowEventListener));