summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-12-25 03:11:31 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2017-01-05 00:11:29 +0200
commit9ae8e4d35681890c5db153c53c74377428fa31d4 (patch)
tree6f2324fdcc009a4ad1386491c2681031db9c33b3
parent835556b51afd21f47b1bd1910cad0b7389ca04a8 (diff)
Base SvxLineEndWindow on ToolbarPopup
Fixes size and position issues under gtk3/wayland Change-Id: I357a5935e2b44fd3d5effde8cf7d3499e26384db
-rw-r--r--include/svx/linectrl.hxx56
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu11
-rw-r--r--sc/source/ui/app/scdll.cxx1
-rw-r--r--sd/source/ui/app/sddll.cxx2
-rw-r--r--svx/source/tbxctrls/linectrl.cxx134
-rw-r--r--svx/util/svx.component4
-rw-r--r--sw/source/uibase/app/swmodule.cxx1
7 files changed, 95 insertions, 114 deletions
diff --git a/include/svx/linectrl.hxx b/include/svx/linectrl.hxx
index bc6f82b6d409..2c476118d446 100644
--- a/include/svx/linectrl.hxx
+++ b/include/svx/linectrl.hxx
@@ -72,62 +72,6 @@ public:
virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override;
};
-
-// class SvxLineEndWindow
-
-class SvxLineEndWindow : public SfxPopupWindow
-{
-private:
- XLineEndListRef mpLineEndList;
- VclPtr<ValueSet> mpLineEndSet;
- sal_uInt16 mnCols;
- sal_uInt16 mnLines;
- Size maBmpSize;
- css::uno::Reference< css::frame::XFrame > mxFrame;
-
-
- DECL_LINK( SelectHdl, ValueSet*, void );
- void FillValueSet();
- void SetSize();
- void implInit();
-
-protected:
- /** This function is called when the window gets the focus. It grabs
- the focus to the line ends value set so that it can be controlled with
- the keyboard.
- */
- virtual void GetFocus() override;
-
-public:
- SvxLineEndWindow( sal_uInt16 nId,
- const css::uno::Reference< css::frame::XFrame >& rFrame,
- vcl::Window* pParentWindow,
- const OUString& rWndTitle );
- virtual ~SvxLineEndWindow() override;
- virtual void dispose() override;
-
- void StartSelection();
-
- virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
-};
-
-
-// class SvxLineEndToolBoxControl
-
-
-class SVX_DLLPUBLIC SvxLineEndToolBoxControl : public SfxToolBoxControl
-{
-public:
- SFX_DECL_TOOLBOX_CONTROL();
- SvxLineEndToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
- virtual ~SvxLineEndToolBoxControl() override;
-
- virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
- const SfxPoolItem* pState ) override;
- virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override;
-};
-
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 631d5a2395fb..2ec77eae80b1 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -1130,6 +1130,17 @@
<value>com.sun.star.comp.sfx2.ClassificationCategoriesController</value>
</prop>
</node>
+ <node oor:name="LineEndToolBoxControl" oor:op="replace">
+ <prop oor:name="Command">
+ <value>.uno:LineEndStyle</value>
+ </prop>
+ <prop oor:name="Module">
+ <value/>
+ </prop>
+ <prop oor:name="Controller">
+ <value>com.sun.star.comp.svx.LineEndToolBoxControl</value>
+ </prop>
+ </node>
<node oor:name="BorderStyleToolBoxControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:SetBorderStyle</value>
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 6bec0130bcc3..0d9df6592b08 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -162,7 +162,6 @@ void ScDLL::Init()
SvxLineWidthToolBoxControl ::RegisterControl(0, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_LINE_COLOR, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_FILL_COLOR, pMod);
- SvxLineEndToolBoxControl ::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod);
SvxStyleToolBoxControl ::RegisterControl(SID_STYLE_APPLY, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_COLOR, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod);
diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx
index 97a4e08da328..1f467d7f2341 100644
--- a/sd/source/ui/app/sddll.cxx
+++ b/sd/source/ui/app/sddll.cxx
@@ -186,8 +186,6 @@ void SdDLL::RegisterControllers(SdModule* pMod)
SvxColorToolBoxControl::RegisterControl(SID_ATTR_LINE_COLOR, pMod);
SvxColorToolBoxControl::RegisterControl(SID_ATTR_FILL_COLOR, pMod);
- SvxLineEndToolBoxControl::RegisterControl( SID_ATTR_LINEEND_STYLE, pMod );
-
SvxStyleToolBoxControl::RegisterControl(0, pMod);
SvxColorToolBoxControl::RegisterControl( SID_ATTR_CHAR_COLOR, pMod );
SvxColorToolBoxControl::RegisterControl( SID_ATTR_CHAR_BACK_COLOR, pMod );
diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
index 76b022ec2401..53dd837d3a83 100644
--- a/svx/source/tbxctrls/linectrl.cxx
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -24,6 +24,9 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/objsh.hxx>
+#include <svtools/toolbarmenu.hxx>
+#include <svtools/popupwindowcontroller.hxx>
+
#include <svx/dialogs.hrc>
#include "helpid.hrc"
@@ -49,7 +52,6 @@ using namespace ::com::sun::star;
SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem );
-SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl, SfxBoolItem );
SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( sal_uInt16 nSlotId,
sal_uInt16 nId,
@@ -243,31 +245,42 @@ VclPtr<vcl::Window> SvxLineWidthToolBoxControl::CreateItemWindow( vcl::Window *p
return VclPtr<SvxMetricField>::Create( pParent, m_xFrame ).get();
}
-SvxLineEndWindow::SvxLineEndWindow(
- sal_uInt16 nSlotId,
- const Reference< XFrame >& rFrame,
- vcl::Window* pParentWindow,
- const OUString& rWndTitle ) :
- SfxPopupWindow( nSlotId,
- rFrame,
- pParentWindow,
- WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
+class SvxLineEndWindow : public svtools::ToolbarPopup
+{
+private:
+ XLineEndListRef mpLineEndList;
+ VclPtr<ValueSet> mpLineEndSet;
+ sal_uInt16 mnCols;
+ sal_uInt16 mnLines;
+ Size maBmpSize;
+ svt::ToolboxController& mrController;
+
+ DECL_LINK( SelectHdl, ValueSet*, void );
+ void FillValueSet();
+ void SetSize();
+
+protected:
+ virtual void GetFocus() override;
+
+public:
+ SvxLineEndWindow( svt::ToolboxController& rController, vcl::Window* pParentWindow );
+ virtual ~SvxLineEndWindow() override;
+ virtual void dispose() override;
+ virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception ) override;
+};
+
+SvxLineEndWindow::SvxLineEndWindow( svt::ToolboxController& rController, vcl::Window* pParentWindow )
+ : ToolbarPopup ( rController.getFrameInterface(), pParentWindow, WB_STDPOPUP | WB_MOVEABLE | WB_CLOSEABLE ),
mpLineEndSet ( VclPtr<ValueSet>::Create(this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) )),
mnCols ( 2 ),
mnLines ( 12 ),
- mxFrame ( rFrame )
-{
- SetText( rWndTitle );
- implInit();
-}
-
-void SvxLineEndWindow::implInit()
+ mrController ( rController )
{
- SfxObjectShell* pDocSh = SfxObjectShell::Current();
-
+ SetText( SVX_RESSTR( RID_SVXSTR_LINEEND ) );
SetHelpId( HID_POPUP_LINEEND );
mpLineEndSet->SetHelpId( HID_POPUP_LINEEND_CTRL );
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
if ( pDocSh )
{
const SfxPoolItem* pItem = pDocSh->GetItem( SID_LINEEND_LIST );
@@ -284,7 +297,6 @@ void SvxLineEndWindow::implInit()
AddStatusListener( ".uno:LineEndListState");
- //ChangeHelpId( HID_POPUP_LINEENDSTYLE );
mpLineEndSet->Show();
}
@@ -296,7 +308,7 @@ SvxLineEndWindow::~SvxLineEndWindow()
void SvxLineEndWindow::dispose()
{
mpLineEndSet.disposeAndClear();
- SfxPopupWindow::dispose();
+ ToolbarPopup::dispose();
}
IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl, ValueSet*, void)
@@ -348,12 +360,9 @@ IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl, ValueSet*, void)
while in Dispatch()), accessing members will crash in this case. */
mpLineEndSet->SetNoSelection();
- SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
- ".uno:LineEndStyle",
- aArgs );
+ mrController.dispatchCommand( mrController.getCommandURL(), aArgs );
}
-
void SvxLineEndWindow::FillValueSet()
{
if( mpLineEndList.is() )
@@ -402,13 +411,8 @@ void SvxLineEndWindow::FillValueSet()
}
}
-void SvxLineEndWindow::StartSelection()
-{
- mpLineEndSet->StartSelection();
-}
-
-
void SvxLineEndWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent )
+ throw ( css::uno::RuntimeException, std::exception )
{
if ( rEvent.FeatureURL.Complete == ".uno:LineEndListState" )
{
@@ -449,46 +453,68 @@ void SvxLineEndWindow::SetSize()
void SvxLineEndWindow::GetFocus()
{
- SfxPopupWindow::GetFocus();
- // Grab the focus to the line ends value set so that it can be controlled
- // with the keyboard.
if ( mpLineEndSet )
+ {
mpLineEndSet->GrabFocus();
+ mpLineEndSet->StartSelection();
+ }
}
-SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) :
- SfxToolBoxControl( nSlotId, nId, rTbx )
+class SvxLineEndToolBoxControl : public svt::PopupWindowController
{
- rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits( nId ) );
- rTbx.Invalidate();
-}
+public:
+ explicit SvxLineEndToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
+ // XInitialization
+ virtual void SAL_CALL initialize( const css::uno::Sequence<css::uno::Any>& rArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception ) override;
-SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl()
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw ( css::uno::RuntimeException, std::exception ) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw ( css::uno::RuntimeException, std::exception ) override;
+
+private:
+ virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
+ using svt::ToolboxController::createPopupWindow;
+};
+
+SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext )
+ : svt::PopupWindowController( rContext, nullptr, OUString() )
{
}
+void SvxLineEndToolBoxControl::initialize( const css::uno::Sequence<css::uno::Any>& rArguments )
+ throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
+{
+ svt::PopupWindowController::initialize( rArguments );
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ if ( getToolboxId( nId, &pToolBox ) )
+ pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
+}
-VclPtr<SfxPopupWindow> SvxLineEndToolBoxControl::CreatePopupWindow()
+VclPtr<vcl::Window> SvxLineEndToolBoxControl::createPopupWindow( vcl::Window* pParent )
{
- VclPtrInstance<SvxLineEndWindow> pLineEndWin( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) );
- pLineEndWin->StartPopupMode( &GetToolBox(),
- FloatWinPopupFlags::GrabFocus |
- FloatWinPopupFlags::AllowTearOff |
- FloatWinPopupFlags::NoAppFocusClose );
- pLineEndWin->StartSelection();
- SetPopupWindow( pLineEndWin );
- return pLineEndWin;
+ return VclPtr<SvxLineEndWindow>::Create( *this, pParent );
}
+OUString SvxLineEndToolBoxControl::getImplementationName()
+ throw ( css::uno::RuntimeException, std::exception )
+{
+ return OUString( "com.sun.star.comp.svx.LineEndToolBoxControl" );
+}
-void SvxLineEndToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* )
+css::uno::Sequence<OUString> SvxLineEndToolBoxControl::getSupportedServiceNames()
+ throw ( css::uno::RuntimeException, std::exception )
{
- sal_uInt16 nId = GetId();
- ToolBox& rTbx = GetToolBox();
+ return { "com.sun.star.frame.ToolbarController" };
+}
- rTbx.EnableItem( nId, SfxItemState::DISABLED != eState );
- rTbx.SetItemState( nId, ( SfxItemState::DONTCARE == eState ) ? TRISTATE_INDET : TRISTATE_FALSE );
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_svx_LineEndToolBoxControl_get_implementation(
+ css::uno::XComponentContext* rContext,
+ css::uno::Sequence<css::uno::Any> const & )
+{
+ return cppu::acquire( new SvxLineEndToolBoxControl( rContext ) );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/util/svx.component b/svx/util/svx.component
index eeecf60080ac..bc5bbb2a04d6 100644
--- a/svx/util/svx.component
+++ b/svx/util/svx.component
@@ -100,4 +100,8 @@
constructor="com_sun_star_comp_svx_SmartTagMenuController_get_implementation">
<service name="com.sun.star.frame.PopupMenuController"/>
</implementation>
+ <implementation name="com.sun.star.comp.svx.LineEndToolBoxControl"
+ constructor="com_sun_star_comp_svx_LineEndToolBoxControl_get_implementation">
+ <service name="com.sun.star.frame.ToolbarController"/>
+ </implementation>
</component>
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index de6a73848e96..bd574866f7f9 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -309,7 +309,6 @@ void SwDLL::RegisterControls()
SvxLineStyleToolBoxControl::RegisterControl(SID_ATTR_LINE_STYLE, pMod );
SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
SvxColorToolBoxControl::RegisterControl(SID_ATTR_LINE_COLOR, pMod );
- SvxLineEndToolBoxControl::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod );
SvxColorToolBoxControl::RegisterControl(SID_ATTR_FILL_COLOR, pMod);
SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_BACK_COLOR, pMod);