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_COLOR_BACKGROUND
60  and SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
61 
62  for paragraph background color (writer)
63  and cell background color (calc)
64  Execute-Id SID_BACKGROUND_COLOR
65 
66  for table/cell border color (writer, calc)
67  Execute-Id SID_FRAME_LINECOLOR
68 
69  for 3D extrusion
70  Execute-Id SID_EXTRUSION_3D_COLOR
71 
72  for line color
73  Execute-Id SID_ATTR_LINE_COLOR
74 
75  for area fill color
76  Execute-Id SID_ATTR_FILL_COLOR
77 
78  SvxPatternToolBoxControl
79  ------------------------
80  Item type: SvxBrushItem
81  Execute-Id: SID_BACKGROUND_PATTERN
82  -> SvxBrushItem
83  Additional information
84  from DocShell: presently none
85  in future: color palette
86  Note: Analysis of BrushItem:
87  Brush-FillColor() is misused as switch,
88  to distinguish whether a new style
89  or a new color has been set
90 
91  GetFillColor() == COL_BLACK -> GetStyle() ,
92  GetFillColor() == COL_WHITE -> GetColor()
93 
94  SvxFrameToolBoxControl
95  ----------------------
96  Item type: SvxBoxItem
97  Execute-Id: SID_ATTR_BORDER
98  -> SvxBoxItem & SvxBoxInfoItem
99  Additional information
100  from DocShell: none
101  Note: provides, depending on chosen ValueSet-Item,
102  only SvxBoxItem or additionally SvxBoxInfoItem
103  If the Controller in SfxUInt16Item receives a
104  value != 0, paragraph mode will be switched on,
105  i.e. the last line will be hidden.
106  A value == 0 switches again to Table mode.
107 
108  SvxFrameLineStyleToolBoxControl
109  -------------------------------
110  Item type: SvxLineItem
111  Execute-Id: SID_FRAME_LINESTYLE
112  -> SvxLineItem
113  Additional information
114  from DocShell: none
115  Note: provides a SvxLineItem, which provides a SvxBorderLine
116  without color information.
117 
118  SvxStyleToolBoxControl
119  ----------------------
120  Item type: SfxTemplateItem
121  Execute-Id: SID_TEMPLATE_APPLY
122  -> StyleName (SfxStringItem)
123  -> eStyleFamily (SfxUInt16Item)
124  Additional information
125  from DocShell: none
126  Note: Switch family by Invalidate
127  at the Bindings (->SfxStyleControllerItem)
128 
129 \*--------------------------------------------------------------*/
130 
131 // ITEMID_... defines in the *.cxx
132 
133 #include <config_options.h>
134 #include <svl/style.hxx>
135 #include <svx/svxdllapi.h>
136 #include <com/sun/star/frame/XSubToolbarController.hpp>
138 #include <svx/colorwindow.hxx>
139 #include <memory>
140 
141 // important in the tbxctrls.hxx created with HeDaBu !!!
142 class SvxLineItem;
143 class SvxBoxInfoItem;
144 class SvxFontItem;
147 class SfxTemplateItem;
148 class PaletteManager;
149 
150 namespace svx
151 {
152  class ToolboxButtonColorUpdaterBase;
153 }
154 
155 class SvxStyleToolBoxControl final : public cppu::ImplInheritanceHelper<svt::ToolboxController,
156  css::lang::XServiceInfo>
157 {
158  struct Impl;
159  std::unique_ptr<Impl> pImpl;
160 
161 public:
163  virtual ~SvxStyleToolBoxControl() override;
164 
165  // XStatusListener
166  virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
167 
168  // XToolbarController
169  virtual css::uno::Reference<css::awt::XWindow> SAL_CALL createItemWindow(const css::uno::Reference<css::awt::XWindow>& rParent) override;
170 
171  // XInitialization
172  virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override;
173 
174  // XUpdatable
175  virtual void SAL_CALL update() override;
176 
177  // XComponent
178  virtual void SAL_CALL dispose() override;
179 
180  // XServiceInfo
181  virtual OUString SAL_CALL getImplementationName() override;
182  virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
183  virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
184 
185 private:
186 #define MAX_FAMILIES 5
187 
190  css::uno::Reference<css::lang::XComponent> m_xBoundItems[MAX_FAMILIES];
191  std::unique_ptr<SfxTemplateItem> pFamilyState[MAX_FAMILIES];
192  sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
193 
194  void Update();
195  void FillStyleBox();
196  void SelectStyle(const OUString& rStyleName);
197 
199 
200  void SetFamilyState(sal_uInt16 nIdx, const SfxTemplateItem* pItem);
202 };
203 
204 typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction;
205 
206 class SVXCORE_DLLPUBLIC SvxColorToolBoxControl final : public cppu::ImplInheritanceHelper< svt::PopupWindowController,
207  css::frame::XSubToolbarController >
208 {
209  std::unique_ptr<svx::ToolboxButtonColorUpdaterBase> m_xBtnUpdater;
210  std::shared_ptr<PaletteManager> m_xPaletteManager;
213  sal_uInt16 m_nSlotId;
215  DECL_LINK(SelectedHdl, const NamedColor&, void);
216 
217 public:
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 
250 class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SvxCurrencyToolBoxControl final : public svt::PopupWindowController
251 {
252 private:
253  OUString m_aFormatString;
254  LanguageType m_eLanguage;
255  sal_uInt32 m_nFormatKey;
256 
257 public:
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::pair< Color, OUString > NamedColor
Definition: Palette.hxx:29
bool update()
virtual OUString SAL_CALL getImplementationName() override=0
std::function< void(const OUString &, const NamedColor &)> ColorSelectFunction
Definition: tbcontrl.hxx:204
std::unique_ptr< SfxTemplateItem > pFamilyState[MAX_FAMILIES]
Definition: tbcontrl.hxx:191
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
void SetFamilyState(sal_uInt16 nIdx, const SfxTemplateItem *pItem)
Definition: tbcontrl.cxx:2933
virtual void SAL_CALL update() override
Definition: tbcontrl.cxx:2735
SfxStyleControllerItem_Impl * pBoundItems[MAX_FAMILIES]
Definition: tbcontrl.hxx:189
std::unique_ptr< Impl > pImpl
Definition: tbcontrl.hxx:158
virtual OUString SAL_CALL getImplementationName() override
Definition: tbcontrl.cxx:2712
#define MAX_FAMILIES
Definition: tbcontrl.hxx:186
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: tbcontrl.hxx:210
virtual void SAL_CALL dispose() override
Definition: tbcontrl.cxx:2674
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: tbcontrl.cxx:2717
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(const css::uno::Reference< css::awt::XWindow > &rParent) override
Definition: tbcontrl.cxx:2959
SfxStyleFamily
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: tbcontrl.cxx:2722
::sal_Int32 m_nFormatKey
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow()
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: tbcontrl.cxx:2651
ColorStatus m_aColorStatus
Definition: tbcontrl.hxx:211
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent)=0
unsigned char sal_Bool
SfxStyleFamily GetActFamily() const
Definition: tbcontrl.cxx:2742
ColorSelectFunction m_aColorSelectFunction
Definition: tbcontrl.hxx:214
std::unique_ptr< svx::ToolboxButtonColorUpdaterBase > m_xBtnUpdater
Definition: tbcontrl.hxx:209
void SelectStyle(const OUString &rStyleName)
Definition: tbcontrl.cxx:2860
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
virtual ~SvxStyleToolBoxControl() override
Definition: tbcontrl.cxx:2647
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
SfxStyleSheetBasePool * pStyleSheetPool
Definition: tbcontrl.hxx:188
std::function< void(const OUString &, const NamedColor &)> ColorSelectFunction
Definition: Palette.hxx:33
css::uno::Reference< css::lang::XComponent > m_xBoundItems[MAX_FAMILIES]
Definition: tbcontrl.hxx:190
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
Definition: tbcontrl.cxx:2940