Kaydet (Commit) 9f61005d authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

tdf#109309 Currency dropdown is misplaced under Wayland

- Base SvxCurrencyToolBoxControl on PopupWindowController,
  so we still allow tearoff, but without marking the window
  as self-decorated (unless actually teared-off).

- Add support for toggle state to PopupWindowController.

Change-Id: I60e004e6ada3efe092352cb93be5aae346073f83
Reviewed-on: https://gerrit.libreoffice.org/40557Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst d742c001
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/frame/XSubToolbarController.hpp> #include <com/sun/star/frame/XSubToolbarController.hpp>
#include <svtools/popupwindowcontroller.hxx>
#include <svx/colorwindow.hxx> #include <svx/colorwindow.hxx>
#include <svx/PaletteManager.hxx> #include <svx/PaletteManager.hxx>
#include <memory> #include <memory>
...@@ -248,7 +249,7 @@ public: ...@@ -248,7 +249,7 @@ public:
const SfxPoolItem* pState) override; const SfxPoolItem* pState) override;
}; };
class SVX_DLLPUBLIC SvxCurrencyToolBoxControl : public SfxToolBoxControl class SVX_DLLPUBLIC SvxCurrencyToolBoxControl : public svt::PopupWindowController
{ {
private: private:
OUString m_aFormatString; OUString m_aFormatString;
...@@ -257,18 +258,24 @@ private: ...@@ -257,18 +258,24 @@ private:
public: public:
static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag, static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag,
std::vector<sal_uInt16>& rCurrencyList ); std::vector<sal_uInt16>& rCurrencyList );
SFX_DECL_TOOLBOX_CONTROL();
SvxCurrencyToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox ); explicit SvxCurrencyToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
virtual ~SvxCurrencyToolBoxControl() override; virtual ~SvxCurrencyToolBoxControl() override;
virtual void Select( sal_uInt16 nSelectModifier ) override;
virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; // XToolbarController
virtual void SAL_CALL execute( sal_Int16 nSelectModifier ) override;
using svt::ToolboxController::createPopupWindow;
virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
// XInitialization // XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override; virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override;
}; };
#endif // INCLUDED_SVX_TBCONTRL_HXX #endif // INCLUDED_SVX_TBCONTRL_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1177,6 +1177,17 @@ ...@@ -1177,6 +1177,17 @@
<value>com.sun.star.comp.svx.FrameToolBoxControl</value> <value>com.sun.star.comp.svx.FrameToolBoxControl</value>
</prop> </prop>
</node> </node>
<node oor:name="CurrencyToolBoxControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:NumberFormatCurrency</value>
</prop>
<prop oor:name="Module">
<value>com.sun.star.sheet.SpreadsheetDocument</value>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.svx.CurrencyToolBoxControl</value>
</prop>
</node>
<node oor:name="c4" oor:op="replace" install:module="reportbuilder"> <node oor:name="c4" oor:op="replace" install:module="reportbuilder">
<prop oor:name="Command"> <prop oor:name="Command">
<value>.uno:FontColor</value> <value>.uno:FontColor</value>
......
...@@ -154,7 +154,6 @@ void ScDLL::Init() ...@@ -154,7 +154,6 @@ void ScDLL::Init()
// Own Controller // Own Controller
ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod); ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod);
SvxCurrencyToolBoxControl ::RegisterControl(SID_NUMBER_CURRENCY, pMod);
// SvxToolboxController // SvxToolboxController
SvxTbxCtlDraw ::RegisterControl(SID_INSERT_DRAW, pMod); SvxTbxCtlDraw ::RegisterControl(SID_INSERT_DRAW, pMod);
......
...@@ -178,8 +178,15 @@ void SAL_CALL PopupWindowController::dispose() ...@@ -178,8 +178,15 @@ void SAL_CALL PopupWindowController::dispose()
// XStatusListener // XStatusListener
void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEvent& rEvent ) void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEvent& rEvent )
{ {
svt::ToolboxController::statusChanged(rEvent); ToolBox* pToolBox = nullptr;
enable( rEvent.IsEnabled ); sal_uInt16 nItemId = 0;
if ( getToolboxId( nItemId, &pToolBox ) )
{
bool bValue = false;
rEvent.State >>= bValue;
pToolBox->CheckItem( nItemId, bValue );
pToolBox->EnableItem( nItemId, rEvent.IsEnabled );
}
} }
Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow() Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow()
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <vcl/vclptr.hxx> #include <vcl/vclptr.hxx>
#include <svtools/valueset.hxx> #include <svtools/valueset.hxx>
#include <svtools/ctrlbox.hxx> #include <svtools/ctrlbox.hxx>
#include <svtools/popupwindowcontroller.hxx>
#include <svtools/toolbarmenu.hxx> #include <svtools/toolbarmenu.hxx>
#include <svl/style.hxx> #include <svl/style.hxx>
#include <svtools/ctrltool.hxx> #include <svtools/ctrltool.hxx>
...@@ -123,7 +122,6 @@ using namespace ::com::sun::star::lang; ...@@ -123,7 +122,6 @@ using namespace ::com::sun::star::lang;
SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxCurrencyToolBoxControl, SfxBoolItem );
class SvxStyleBox_Impl : public ComboBox class SvxStyleBox_Impl : public ComboBox
{ {
...@@ -296,8 +294,7 @@ public: ...@@ -296,8 +294,7 @@ public:
virtual void dispose() override { m_aLineStyleLb.disposeAndClear(); ToolbarPopup::dispose(); } virtual void dispose() override { m_aLineStyleLb.disposeAndClear(); ToolbarPopup::dispose(); }
}; };
class SvxCurrencyToolBoxControl; class SvxCurrencyList_Impl : public svtools::ToolbarPopup
class SvxCurrencyList_Impl : public SfxPopupWindow
{ {
private: private:
VclPtr<ListBox> m_pCurrencyLb; VclPtr<ListBox> m_pCurrencyLb;
...@@ -310,10 +307,8 @@ private: ...@@ -310,10 +307,8 @@ private:
DECL_LINK( SelectHdl, ListBox&, void ); DECL_LINK( SelectHdl, ListBox&, void );
public: public:
SvxCurrencyList_Impl( sal_uInt16 nId, const Reference< XFrame >& rxFrame, SvxCurrencyList_Impl( SvxCurrencyToolBoxControl* pControl,
vcl::Window* pParentWindow, vcl::Window* pParentWindow,
const Reference< css::uno::XComponentContext >& rxContext,
SvxCurrencyToolBoxControl *pControl,
OUString& rSelectFormat, OUString& rSelectFormat,
LanguageType& eSelectLanguage ); LanguageType& eSelectLanguage );
virtual ~SvxCurrencyList_Impl() override { disposeOnce(); } virtual ~SvxCurrencyList_Impl() override { disposeOnce(); }
...@@ -1992,13 +1987,11 @@ static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ ) ...@@ -1992,13 +1987,11 @@ static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
} }
SvxCurrencyList_Impl::SvxCurrencyList_Impl( SvxCurrencyList_Impl::SvxCurrencyList_Impl(
sal_uInt16 nId, const Reference< XFrame >& rxFrame, SvxCurrencyToolBoxControl* pControl,
vcl::Window* pParentWindow, vcl::Window* pParentWindow,
const Reference< XComponentContext >& rxContext,
SvxCurrencyToolBoxControl *pControl,
OUString& rSelectedFormat, OUString& rSelectedFormat,
LanguageType& eSelectedLanguage ) : LanguageType& eSelectedLanguage ) :
SfxPopupWindow( nId, rxFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION | WB_AUTOSIZE | WB_3DLOOK ) ), ToolbarPopup( pControl->getFrameInterface(), pParentWindow, WB_STDPOPUP | WB_MOVEABLE | WB_CLOSEABLE ),
m_pCurrencyLb( VclPtr<ListBox>::Create(this) ), m_pCurrencyLb( VclPtr<ListBox>::Create(this) ),
m_xControl( pControl ), m_xControl( pControl ),
m_rSelectedFormat( rSelectedFormat ), m_rSelectedFormat( rSelectedFormat ),
...@@ -2012,7 +2005,7 @@ SvxCurrencyList_Impl::SvxCurrencyList_Impl( ...@@ -2012,7 +2005,7 @@ SvxCurrencyList_Impl::SvxCurrencyList_Impl(
const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable(); const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable();
sal_uInt16 nLen = rCurrencyTable.size(); sal_uInt16 nLen = rCurrencyTable.size();
SvNumberFormatter aFormatter( rxContext, LANGUAGE_SYSTEM ); SvNumberFormatter aFormatter( m_xControl->getContext(), LANGUAGE_SYSTEM );
m_eFormatLanguage = aFormatter.GetLanguage(); m_eFormatLanguage = aFormatter.GetLanguage();
SvxCurrencyToolBoxControl::GetCurrencySymbols( aList, true, aCurrencyList ); SvxCurrencyToolBoxControl::GetCurrencySymbols( aList, true, aCurrencyList );
...@@ -2051,7 +2044,7 @@ void SvxCurrencyList_Impl::dispose() ...@@ -2051,7 +2044,7 @@ void SvxCurrencyList_Impl::dispose()
{ {
m_xControl.clear(); m_xControl.clear();
m_pCurrencyLb.disposeAndClear(); m_pCurrencyLb.disposeAndClear();
SfxPopupWindow::dispose(); ToolbarPopup::dispose();
} }
SvxLineWindow_Impl::SvxLineWindow_Impl( svt::ToolboxController& rController, vcl::Window* pParentWindow ) : SvxLineWindow_Impl::SvxLineWindow_Impl( svt::ToolboxController& rController, vcl::Window* pParentWindow ) :
...@@ -2122,7 +2115,7 @@ IMPL_LINK_NOARG(SvxCurrencyList_Impl, SelectHdl, ListBox&, void) ...@@ -2122,7 +2115,7 @@ IMPL_LINK_NOARG(SvxCurrencyList_Impl, SelectHdl, ListBox&, void)
m_rSelectedFormat = m_aFormatEntries[ m_pCurrencyLb->GetSelectEntryPos() ]; m_rSelectedFormat = m_aFormatEntries[ m_pCurrencyLb->GetSelectEntryPos() ];
m_eSelectedLanguage = m_eFormatLanguage; m_eSelectedLanguage = m_eFormatLanguage;
m_xControl->Select( m_pCurrencyLb->GetSelectEntryPos() + 1 ); m_xControl->execute( m_pCurrencyLb->GetSelectEntryPos() + 1 );
} }
IMPL_LINK_NOARG(SvxLineWindow_Impl, SelectHdl, ListBox&, void) IMPL_LINK_NOARG(SvxLineWindow_Impl, SelectHdl, ListBox&, void)
...@@ -3045,8 +3038,8 @@ void SvxSimpleUndoRedoController::StateChanged( sal_uInt16, SfxItemState eState, ...@@ -3045,8 +3038,8 @@ void SvxSimpleUndoRedoController::StateChanged( sal_uInt16, SfxItemState eState,
rBox.EnableItem( GetId(), eState != SfxItemState::DISABLED ); rBox.EnableItem( GetId(), eState != SfxItemState::DISABLED );
} }
SvxCurrencyToolBoxControl::SvxCurrencyToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox ) : SvxCurrencyToolBoxControl::SvxCurrencyToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext ) :
SfxToolBoxControl( nSlotId, nId, rBox ), PopupWindowController( rContext, nullptr, OUString() ),
m_eLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() ), m_eLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() ),
m_nFormatKey( NUMBERFORMAT_ENTRY_NOT_FOUND ) m_nFormatKey( NUMBERFORMAT_ENTRY_NOT_FOUND )
{ {
...@@ -3056,28 +3049,20 @@ SvxCurrencyToolBoxControl::~SvxCurrencyToolBoxControl() {} ...@@ -3056,28 +3049,20 @@ SvxCurrencyToolBoxControl::~SvxCurrencyToolBoxControl() {}
void SvxCurrencyToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) void SvxCurrencyToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
{ {
SfxToolBoxControl::initialize(rArguments); PopupWindowController::initialize(rArguments);
if (GetToolBox().GetItemCommand(GetId()) == m_aCommandURL)
GetToolBox().SetItemBits(GetId(), ToolBoxItemBits::DROPDOWN | GetToolBox().GetItemBits(GetId())); ToolBox* pToolBox = nullptr;
sal_uInt16 nId = 0;
if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWN | pToolBox->GetItemBits(nId));
} }
VclPtr<SfxPopupWindow> SvxCurrencyToolBoxControl::CreatePopupWindow() VclPtr<vcl::Window> SvxCurrencyToolBoxControl::createPopupWindow( vcl::Window* pParent )
{ {
VclPtr<SvxCurrencyList_Impl> xCurrencyWin = return VclPtr<SvxCurrencyList_Impl>::Create(this, pParent, m_aFormatString, m_eLanguage);
VclPtr<SvxCurrencyList_Impl>::Create( GetSlotId(), m_xFrame,
&GetToolBox(), getContext(),
this, m_aFormatString,
m_eLanguage );
xCurrencyWin->StartPopupMode( &GetToolBox(),
FloatWinPopupFlags::GrabFocus |
FloatWinPopupFlags::AllowTearOff |
FloatWinPopupFlags::NoAppFocusClose );
SetPopupWindow( xCurrencyWin );
return xCurrencyWin;
} }
void SvxCurrencyToolBoxControl::Select( sal_uInt16 nSelectModifier ) void SvxCurrencyToolBoxControl::execute( sal_Int16 nSelectModifier )
{ {
sal_uInt32 nFormatKey; sal_uInt32 nFormatKey;
if (m_aFormatString.isEmpty()) if (m_aFormatString.isEmpty())
...@@ -3109,11 +3094,29 @@ void SvxCurrencyToolBoxControl::Select( sal_uInt16 nSelectModifier ) ...@@ -3109,11 +3094,29 @@ void SvxCurrencyToolBoxControl::Select( sal_uInt16 nSelectModifier )
Sequence< PropertyValue > aArgs( 1 ); Sequence< PropertyValue > aArgs( 1 );
aArgs[0].Name = "NumberFormatCurrency"; aArgs[0].Name = "NumberFormatCurrency";
aArgs[0].Value <<= nFormatKey; aArgs[0].Value <<= nFormatKey;
Dispatch( m_aCommandURL, aArgs ); dispatchCommand( m_aCommandURL, aArgs );
m_nFormatKey = nFormatKey; m_nFormatKey = nFormatKey;
} }
else else
SfxToolBoxControl::Select( nSelectModifier ); PopupWindowController::execute( nSelectModifier );
}
OUString SvxCurrencyToolBoxControl::getImplementationName()
{
return OUString( "com.sun.star.comp.svx.CurrencyToolBoxControl" );
}
css::uno::Sequence<OUString> SvxCurrencyToolBoxControl::getSupportedServiceNames()
{
return { "com.sun.star.frame.ToolbarController" };
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_svx_CurrencyToolBoxControl_get_implementation(
css::uno::XComponentContext* rContext,
css::uno::Sequence<css::uno::Any> const & )
{
return cppu::acquire( new SvxCurrencyToolBoxControl( rContext ) );
} }
Reference< css::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible() Reference< css::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
constructor="com_sun_star_comp_svx_FrameToolBoxControl_get_implementation"> constructor="com_sun_star_comp_svx_FrameToolBoxControl_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/> <service name="com.sun.star.frame.ToolbarController"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.svx.CurrencyToolBoxControl"
constructor="com_sun_star_comp_svx_CurrencyToolBoxControl_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.comp.svx.FontNameToolBoxControl" <implementation name="com.sun.star.comp.svx.FontNameToolBoxControl"
constructor="com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation"> constructor="com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/> <service name="com.sun.star.frame.ToolbarController"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment