LibreOffice Module svx (master) 1
tbcontrl.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_SVX_TBCONTRL_HXX
20#define INCLUDED_SVX_TBCONTRL_HXX
21
22/*--------------------------------------------------------------*\
23
24 Description:
25 -------------
26 ToolBox-Controller for:
27 Font-Name, Font-Height, Font-Color
28 Fore-/Background color /-patterns
29 Frames, Lines
30 (indentation-)templates
31
32 Use:
33 ----------
34 SvxFontNameToolBoxControl
35 -------------------------
36 Item type: SvxFontItem
37 Execute-Id: SID_ATTR_CHAR_FONT
38 -> SvxFontItem
39 Additional information
40 from DocShell: SvxFontListItem (SID_ATTR_CHAR_FONTLIST)
41
42 SvxColorToolBoxControl
43 ----------------------
44 Item type: SvxColorItem
45 SvxLineItem
46 SfxBoolItem
47 XLineColorItem
48 and XFillColorItem
49
50 for font color (writer, ...)
51 Execute-Id SID_ATTR_CHAR_COLOR2
52 and SID_ATTR_CHAR_COLOR_EXT
53
54 for font color
55 (calc/impress/draw and writer drawing objects)
56 Execute-Id SID_ATTR_CHAR_COLOR
57
58 for character background color (writer)
59 Execute-Id SID_ATTR_CHAR_BACK_COLOR
60
61 for paragraph background color (writer)
62 and cell background color (calc)
63 Execute-Id SID_BACKGROUND_COLOR
64
65 for table/cell border color (writer, calc)
66 Execute-Id SID_FRAME_LINECOLOR
67
68 for 3D extrusion
69 Execute-Id SID_EXTRUSION_3D_COLOR
70
71 for line color
72 Execute-Id SID_ATTR_LINE_COLOR
73
74 for area fill color
75 Execute-Id SID_ATTR_FILL_COLOR
76
77 SvxPatternToolBoxControl
78 ------------------------
79 Item type: SvxBrushItem
80 Execute-Id: SID_BACKGROUND_PATTERN
81 -> SvxBrushItem
82 Additional information
83 from DocShell: presently none
84 in future: color palette
85 Note: Analysis of BrushItem:
86 Brush-FillColor() is misused as switch,
87 to distinguish whether a new style
88 or a new color has been set
89
90 GetFillColor() == COL_BLACK -> GetStyle() ,
91 GetFillColor() == COL_WHITE -> GetColor()
92
93 SvxFrameToolBoxControl
94 ----------------------
95 Item type: SvxBoxItem
96 Execute-Id: SID_ATTR_BORDER
97 -> SvxBoxItem & SvxBoxInfoItem
98 Additional information
99 from DocShell: none
100 Note: provides, depending on chosen ValueSet-Item,
101 only SvxBoxItem or additionally SvxBoxInfoItem
102 If the Controller in SfxUInt16Item receives a
103 value != 0, paragraph mode will be switched on,
104 i.e. the last line will be hidden.
105 A value == 0 switches again to Table mode.
106
107 SvxFrameLineStyleToolBoxControl
108 -------------------------------
109 Item type: SvxLineItem
110 Execute-Id: SID_FRAME_LINESTYLE
111 -> SvxLineItem
112 Additional information
113 from DocShell: none
114 Note: provides a SvxLineItem, which provides a SvxBorderLine
115 without color information.
116
117 SvxStyleToolBoxControl
118 ----------------------
119 Item type: SfxTemplateItem
120 Execute-Id: SID_TEMPLATE_APPLY
121 -> StyleName (SfxStringItem)
122 -> eStyleFamily (SfxUInt16Item)
123 Additional information
124 from DocShell: none
125 Note: Switch family by Invalidate
126 at the Bindings (->SfxStyleControllerItem)
127
128\*--------------------------------------------------------------*/
129
130// ITEMID_... defines in the *.cxx
131
132#include <config_options.h>
133#include <svl/style.hxx>
134#include <svx/svxdllapi.h>
135#include <com/sun/star/frame/XSubToolbarController.hpp>
137#include <svx/colorwindow.hxx>
138#include <memory>
139
140// important in the tbxctrls.hxx created with HeDaBu !!!
141class SvxLineItem;
142class SvxBoxInfoItem;
143class SvxFontItem;
146class SfxTemplateItem;
147class PaletteManager;
148
149namespace svx
150{
151 class ToolboxButtonColorUpdaterBase;
152}
153
154class SvxStyleToolBoxControl final : public cppu::ImplInheritanceHelper<svt::ToolboxController,
155 css::lang::XServiceInfo>
156{
157 struct Impl;
158 std::unique_ptr<Impl> pImpl;
159
160public:
162 virtual ~SvxStyleToolBoxControl() override;
163
164 // XStatusListener
165 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
166
167 // XToolbarController
168 virtual css::uno::Reference<css::awt::XWindow> SAL_CALL createItemWindow(const css::uno::Reference<css::awt::XWindow>& rParent) override;
169
170 // XInitialization
171 virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override;
172
173 // XUpdatable
174 virtual void SAL_CALL update() override;
175
176 // XComponent
177 virtual void SAL_CALL dispose() override;
178
179 // XServiceInfo
180 virtual OUString SAL_CALL getImplementationName() override;
181 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
182 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
183
184private:
185#define MAX_FAMILIES 5
186
189 std::unique_ptr<SfxTemplateItem> pFamilyState[MAX_FAMILIES];
190 sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
191
192 void Update();
193 void FillStyleBox();
194 void SelectStyle(const OUString& rStyleName);
195
197
198 void SetFamilyState(sal_uInt16 nIdx, const SfxTemplateItem* pItem);
200};
201
202typedef std::function<void(const OUString&, const svx::NamedThemedColor&)> ColorSelectFunction;
203
204class SVXCORE_DLLPUBLIC SvxColorToolBoxControl final : public cppu::ImplInheritanceHelper< svt::PopupWindowController,
205 css::frame::XSubToolbarController >
206{
207 std::unique_ptr<svx::ToolboxButtonColorUpdaterBase> m_xBtnUpdater;
208 std::shared_ptr<PaletteManager> m_xPaletteManager;
211 sal_uInt16 m_nSlotId;
213 DECL_DLLPRIVATE_LINK(SelectedHdl, const NamedColor&, void);
214
215 weld::Window* GetParentFrame() const;
216
217public:
218 explicit SvxColorToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
219 virtual ~SvxColorToolBoxControl() override;
220
221 // XInitialization
222 virtual void SAL_CALL initialize( const css::uno::Sequence<css::uno::Any>& rArguments ) override;
223
224 // XUpdatable
225 virtual void SAL_CALL update() override;
226
227 // XStatusListener
228 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
229
230 // XToolbarController
231 virtual void SAL_CALL execute( sal_Int16 nSelectModifier ) override;
232
233 virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
234 virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
235
236 // XSubToolbarController
237 virtual sal_Bool SAL_CALL opensSubToolbar() override;
238 virtual OUString SAL_CALL getSubToolbarName() override;
239 virtual void SAL_CALL functionSelected( const OUString& rCommand ) override;
240 virtual void SAL_CALL updateImage() override;
241
242 // XServiceInfo
243 virtual OUString SAL_CALL getImplementationName() override;
244 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
245
246 void setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction);
247 void EnsurePaletteManager();
248};
249
250class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SvxCurrencyToolBoxControl final : public svt::PopupWindowController
251{
252private:
253 OUString m_aFormatString;
254 LanguageType m_eLanguage;
255 sal_uInt32 m_nFormatKey;
256
257public:
258 static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag,
259 std::vector<sal_uInt16>& rCurrencyList );
260
261 explicit SvxCurrencyToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
262 virtual ~SvxCurrencyToolBoxControl() override;
263
264 // XToolbarController
265 virtual void SAL_CALL execute( sal_Int16 nSelectModifier ) override;
266
267 virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
268 virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
269
270 // XServiceInfo
271 virtual OUString SAL_CALL getImplementationName() override;
272 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
273
274 // XInitialization
275 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override;
276};
277
278#endif // INCLUDED_SVX_TBCONTRL_HXX
279
280/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::function< void(const OUString &, const svx::NamedThemedColor &)> ColorSelectFunction
Definition: Palette.hxx:51
std::pair< Color, OUString > NamedColor
Definition: Palette.hxx:30
DECL_DLLPRIVATE_LINK(SelectedHdl, const NamedColor &, void)
ColorStatus m_aColorStatus
Definition: tbcontrl.hxx:209
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: tbcontrl.hxx:208
std::unique_ptr< svx::ToolboxButtonColorUpdaterBase > m_xBtnUpdater
Definition: tbcontrl.hxx:207
ColorSelectFunction m_aColorSelectFunction
Definition: tbcontrl.hxx:212
rtl::Reference< SfxStyleControllerItem_Impl > m_xBoundItems[MAX_FAMILIES]
Definition: tbcontrl.hxx:188
virtual void SAL_CALL dispose() override
Definition: tbcontrl.cxx:3055
SfxStyleFamily GetActFamily() const
Definition: tbcontrl.cxx:3122
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(const css::uno::Reference< css::awt::XWindow > &rParent) override
Definition: tbcontrl.cxx:3318
void SetFamilyState(sal_uInt16 nIdx, const SfxTemplateItem *pItem)
Definition: tbcontrl.cxx:3292
void SelectStyle(const OUString &rStyleName)
Definition: tbcontrl.cxx:3219
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: tbcontrl.cxx:3102
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: tbcontrl.cxx:3033
std::unique_ptr< SfxTemplateItem > pFamilyState[MAX_FAMILIES]
Definition: tbcontrl.hxx:189
virtual void SAL_CALL update() override
Definition: tbcontrl.cxx:3115
virtual OUString SAL_CALL getImplementationName() override
Definition: tbcontrl.cxx:3092
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
Definition: tbcontrl.cxx:3299
virtual ~SvxStyleToolBoxControl() override
Definition: tbcontrl.cxx:3029
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: tbcontrl.cxx:3097
std::unique_ptr< Impl > pImpl
Definition: tbcontrl.hxx:157
SfxStyleSheetBasePool * pStyleSheetPool
Definition: tbcontrl.hxx:187
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow()=0
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent)
virtual OUString SAL_CALL getImplementationName() override=0
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
A color with an optional name and other theming-related properties.
Definition: Palette.hxx:38
SfxStyleFamily
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
std::function< void(const OUString &, const svx::NamedThemedColor &)> ColorSelectFunction
Definition: tbcontrl.hxx:202
#define MAX_FAMILIES
Definition: tbcontrl.hxx:185
unsigned char sal_Bool
bool update()