LibreOffice Module sfx2 (master) 1
tbxctrl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SFX2_TBXCTRL_HXX
20#define INCLUDED_SFX2_TBXCTRL_HXX
21
22#include <memory>
23#include <sal/config.h>
24#include <sfx2/dllapi.h>
25#include <sal/types.h>
26#include <svl/poolitem.hxx>
28#include <rtl/ref.hxx>
29#include <vcl/vclptr.hxx>
30
32namespace com::sun::star::frame { class XFrame; }
33namespace vcl { class Window; }
34
37class SfxModule;
38
39rtl::Reference<svt::ToolboxController> SfxToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, ToolBoxItemId nID, const OUString& aCommandURL );
40
42
44{
46 const std::type_info& nTypeId;
47 sal_uInt16 nSlotId;
48
50 const std::type_info& nTheTypeId, sal_uInt16 nTheSlotId ):
51 pCtor(pTheCtor),
52 nTypeId(nTheTypeId),
53 nSlotId(nTheSlotId)
54 {}
55};
56
57
58#define SFX_DECL_TOOLBOX_CONTROL() \
59 static rtl::Reference<SfxToolBoxControl> CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ); \
60 static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr)
61
62/* For special ToolBox controls, such as a font selection box or toolbox
63 tear-off floating windows, an appropriate Item-Subclass of SfxTooBoxControl
64 has to be implemented.
65
66 This class has to be registered in SfxApplication:Init() with the static
67 control method RegisterControl(). The SFx then automatically creates these
68 controls in the toolbox, if the associated slots are of the specific type.
69 */
70
73{
74friend struct SfxTbxCtrlFactory;
75
76 std::unique_ptr< SfxToolBoxControl_Impl> pImpl;
77
78protected:
79 // old SfxToolBoxControl methods
80 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
81 virtual void Select( sal_uInt16 nSelectModifier );
82
83 virtual void DoubleClick();
84 virtual void Click();
85 virtual void CreatePopupWindow();
86 virtual VclPtr<InterimItemWindow> CreateItemWindow(vcl::Window *pParent);
87
88public:
89 // XComponent
90 virtual void SAL_CALL dispose() override;
91
92 // new controller API
93 // XStatusListener
94 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
95
96 // XToolbarController
97 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override;
98 virtual void SAL_CALL click() override;
99 virtual void SAL_CALL doubleClick() override;
100 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override;
101 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) override;
102
103public:
105
106 SfxToolBoxControl( sal_uInt16 nSlotID, ToolBoxItemId nId, ToolBox& rBox, bool bShowStrings = false );
107 virtual ~SfxToolBoxControl() override;
108
109 ToolBox& GetToolBox() const;
110 ToolBoxItemId GetId() const;
111 unsigned short GetSlotId() const;
112
113 void Dispatch( const OUString& aCommand,
114 css::uno::Sequence< css::beans::PropertyValue > const & aArgs );
115 static void Dispatch( const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider,
116 const OUString& rCommand,
117 css::uno::Sequence< css::beans::PropertyValue > const & aArgs );
118
119 static SfxItemState GetItemState( const SfxPoolItem* pState );
120 static rtl::Reference<SfxToolBoxControl> CreateControl( sal_uInt16 nSlotId, ToolBoxItemId nTbxId, ToolBox *pBox, SfxModule const *pMod );
121 static void RegisterToolBoxControl( SfxModule*, const SfxTbxCtrlFactory&);
122};
123
124#define SFX_IMPL_TOOLBOX_CONTROL(Class, nItemClass) \
125 rtl::Reference<SfxToolBoxControl> Class::CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ) \
126 { return new Class( nSlotId, nId, rTbx ); } \
127 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
128 { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \
129 Class::CreateImpl, typeid(nItemClass), nSlotId ) ); }
130
131#define SFX_IMPL_TOOLBOX_CONTROL_ARG(Class, nItemClass, Arg) \
132 rtl::Reference<SfxToolBoxControl> Class::CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ) \
133 { return new Class( nSlotId, nId, rTbx, Arg); } \
134 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
135 { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \
136 Class::CreateImpl, typeid(nItemClass), nSlotId ) ); }
137
138
139#endif
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< SfxToolBoxControl_Impl > pImpl
Definition: tbxctrl.hxx:76
static void Dispatch(const css::uno::Reference< css::frame::XDispatchProvider > &rDispatchProvider, const OUString &rCommand, css::uno::Sequence< css::beans::PropertyValue > const &aArgs)
virtual void SAL_CALL dispose() override
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(const css::uno::Reference< css::awt::XWindow > &Parent) override
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &Event) override=0
virtual void SAL_CALL execute(sal_Int16 KeyModifier) override
virtual void SAL_CALL click() override
virtual void SAL_CALL doubleClick() override
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override
virtual sal_uInt32 GetId() const override
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
sal_Int16 nId
SfxItemState
SfxTbxCtrlFactory(SfxToolBoxControlCtor pTheCtor, const std::type_info &nTheTypeId, sal_uInt16 nTheSlotId)
Definition: tbxctrl.hxx:49
sal_uInt16 nSlotId
Definition: tbxctrl.hxx:47
SfxToolBoxControlCtor pCtor
Definition: tbxctrl.hxx:45
const std::type_info & nTypeId
Definition: tbxctrl.hxx:46
rtl::Reference< SfxToolBoxControl >(* SfxToolBoxControlCtor)(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rBox)
Definition: tbxctrl.hxx:41
rtl::Reference< svt::ToolboxController > SfxToolBoxControllerFactory(const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBox *pToolbox, ToolBoxItemId nID, const OUString &aCommandURL)