android: Update app-specific/MIME type icons
[LibreOffice.git] / include / svx / tbcontrl.hxx
blob11d41ee4ddde164435258b44b7f5feedfc86edad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_TBCONTRL_HXX
20 #define INCLUDED_SVX_TBCONTRL_HXX
22 /*--------------------------------------------------------------*\
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
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)
42 SvxColorToolBoxControl
43 ----------------------
44 Item type: SvxColorItem
45 SvxLineItem
46 SfxBoolItem
47 XLineColorItem
48 and XFillColorItem
50 for font color (writer, ...)
51 Execute-Id SID_ATTR_CHAR_COLOR2
52 and SID_ATTR_CHAR_COLOR_EXT
54 for font color
55 (calc/impress/draw and writer drawing objects)
56 Execute-Id SID_ATTR_CHAR_COLOR
58 for character background color (writer)
59 Execute-Id SID_ATTR_CHAR_BACK_COLOR
61 for paragraph background color (writer)
62 and cell background color (calc)
63 Execute-Id SID_BACKGROUND_COLOR
65 for table/cell border color (writer, calc)
66 Execute-Id SID_FRAME_LINECOLOR
68 for 3D extrusion
69 Execute-Id SID_EXTRUSION_3D_COLOR
71 for line color
72 Execute-Id SID_ATTR_LINE_COLOR
74 for area fill color
75 Execute-Id SID_ATTR_FILL_COLOR
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
90 GetFillColor() == COL_BLACK -> GetStyle() ,
91 GetFillColor() == COL_WHITE -> GetColor()
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.
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.
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)
128 \*--------------------------------------------------------------*/
130 // ITEMID_... defines in the *.cxx
132 #include <config_options.h>
133 #include <svl/style.hxx>
134 #include <svx/svxdllapi.h>
135 #include <com/sun/star/frame/XSubToolbarController.hpp>
136 #include <svtools/popupwindowcontroller.hxx>
137 #include <svx/colorwindow.hxx>
138 #include <memory>
140 // important in the tbxctrls.hxx created with HeDaBu !!!
141 class SvxLineItem;
142 class SvxBoxInfoItem;
143 class SvxFontItem;
144 class SfxStyleControllerItem_Impl;
145 class SfxStyleSheetBasePool;
146 class SfxTemplateItem;
147 class PaletteManager;
149 namespace svx
151 class ToolboxButtonColorUpdaterBase;
154 class SvxStyleToolBoxControl final : public cppu::ImplInheritanceHelper<svt::ToolboxController,
155 css::lang::XServiceInfo>
157 struct Impl;
158 std::unique_ptr<Impl> pImpl;
160 public:
161 SvxStyleToolBoxControl();
162 virtual ~SvxStyleToolBoxControl() override;
164 // XStatusListener
165 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
167 // XToolbarController
168 virtual css::uno::Reference<css::awt::XWindow> SAL_CALL createItemWindow(const css::uno::Reference<css::awt::XWindow>& rParent) override;
170 // XInitialization
171 virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override;
173 // XUpdatable
174 virtual void SAL_CALL update() override;
176 // XComponent
177 virtual void SAL_CALL dispose() override;
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;
184 private:
185 #define MAX_FAMILIES 5
187 SfxStyleSheetBasePool* pStyleSheetPool;
188 rtl::Reference<SfxStyleControllerItem_Impl> m_xBoundItems[MAX_FAMILIES];
189 std::unique_ptr<SfxTemplateItem> pFamilyState[MAX_FAMILIES];
190 sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
192 void Update();
193 void FillStyleBox();
194 void SelectStyle(const OUString& rStyleName);
196 friend class SfxStyleControllerItem_Impl;
198 void SetFamilyState(sal_uInt16 nIdx, const SfxTemplateItem* pItem);
199 SfxStyleFamily GetActFamily() const;
202 typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction;
204 class SVXCORE_DLLPUBLIC SvxColorToolBoxControl final : public cppu::ImplInheritanceHelper< svt::PopupWindowController,
205 css::frame::XSubToolbarController >
207 std::unique_ptr<svx::ToolboxButtonColorUpdaterBase> m_xBtnUpdater;
208 std::shared_ptr<PaletteManager> m_xPaletteManager;
209 ColorStatus m_aColorStatus;
210 bool m_bSplitButton;
211 sal_uInt16 m_nSlotId;
212 ColorSelectFunction m_aColorSelectFunction;
214 weld::Window* GetParentFrame() const;
216 public:
217 explicit SvxColorToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
218 virtual ~SvxColorToolBoxControl() override;
220 // XInitialization
221 virtual void SAL_CALL initialize( const css::uno::Sequence<css::uno::Any>& rArguments ) override;
223 // XUpdatable
224 virtual void SAL_CALL update() override;
226 // XStatusListener
227 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
229 // XToolbarController
230 virtual void SAL_CALL execute( sal_Int16 nSelectModifier ) override;
232 virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
233 virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
235 // XSubToolbarController
236 virtual sal_Bool SAL_CALL opensSubToolbar() override;
237 virtual OUString SAL_CALL getSubToolbarName() override;
238 virtual void SAL_CALL functionSelected( const OUString& rCommand ) override;
239 virtual void SAL_CALL updateImage() override;
241 // XServiceInfo
242 virtual OUString SAL_CALL getImplementationName() override;
243 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
245 void setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction);
246 void EnsurePaletteManager();
249 /** Popup controller for currency combo widget **/
250 class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SvxCurrencyToolBoxControl final : public svt::PopupWindowController
252 public:
254 * Struct containing currency data<p>
255 * an instance corresponds to a line in the combo
257 struct SvxCurrencyData {
258 /** position of the currency in SvxCurrencyToolBoxControl::CurrencySymbols vector **/
259 sal_uInt16 m_currencyIdx;
262 * False if the instance corresponds to a line of the combo that shows only the ISO code<p>
263 * True otherwise
265 bool m_onlyIsoCode;
266 OUString m_label;
268 /** Constant for invalid currency **/
269 static const sal_uInt16 InvalidCurrency;
272 * Constructor
274 * @param currencyIdx Position of the currency in SvxCurrencyToolBoxControl::CurrencySymbols vector
275 * @param onlyIsoCode False if the instance corresponds to a line of the combo that shows
276 * only the ISO code<p> True otherwise
278 SvxCurrencyData(
279 sal_uInt16 currencyIdx = InvalidCurrency,
280 bool onlyIsoCode = false
283 /** Needed by std::find **/
284 bool operator == (const SvxCurrencyData& other) const;
287 /** vector of combo box currencies **/
288 typedef std::vector<SvxCurrencyData> SvxCurrencyVect_t;
290 private:
291 OUString m_aFormatString;
292 LanguageType m_eLanguage;
293 sal_uInt32 m_nFormatKey;
295 /** Currencies in the combo **/
296 SvxCurrencyVect_t m_currencies;
299 /** Most recently used currencies **/
300 SvxCurrencyVect_t m_mru_currencies;
302 /** Adds a currency to the most recently used list **/
303 void addMruCurrency(sal_Int16 currencyPosition);
306 * Inner static method that polialtes the currency list and the most recently used
307 * currency list.<p>
308 * The method is static for backward compatibility: it is used by the two
309 * homonymous public methods, one of which is static while the other is instance
311 * @param bFlag used by SvxNumberFormatShell::GetCurrencySymbols
312 * @param p_mru_currencies output: most recently used currencies
313 * @param pCurrencies output: most recently used currencies
314 * @see SvxNumberFormatShell::GetCurrencySymbols
316 static void inner_GetCurrencySymbols( bool bFlag, SvxCurrencyVect_t &p_mru_currencies,
317 SvxCurrencyVect_t &pCurrencies);
319 public:
321 * Static method used by SvxNumberFormatShell::GetCurrencySymbols<p>
323 * @param rList output: labels in the combo box
324 * @param bFlag input: true means that we add the default currency in the combox
325 * @param rCurrencyList output: list of the currency positions in SvxCurrencyToolBoxControl::CurrencySymbols vector
326 * @see SvxNumberFormatShell::GetCurrencySymbols
328 static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag,
329 std::vector<sal_uInt16>& rCurrencyList );
331 /** Instance method used by SvxCurrencyList_Impl constructor **/
332 const SvxCurrencyVect_t& GetCurrencySymbols();
334 explicit SvxCurrencyToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
335 virtual ~SvxCurrencyToolBoxControl() override;
337 /** XToolbarController **/
338 virtual void SAL_CALL execute( sal_Int16 nSelectModifier ) override;
340 virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
341 virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
343 /** XServiceInfo **/
344 virtual OUString SAL_CALL getImplementationName() override;
345 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
347 /** XInitialization **/
348 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override;
351 #endif // INCLUDED_SVX_TBCONTRL_HXX
353 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */