rework SfxEmojiControl to be a PopupWindowController

Change-Id: Ia3262e5b54257d5556c500f440806ac2df9886cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86794
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2020-01-14 17:17:35 +00:00
parent 22bf6e3234
commit e5701af7c4
10 changed files with 65 additions and 32 deletions

View file

@ -22,7 +22,6 @@
#include <sal/config.h>
#include <sfx2/dllapi.h>
#include <sfx2/tbxctrl.hxx>
#include <sfx2/charwin.hxx>
#include <svtools/toolbarmenu.hxx>
#include <deque>

View file

@ -13,21 +13,21 @@
#include <sal/config.h>
#include <sfx2/dllapi.h>
#include <vcl/tabctrl.hxx>
#include <sfx2/tbxctrl.hxx>
#include <svtools/toolbarmenu.hxx>
#define TAB_FONT_SIZE 15
namespace com::sun::star::frame { class XFrame; }
class EmojiPopup;
class EmojiView;
class ThumbnailViewItem;
enum class FILTER_CATEGORY;
class SfxEmojiControl final : public SfxPopupWindow
class SfxEmojiControl final : public svtools::ToolbarPopup
{
public:
explicit SfxEmojiControl(sal_uInt16 nId, vcl::Window* pParent,
const css::uno::Reference< css::frame::XFrame >& rFrame);
explicit SfxEmojiControl(EmojiPopup* pControl, vcl::Window* pParent);
virtual ~SfxEmojiControl() override;

View file

@ -20,18 +20,24 @@
#ifndef INCLUDED_SFX2_INC_EMOJIPOPUP_HXX
#define INCLUDED_SFX2_INC_EMOJIPOPUP_HXX
#include <sfx2/tbxctrl.hxx>
#include <svtools/popupwindowcontroller.hxx>
#include <sfx2/dllapi.h>
class SFX2_DLLPUBLIC EmojiPopup final : public SfxToolBoxControl
class SFX2_DLLPUBLIC EmojiPopup final : public svt::PopupWindowController
{
public:
SFX_DECL_TOOLBOX_CONTROL();
EmojiPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
EmojiPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext);
virtual ~EmojiPopup() override;
virtual VclPtr<SfxPopupWindow> CreatePopupWindow() 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
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override;
};
#endif

View file

@ -1360,6 +1360,17 @@
<value>com.sun.star.comp.svx.CharacterSpacingToolBoxControl</value>
</prop>
</node>
<node oor:name="InsertEmojiToolBoxControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:EmojiControl</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.sfx2.InsertEmojiToolBoxControl</value>
</prop>
</node>
<node oor:name="InsertSymbolToolBoxControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:CharmapControl</value>

View file

@ -172,8 +172,6 @@ void ScDLL::Init()
SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod);
SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod);
EmojiPopup::RegisterControl(SID_EMOJI_CONTROL, pMod );
// Media Controller
#if HAVE_FEATURE_AVMEDIA
::avmedia::MediaToolBoxControl::RegisterControl( SID_AVMEDIA_TOOLBOX, pMod );

View file

@ -221,8 +221,6 @@ void SdDLL::RegisterControllers(SdModule* pMod)
XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
SdTemplateControl::RegisterControl( SID_STATUS_LAYOUT, pMod );
SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
EmojiPopup::RegisterControl(SID_EMOJI_CONTROL, pMod );
}
void SdDLL::Init()

View file

@ -17,8 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sfx2/emojiview.hxx>
#include <sfx2/emojicontrol.hxx>
#include <sfx2/emojipopup.hxx>
#include <sfx2/emojiview.hxx>
#include <sfx2/thumbnailviewitem.hxx>
#include <vcl/tabpage.hxx>
#include <comphelper/propertysequence.hxx>
@ -37,8 +38,8 @@ const char FILTER_UNICODE9[] = "unicode9";
using namespace com::sun::star;
SfxEmojiControl::SfxEmojiControl(sal_uInt16 nId, vcl::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rFrame)
: SfxPopupWindow(nId, pParent, "emojictrl", "sfx/ui/emojicontrol.ui", rFrame)
SfxEmojiControl::SfxEmojiControl(EmojiPopup* pControl, vcl::Window* pParent)
: ToolbarPopup(pControl->getFrameInterface(), pParent, "emojictrl", "sfx/ui/emojicontrol.ui")
{
get(mpTabControl, "tabcontrol");
get(mpEmojiView, "emoji_view");
@ -111,13 +112,12 @@ SfxEmojiControl::~SfxEmojiControl()
disposeOnce();
}
void SfxEmojiControl::dispose()
{
mpTabControl.clear();
mpEmojiView.clear();
SfxPopupWindow::dispose();
ToolbarPopup::dispose();
}
void SfxEmojiControl::ConvertLabelToUnicode(sal_uInt16 nPageId)

View file

@ -20,27 +20,46 @@
#include <sfx2/emojicontrol.hxx>
#include <vcl/toolbox.hxx>
SFX_IMPL_TOOLBOX_CONTROL(EmojiPopup, SfxVoidItem);
EmojiPopup::EmojiPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
: SfxToolBoxControl(nSlotId, nId, rTbx)
EmojiPopup::EmojiPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext)
: PopupWindowController(rContext, nullptr, OUString())
{
rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits(nId));
}
void EmojiPopup::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
{
PopupWindowController::initialize(rArguments);
ToolBox* pToolBox = nullptr;
sal_uInt16 nId = 0;
if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
}
EmojiPopup::~EmojiPopup()
{
}
VclPtr<SfxPopupWindow> EmojiPopup::CreatePopupWindow()
VclPtr<vcl::Window> EmojiPopup::createPopupWindow(vcl::Window* pParent)
{
VclPtr<SfxEmojiControl> pControl = VclPtr<SfxEmojiControl>::Create(GetSlotId(), &GetToolBox(), m_xFrame);
return VclPtr<SfxEmojiControl>::Create(this, pParent);
}
pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus);
OUString EmojiPopup::getImplementationName()
{
return "com.sun.star.comp.sfx2.InsertEmojiToolBoxControl";
}
SetPopupWindow(pControl);
css::uno::Sequence<OUString> EmojiPopup::getSupportedServiceNames()
{
return { "com.sun.star.frame.ToolbarController" };
}
return pControl;
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_sfx2_InsertEmojiToolBoxControl_get_implementation(
css::uno::XComponentContext* rContext,
css::uno::Sequence<css::uno::Any> const & )
{
return cppu::acquire(new EmojiPopup(rContext));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -86,6 +86,10 @@
constructor="com_sun_star_sfx2_ClassificationCategoriesController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.comp.sfx2.InsertEmojiToolBoxControl"
constructor="com_sun_star_comp_sfx2_InsertEmojiToolBoxControl_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.comp.sfx2.InsertSymbolToolBoxControl"
constructor="com_sun_star_comp_sfx2_InsertSymbolToolBoxControl_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>

View file

@ -309,8 +309,6 @@ void SwDLL::RegisterControls()
SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
EmojiPopup::RegisterControl(SID_EMOJI_CONTROL, pMod );
SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );