LibreOffice Module svx (master)  1
tbcontrl.cxx
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 
20 #include <utility>
21 
24 #include <tools/color.hxx>
25 #include <svl/numformat.hxx>
26 #include <svl/poolitem.hxx>
27 #include <svl/itemset.hxx>
29 #include <vcl/event.hxx>
30 #include <vcl/toolbox.hxx>
31 #include <vcl/customweld.hxx>
32 #include <vcl/vclptr.hxx>
33 #include <vcl/weldutils.hxx>
34 #include <svtools/valueset.hxx>
35 #include <svtools/ctrlbox.hxx>
36 #include <svl/style.hxx>
37 #include <svtools/ctrltool.hxx>
38 #include <svtools/borderhelper.hxx>
40 #include <sfx2/tbxctrl.hxx>
41 #include <sfx2/tplpitem.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <vcl/svapp.hxx>
46 #include <vcl/settings.hxx>
47 #include <vcl/virdev.hxx>
48 #include <com/sun/star/awt/FontDescriptor.hpp>
49 #include <com/sun/star/table/BorderLine2.hpp>
50 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <com/sun/star/beans/XPropertySet.hpp>
53 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
54 #include <com/sun/star/frame/XDispatchProvider.hpp>
55 #include <com/sun/star/frame/XFrame.hpp>
56 #include <svx/strings.hrc>
57 #include <svx/svxids.hrc>
58 #include <helpids.h>
59 #include <sfx2/sidebar/Sidebar.hxx>
60 #include <svx/xtable.hxx>
61 #include <editeng/editids.hrc>
62 #include <editeng/fontitem.hxx>
63 #include <editeng/fhgtitem.hxx>
64 #include <editeng/boxitem.hxx>
66 #include <editeng/contouritem.hxx>
67 #include <editeng/colritem.hxx>
70 #include <editeng/flstitem.hxx>
71 #include <editeng/lineitem.hxx>
72 #include <editeng/postitem.hxx>
73 #include <editeng/shdditem.hxx>
74 #include <editeng/udlnitem.hxx>
75 #include <editeng/wghtitem.hxx>
76 #include <editeng/svxfont.hxx>
77 #include <editeng/cmapitem.hxx>
78 #include <svx/colorwindow.hxx>
79 #include <svx/colorbox.hxx>
80 #include <svx/tbcontrl.hxx>
81 #include <svx/dialmgr.hxx>
82 #include <svx/PaletteManager.hxx>
83 #include <memory>
84 
85 #include <tbxcolorupdate.hxx>
86 #include <editeng/eerdll.hxx>
87 #include <editeng/editrids.hrc>
88 #include <svx/xdef.hxx>
89 #include <svx/xfillit0.hxx>
90 #include <svx/xflclit.hxx>
91 #include <svl/currencytable.hxx>
92 #include <svtools/langtab.hxx>
93 #include <cppu/unotype.hxx>
95 #include <officecfg/Office/Common.hxx>
96 #include <o3tl/safeint.hxx>
97 #include <o3tl/typed_flags_set.hxx>
98 #include <bitmaps.hlst>
99 #include <sal/log.hxx>
101 
102 #include <comphelper/lok.hxx>
103 #include <tools/json_writer.hxx>
104 
105 #define MAX_MRU_FONTNAME_ENTRIES 5
106 
107 #define COMBO_WIDTH_IN_CHARS 18
108 
109 // namespaces
110 using namespace ::editeng;
111 using namespace ::com::sun::star;
112 using namespace ::com::sun::star::uno;
113 using namespace ::com::sun::star::frame;
114 using namespace ::com::sun::star::beans;
115 using namespace ::com::sun::star::lang;
116 
117 namespace
118 {
119 class SvxStyleBox_Base
120 {
121 public:
122  SvxStyleBox_Base(std::unique_ptr<weld::ComboBox> xWidget, const OUString& rCommand, SfxStyleFamily eFamily,
123  const Reference<XDispatchProvider>& rDispatchProvider,
124  const Reference<XFrame>& _xFrame,const OUString& rClearFormatKey,
125  const OUString& rMoreKey, bool bInSpecialMode, SvxStyleToolBoxControl& rCtrl);
126 
127  virtual ~SvxStyleBox_Base()
128  {
129  }
130 
131  void SetFamily( SfxStyleFamily eNewFamily );
132 
133  void SetDefaultStyle( const OUString& rDefault ) { sDefaultStyle = rDefault; }
134 
135  int get_count() const { return m_xWidget->get_count(); }
136  OUString get_text(int nIndex) const { return m_xWidget->get_text(nIndex); }
137  OUString get_active_text() const { return m_xWidget->get_active_text(); }
138 
139  void append_text(const OUString& rStr)
140  {
141  OUString sId(OUString::number(m_xWidget->get_count()));
142  m_xWidget->append(sId, rStr);
143  }
144 
145  void insert_separator(int pos, const OUString& rId)
146  {
147  m_xWidget->insert_separator(pos, rId);
148  }
149 
150  void set_active_or_entry_text(const OUString& rText)
151  {
152  const int nFound = m_xWidget->find_text(rText);
153  if (nFound != -1)
154  m_xWidget->set_active(nFound);
155  else
156  m_xWidget->set_entry_text(rText);
157  }
158 
159  void set_active(int nActive)
160  {
161  m_xWidget->set_active(nActive);
162  }
163 
164  void freeze()
165  {
166  m_xWidget->freeze();
167  }
168 
169  void save_value()
170  {
171  m_xWidget->save_value();
172  }
173 
174  void clear()
175  {
176  m_xWidget->clear();
177  m_nMaxUserDrawFontWidth = 0;
178  }
179 
180  void thaw()
181  {
182  m_xWidget->thaw();
183  }
184 
185  virtual bool DoKeyInput(const KeyEvent& rKEvt);
186 
187 private:
188  DECL_LINK(SelectHdl, weld::ComboBox&, void);
189  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
190  DECL_LINK(ActivateHdl, weld::ComboBox&, bool);
191  DECL_LINK(FocusOutHdl, weld::Widget&, void);
192  DECL_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void);
193  DECL_LINK(CustomRenderHdl, weld::ComboBox::render_args, void);
194  DECL_LINK(CustomGetSizeHdl, OutputDevice&, Size);
195 
197  void CalcOptimalExtraUserWidth(vcl::RenderContext& rRenderContext);
198 
199  void Select(bool bNonTravelSelect);
200 
201 protected:
202  SvxStyleToolBoxControl& m_rCtrl;
203 
204  std::unique_ptr<weld::Builder> m_xMenuBuilder;
205  std::unique_ptr<weld::Menu> m_xMenu;
206  std::unique_ptr<weld::ComboBox> m_xWidget;
207 
208  SfxStyleFamily eStyleFamily;
209  int m_nMaxUserDrawFontWidth;
210  int m_nLastItemWithMenu;
211  bool bRelease;
212  Reference< XDispatchProvider > m_xDispatchProvider;
214  OUString m_aCommand;
215  OUString aClearFormatKey;
216  OUString aMoreKey;
217  OUString sDefaultStyle;
218  bool bInSpecialMode;
219 
220  void ReleaseFocus();
221  static Color TestColorsVisible(const Color &FontCol, const Color &BackCol);
222  static void UserDrawEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const OUString &rStyleName);
223  void SetupEntry(vcl::RenderContext& rRenderContext, sal_Int32 nItem, const tools::Rectangle& rRect, std::u16string_view rStyleName, bool bIsNotSelected);
224  static bool AdjustFontForItemHeight(OutputDevice& rDevice, tools::Rectangle const & rTextRect, tools::Long nHeight);
225  DECL_LINK(MenuSelectHdl, const OString&, void);
226  DECL_STATIC_LINK(SvxStyleBox_Base, ShowMoreHdl, void*, void);
227 };
228 
229 class SvxStyleBox_Impl final : public InterimItemWindow
230  , public SvxStyleBox_Base
231 {
232 public:
233  SvxStyleBox_Impl(vcl::Window* pParent, const OUString& rCommand, SfxStyleFamily eFamily, const Reference< XDispatchProvider >& rDispatchProvider,
234  const Reference< XFrame >& _xFrame,const OUString& rClearFormatKey, const OUString& rMoreKey, bool bInSpecialMode, SvxStyleToolBoxControl& rCtrl);
235 
236  virtual ~SvxStyleBox_Impl() override
237  {
238  disposeOnce();
239  }
240 
241  virtual void dispose() override
242  {
243  m_xWidget.reset();
244  m_xMenu.reset();
245  m_xMenuBuilder.reset();
247  }
248 
249  virtual bool DoKeyInput(const KeyEvent& rKEvt) override;
250 
251 private:
252 
253  virtual void DataChanged(const DataChangedEvent& rDCEvt) override;
254  void SetOptimalSize();
255 };
256 
257 class SvxFontNameBox_Impl;
258 class SvxFontNameBox_Base;
259 
260 class SvxFontNameToolBoxControl final : public cppu::ImplInheritanceHelper<svt::ToolboxController,
261  css::lang::XServiceInfo>
262 {
263 public:
264  SvxFontNameToolBoxControl();
265 
266  // XStatusListener
267  virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
268 
269  // XToolbarController
270  virtual css::uno::Reference<css::awt::XWindow> SAL_CALL createItemWindow(const css::uno::Reference<css::awt::XWindow>& rParent) override;
271 
272  // XComponent
273  virtual void SAL_CALL dispose() override;
274 
275  // XServiceInfo
276  virtual OUString SAL_CALL getImplementationName() override;
277  virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
278  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
279 
280 private:
281  VclPtr<SvxFontNameBox_Impl> m_xVclBox;
282  std::unique_ptr<SvxFontNameBox_Base> m_xWeldBox;
283  SvxFontNameBox_Base* m_pBox;
284 };
285 
286 class FontOptionsListener final : public comphelper::ConfigurationListenerProperty<bool>
287 {
288 private:
289  SvxFontNameBox_Base& m_rBox;
290 
291  virtual void setProperty(const css::uno::Any &rProperty) override;
292 public:
293  FontOptionsListener(const rtl::Reference<comphelper::ConfigurationListener>& rListener, const OUString& rProp, SvxFontNameBox_Base& rBox)
295  , m_rBox(rBox)
296  {
297  }
298 };
299 
300 class SvxFontNameBox_Base
301 {
302 private:
304  FontOptionsListener m_aWYSIWYG;
305  FontOptionsListener m_aHistory;
306 
307 protected:
308  SvxFontNameToolBoxControl& m_rCtrl;
309 
310  std::unique_ptr<FontNameBox> m_xWidget;
311  const FontList* pFontList;
312  ::std::unique_ptr<FontList> m_aOwnFontList;
313  vcl::Font aCurFont;
314  sal_uInt16 nFtCount;
315  bool bRelease;
316  Reference< XDispatchProvider > m_xDispatchProvider;
318  bool mbCheckingUnknownFont;
319 
320  void ReleaseFocus_Impl();
321 
322  void Select(bool bNonTravelSelect);
323 
324  void EndPreview()
325  {
326  Sequence< PropertyValue > aArgs;
327  SfxToolBoxControl::Dispatch( m_xDispatchProvider,
328  ".uno:CharEndPreviewFontName",
329  aArgs );
330  }
331  void CheckAndMarkUnknownFont();
332 
333 public:
334  SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget, const Reference<XDispatchProvider>& rDispatchProvider,
335  const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl);
336  virtual ~SvxFontNameBox_Base()
337  {
338  m_xListener->dispose();
339  }
340 
341  void FillList();
342  void Update( const css::awt::FontDescriptor* pFontDesc );
343  sal_uInt16 GetListCount() const { return nFtCount; }
344  void Clear() { m_xWidget->clear(); nFtCount = 0; }
345  void Fill( const FontList* pList )
346  {
347  m_xWidget->Fill(pList);
348  nFtCount = pList->GetFontNameCount();
349  }
350 
351  void SetOwnFontList(::std::unique_ptr<FontList> && _aOwnFontList) { m_aOwnFontList = std::move(_aOwnFontList); }
352 
353  virtual void set_sensitive(bool bSensitive)
354  {
355  m_xWidget->set_sensitive(bSensitive);
356  }
357 
358  void set_active_or_entry_text(const OUString& rText);
359 
360  void statusChanged_Impl(const css::frame::FeatureStateEvent& rEvent);
361 
362  virtual bool DoKeyInput(const KeyEvent& rKEvt);
363 
364  void EnableControls();
365 
366  DECL_LINK(SelectHdl, weld::ComboBox&, void);
367  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
368  DECL_LINK(ActivateHdl, weld::ComboBox&, bool);
369  DECL_LINK(FocusInHdl, weld::Widget&, void);
370  DECL_LINK(FocusOutHdl, weld::Widget&, void);
371  DECL_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void);
372 };
373 
374 void FontOptionsListener::setProperty(const css::uno::Any &rProperty)
375 {
377  m_rBox.EnableControls();
378 }
379 
380 class SvxFontNameBox_Impl final : public InterimItemWindow
381  , public SvxFontNameBox_Base
382 {
383 private:
384  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
385  virtual void GetFocus() override
386  {
387  if (m_xWidget)
388  m_xWidget->grab_focus();
390  }
391 
392  void SetOptimalSize();
393 
394  virtual bool DoKeyInput(const KeyEvent& rKEvt) override;
395 
396 public:
397  SvxFontNameBox_Impl(vcl::Window* pParent, const Reference<XDispatchProvider>& rDispatchProvider,
398  const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl);
399 
400  virtual void dispose() override
401  {
402  m_xWidget.reset();
404  }
405 
406  virtual ~SvxFontNameBox_Impl() override
407  {
408  disposeOnce();
409  }
410 
411  virtual Reference< css::accessibility::XAccessible > CreateAccessible() override;
412 
413  virtual void set_sensitive(bool bSensitive) override
414  {
415  m_xWidget->set_sensitive(bSensitive);
416  if (bSensitive)
418  else
420  }
421 };
422 
423 
424 // SelectHdl needs the Modifiers, get them in MouseButtonUp
425 class SvxFrmValueSet_Impl final : public ValueSet
426 {
427 private:
428  sal_uInt16 nModifier;
429 
430  virtual bool MouseButtonUp(const MouseEvent& rMEvt) override
431  {
432  nModifier = rMEvt.GetModifier();
433  return ValueSet::MouseButtonUp(rMEvt);
434  }
435 
436 public:
437  SvxFrmValueSet_Impl()
438  : ValueSet(nullptr)
439  , nModifier(0)
440  {
441  }
442  sal_uInt16 GetModifier() const {return nModifier;}
443 };
444 
445 }
446 
447 namespace {
448 
449 class SvxFrameToolBoxControl;
450 
451 class SvxFrameWindow_Impl final : public WeldToolbarPopup
452 {
453 private:
455  std::unique_ptr<SvxFrmValueSet_Impl> mxFrameSet;
456  std::unique_ptr<weld::CustomWeld> mxFrameSetWin;
457  std::vector<std::pair<BitmapEx, OUString>> aImgVec;
458  bool bParagraphMode;
459 
460  void InitImageList();
461  void CalcSizeValueSet();
462  DECL_LINK( SelectHdl, ValueSet*, void );
463 
464 public:
465  SvxFrameWindow_Impl(SvxFrameToolBoxControl* pControl, weld::Widget* pParent);
466  virtual void GrabFocus() override
467  {
468  mxFrameSet->GrabFocus();
469  }
470 
471  virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
472 };
473 
474 class SvxFrameToolBoxControl : public svt::PopupWindowController
475 {
476 public:
477  explicit SvxFrameToolBoxControl( const css::uno::Reference< css::uno::XComponentContext >& rContext );
478 
479  // XInitialization
480  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override;
481 
482  // XServiceInfo
483  virtual OUString SAL_CALL getImplementationName() override;
484  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
485 
486  virtual void SAL_CALL execute(sal_Int16 nKeyModifier) override;
487 private:
488  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
489  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
490 };
491 
492  class LineListBox final : public ValueSet
493  {
494  public:
495  typedef Color (*ColorFunc)(Color);
496  typedef Color (*ColorDistFunc)(Color, Color);
497 
498  LineListBox();
499 
501  Size SetWidth( tools::Long nWidth )
502  {
503  tools::Long nOldWidth = m_nWidth;
504  m_nWidth = nWidth;
505  return UpdateEntries( nOldWidth );
506  }
507 
508  void SetNone( const OUString& sNone )
509  {
510  m_sNone = sNone;
511  }
512 
514  void InsertEntry(const BorderWidthImpl& rWidthImpl,
515  SvxBorderLineStyle nStyle, tools::Long nMinWidth = 0,
516  ColorFunc pColor1Fn = &sameColor,
517  ColorFunc pColor2Fn = &sameColor,
518  ColorDistFunc pColorDistFn = &sameDistColor);
519 
520  SvxBorderLineStyle GetEntryStyle( sal_Int32 nPos ) const;
521 
522  SvxBorderLineStyle GetSelectEntryStyle() const;
523 
524  void SetSourceUnit( FieldUnit eNewUnit ) { eSourceUnit = eNewUnit; }
525 
526  const Color& GetColor() const { return aColor; }
527 
528  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
529  private:
530 
531  void ImpGetLine(tools::Long nLine1, tools::Long nLine2, tools::Long nDistance,
532  Color nColor1, Color nColor2, Color nColorDist,
533  SvxBorderLineStyle nStyle, BitmapEx& rBmp);
534 
535  void UpdatePaintLineColor(); // returns sal_True if maPaintCol has changed
536 
537  Size UpdateEntries( tools::Long nOldWidth );
538  sal_Int32 GetStylePos( sal_Int32 nListPos, tools::Long nWidth );
539 
540  const Color& GetPaintColor() const
541  {
542  return maPaintCol;
543  }
544 
545  Color GetColorLine1( sal_Int32 nPos );
546  Color GetColorLine2( sal_Int32 nPos );
547  Color GetColorDist( sal_Int32 nPos );
548 
549  LineListBox( const LineListBox& ) = delete;
550  LineListBox& operator =( const LineListBox& ) = delete;
551 
552  std::vector<std::unique_ptr<ImpLineListData>> m_vLineList;
553  tools::Long m_nWidth;
554  OUString m_sNone;
556  Size aTxtSize;
557  Color const aColor;
558  Color maPaintCol;
559  FieldUnit eSourceUnit;
560  };
561 
562  SvxBorderLineStyle LineListBox::GetSelectEntryStyle() const
563  {
564  SvxBorderLineStyle nStyle = SvxBorderLineStyle::SOLID;
565  size_t nPos = GetSelectItemPos();
566  if (nPos != VALUESET_ITEM_NOTFOUND)
567  {
568  if (!m_sNone.isEmpty())
569  --nPos;
570  nStyle = GetEntryStyle( nPos );
571  }
572 
573  return nStyle;
574  }
575 
576  void LineListBox::ImpGetLine( tools::Long nLine1, tools::Long nLine2, tools::Long nDistance,
577  Color aColor1, Color aColor2, Color aColorDist,
578  SvxBorderLineStyle nStyle, BitmapEx& rBmp )
579  {
580  auto nMinWidth = GetDrawingArea()->get_ref_device().approximate_digit_width() * COMBO_WIDTH_IN_CHARS;
581  Size aSize(nMinWidth, aTxtSize.Height());
582  aSize.AdjustWidth( -(aTxtSize.Width()) );
583  aSize.AdjustWidth( -6 );
584 
585  // SourceUnit to Twips
586  if ( eSourceUnit == FieldUnit::POINT )
587  {
588  nLine1 /= 5;
589  nLine2 /= 5;
590  nDistance /= 5;
591  }
592 
593  // Paint the lines
594  aSize = aVirDev->PixelToLogic( aSize );
595  tools::Long nPix = aVirDev->PixelToLogic( Size( 0, 1 ) ).Height();
596  sal_uInt32 n1 = nLine1;
597  sal_uInt32 n2 = nLine2;
598  tools::Long nDist = nDistance;
599  n1 += nPix-1;
600  n1 -= n1%nPix;
601  if ( n2 )
602  {
603  nDist += nPix-1;
604  nDist -= nDist%nPix;
605  n2 += nPix-1;
606  n2 -= n2%nPix;
607  }
608  tools::Long nVirHeight = n1+nDist+n2;
609  if ( nVirHeight > aSize.Height() )
610  aSize.setHeight( nVirHeight );
611  // negative width should not be drawn
612  if ( aSize.Width() <= 0 )
613  return;
614 
615  Size aVirSize = aVirDev->LogicToPixel( aSize );
616  if ( aVirDev->GetOutputSizePixel() != aVirSize )
617  aVirDev->SetOutputSizePixel( aVirSize );
618  aVirDev->SetFillColor( aColorDist );
619  aVirDev->DrawRect( tools::Rectangle( Point(), aSize ) );
620 
621  aVirDev->SetFillColor( aColor1 );
622 
623  double y1 = double( n1 ) / 2;
624  svtools::DrawLine( *aVirDev, basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle );
625 
626  if ( n2 )
627  {
628  double y2 = n1 + nDist + double( n2 ) / 2;
629  aVirDev->SetFillColor( aColor2 );
630  svtools::DrawLine( *aVirDev, basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, SvxBorderLineStyle::SOLID );
631  }
632  rBmp = aVirDev->GetBitmapEx( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
633  }
634 
635  LineListBox::LineListBox()
636  : ValueSet(nullptr)
637  , m_nWidth( 5 )
638  , aVirDev(VclPtr<VirtualDevice>::Create())
639  , aColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor())
640  , maPaintCol(COL_BLACK)
641  , eSourceUnit(FieldUnit::POINT)
642  {
643  aVirDev->SetLineColor();
644  aVirDev->SetMapMode( MapMode( MapUnit::MapTwip ) );
645  }
646 
647  void LineListBox::SetDrawingArea(weld::DrawingArea* pDrawingArea)
648  {
649  ValueSet::SetDrawingArea(pDrawingArea);
650 
651  OutputDevice& rDevice = pDrawingArea->get_ref_device();
652 
653  aTxtSize.setWidth( rDevice.approximate_digit_width() );
654  aTxtSize.setHeight( rDevice.GetTextHeight() );
655 
656  UpdatePaintLineColor();
657  }
658 
659  sal_Int32 LineListBox::GetStylePos( sal_Int32 nListPos, tools::Long nWidth )
660  {
661  sal_Int32 nPos = -1;
662  if (!m_sNone.isEmpty())
663  nListPos--;
664 
665  sal_Int32 n = 0;
666  size_t i = 0;
667  size_t nCount = m_vLineList.size();
668  while ( nPos == -1 && i < nCount )
669  {
670  auto& pData = m_vLineList[ i ];
671  if ( pData->GetMinWidth() <= nWidth )
672  {
673  if ( nListPos == n )
674  nPos = static_cast<sal_Int32>(i);
675  n++;
676  }
677  i++;
678  }
679 
680  return nPos;
681  }
682 
683  void LineListBox::InsertEntry(
684  const BorderWidthImpl& rWidthImpl, SvxBorderLineStyle nStyle, tools::Long nMinWidth,
685  ColorFunc pColor1Fn, ColorFunc pColor2Fn, ColorDistFunc pColorDistFn )
686  {
687  m_vLineList.emplace_back(new ImpLineListData(
688  rWidthImpl, nStyle, nMinWidth, pColor1Fn, pColor2Fn, pColorDistFn));
689  }
690 
691  SvxBorderLineStyle LineListBox::GetEntryStyle( sal_Int32 nPos ) const
692  {
693  ImpLineListData* pData = (0 <= nPos && o3tl::make_unsigned(nPos) < m_vLineList.size()) ? m_vLineList[ nPos ].get() : nullptr;
694  return pData ? pData->GetStyle() : SvxBorderLineStyle::NONE;
695  }
696 
697  void LineListBox::UpdatePaintLineColor()
698  {
700  Color aNewCol( rSettings.GetWindowColor().IsDark()? rSettings.GetLabelTextColor() : aColor );
701 
702  bool bRet = aNewCol != maPaintCol;
703 
704  if( bRet )
705  maPaintCol = aNewCol;
706  }
707 
708  Size LineListBox::UpdateEntries( tools::Long nOldWidth )
709  {
710  Size aSize;
711 
712  UpdatePaintLineColor( );
713 
714  sal_Int32 nSelEntry = GetSelectItemPos();
715  sal_Int32 nTypePos = GetStylePos( nSelEntry, nOldWidth );
716 
717  // Remove the old entries
718  Clear();
719 
720  sal_uInt16 nId(1);
721 
722  // Add the new entries based on the defined width
723  if (!m_sNone.isEmpty())
724  InsertItem(nId++, Image(), m_sNone);
725 
726  sal_uInt16 n = 0;
727  sal_uInt16 nCount = m_vLineList.size( );
728  while ( n < nCount )
729  {
730  auto& pData = m_vLineList[ n ];
731  if ( pData->GetMinWidth() <= m_nWidth )
732  {
733  BitmapEx aBmp;
734  ImpGetLine( pData->GetLine1ForWidth( m_nWidth ),
735  pData->GetLine2ForWidth( m_nWidth ),
736  pData->GetDistForWidth( m_nWidth ),
737  GetColorLine1( GetItemCount( ) ),
738  GetColorLine2( GetItemCount( ) ),
739  GetColorDist( GetItemCount( ) ),
740  pData->GetStyle(), aBmp );
741  InsertItem(nId, Image(aBmp), SvtLineListBox::GetLineStyleName(pData->GetStyle()));
742  Size aBmpSize = aBmp.GetSizePixel();
743  if (aBmpSize.Width() > aSize.Width())
744  aSize.setWidth(aBmpSize.getWidth());
745  if (aBmpSize.Height() > aSize.Height())
746  aSize.setHeight(aBmpSize.getHeight());
747  if ( n == nTypePos )
748  SelectItem(nId);
749  }
750  else if ( n == nTypePos )
751  SetNoSelection();
752  n++;
753  ++nId;
754  }
755 
756  Invalidate();
757 
758  return aSize;
759  }
760 
761  Color LineListBox::GetColorLine1( sal_Int32 nPos )
762  {
763  sal_Int32 nStyle = GetStylePos( nPos, m_nWidth );
764  if (nStyle == -1)
765  return GetPaintColor( );
766  auto& pData = m_vLineList[ nStyle ];
767  return pData->GetColorLine1( GetColor( ) );
768  }
769 
770  Color LineListBox::GetColorLine2( sal_Int32 nPos )
771  {
772  sal_Int32 nStyle = GetStylePos( nPos, m_nWidth );
773  if (nStyle == -1)
774  return GetPaintColor( );
775  auto& pData = m_vLineList[ nStyle ];
776  return pData->GetColorLine2( GetColor( ) );
777  }
778 
779  Color LineListBox::GetColorDist( sal_Int32 nPos )
780  {
782 
783  sal_Int32 nStyle = GetStylePos( nPos, m_nWidth );
784  if (nStyle == -1)
785  return rResult;
786  auto& pData = m_vLineList[ nStyle ];
787  return pData->GetColorDist( GetColor( ), rResult );
788  }
789 }
790 
791 namespace {
792 
793 class SvxLineWindow_Impl final : public WeldToolbarPopup
794 {
795 private:
797  std::unique_ptr<LineListBox> m_xLineStyleLb;
798  std::unique_ptr<weld::CustomWeld> m_xLineStyleLbWin;
799  bool m_bIsWriter;
800 
801  DECL_LINK( SelectHdl, ValueSet*, void );
802 
803 public:
804  SvxLineWindow_Impl(SvxFrameToolBoxControl* pControl, weld::Widget* pParent);
805  virtual void GrabFocus() override
806  {
807  m_xLineStyleLb->GrabFocus();
808  }
809 };
810 
811 }
812 
814 
816 {
817  public:
818  SfxStyleControllerItem_Impl( const Reference< XDispatchProvider >& rDispatchProvider,
819  sal_uInt16 nSlotId,
820  const OUString& rCommand,
821  SvxStyleToolBoxControl& rTbxCtl );
822 
823  protected:
824  virtual void StateChangedAtStatusListener( SfxItemState eState, const SfxPoolItem* pState ) override;
825 
826  private:
828 };
829 
830 #define BUTTON_PADDING 10
831 #define ITEM_HEIGHT 30
832 
833 SvxStyleBox_Base::SvxStyleBox_Base(std::unique_ptr<weld::ComboBox> xWidget,
834  const OUString& rCommand,
835  SfxStyleFamily eFamily,
836  const Reference< XDispatchProvider >& rDispatchProvider,
837  const Reference< XFrame >& _xFrame,
838  const OUString& rClearFormatKey,
839  const OUString& rMoreKey,
840  bool bInSpec, SvxStyleToolBoxControl& rCtrl)
841  : m_rCtrl(rCtrl)
842  , m_xMenuBuilder(Application::CreateBuilder(nullptr, "svx/ui/stylemenu.ui"))
843  , m_xMenu(m_xMenuBuilder->weld_menu("menu"))
844  , m_xWidget(std::move(xWidget))
845  , eStyleFamily( eFamily )
846  , m_nMaxUserDrawFontWidth(0)
847  , m_nLastItemWithMenu(-1)
848  , bRelease( true )
849  , m_xDispatchProvider( rDispatchProvider )
850  , m_xFrame(_xFrame)
851  , m_aCommand( rCommand )
852  , aClearFormatKey( rClearFormatKey )
853  , aMoreKey( rMoreKey )
854  , bInSpecialMode( bInSpec )
855 {
856  m_xWidget->connect_changed(LINK(this, SvxStyleBox_Base, SelectHdl));
857  m_xWidget->connect_key_press(LINK(this, SvxStyleBox_Base, KeyInputHdl));
858  m_xWidget->connect_entry_activate(LINK(this, SvxStyleBox_Base, ActivateHdl));
859  m_xWidget->connect_focus_out(LINK(this, SvxStyleBox_Base, FocusOutHdl));
860  m_xWidget->connect_get_property_tree(LINK(this, SvxStyleBox_Base, DumpAsPropertyTreeHdl));
861  m_xWidget->set_help_id(HID_STYLE_LISTBOX);
862  m_xWidget->set_entry_completion(true);
863  m_xMenu->connect_activate(LINK(this, SvxStyleBox_Base, MenuSelectHdl));
864 
865  m_xWidget->connect_custom_get_size(LINK(this, SvxStyleBox_Base, CustomGetSizeHdl));
866  m_xWidget->connect_custom_render(LINK(this, SvxStyleBox_Base, CustomRenderHdl));
867  m_xWidget->set_custom_renderer(true);
868 
869  m_xWidget->set_entry_width_chars(COMBO_WIDTH_IN_CHARS + 3);
870 }
871 
872 IMPL_LINK(SvxStyleBox_Base, CustomGetSizeHdl, OutputDevice&, rArg, Size)
873 {
874  CalcOptimalExtraUserWidth(rArg);
875  return Size(m_nMaxUserDrawFontWidth, ITEM_HEIGHT);
876 }
877 
878 SvxStyleBox_Impl::SvxStyleBox_Impl(vcl::Window* pParent,
879  const OUString& rCommand,
880  SfxStyleFamily eFamily,
881  const Reference< XDispatchProvider >& rDispatchProvider,
882  const Reference< XFrame >& _xFrame,
883  const OUString& rClearFormatKey,
884  const OUString& rMoreKey,
885  bool bInSpec, SvxStyleToolBoxControl& rCtrl)
886  : InterimItemWindow(pParent, "svx/ui/applystylebox.ui", "ApplyStyleBox")
887  , SvxStyleBox_Base(m_xBuilder->weld_combo_box("applystyle"), rCommand, eFamily,
888  rDispatchProvider, _xFrame, rClearFormatKey, rMoreKey, bInSpec, rCtrl)
889 {
890  InitControlBase(m_xWidget.get());
891 
892  set_id("applystyle");
893  SetOptimalSize();
894 }
895 
896 void SvxStyleBox_Base::ReleaseFocus()
897 {
898  if ( !bRelease )
899  {
900  bRelease = true;
901  return;
902  }
903  if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
904  m_xFrame->getContainerWindow()->setFocus();
905 }
906 
907 IMPL_LINK(SvxStyleBox_Base, MenuSelectHdl, const OString&, rMenuIdent, void)
908 {
909  if (m_nLastItemWithMenu < 0 || m_nLastItemWithMenu >= m_xWidget->get_count())
910  return;
911 
912  OUString sEntry = m_xWidget->get_text(m_nLastItemWithMenu);
913 
914  ReleaseFocus(); // It must be after getting entry pos!
915  Sequence<PropertyValue> aArgs(2);
916  aArgs[0].Name = "Param";
917  aArgs[0].Value <<= sEntry;
918  aArgs[1].Name = "Family";
919  aArgs[1].Value <<= sal_Int16( eStyleFamily );
920 
921  if (rMenuIdent == "update")
922  {
923  SfxToolBoxControl::Dispatch( m_xDispatchProvider,
924  ".uno:StyleUpdateByExample", aArgs );
925  }
926  else if (rMenuIdent == "edit")
927  {
928  SfxToolBoxControl::Dispatch( m_xDispatchProvider,
929  ".uno:EditStyle", aArgs );
930  }
931 }
932 
933 IMPL_STATIC_LINK_NOARG(SvxStyleBox_Base, ShowMoreHdl, void*, void)
934 {
935  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
936  DBG_ASSERT( pViewFrm, "SvxStyleBox_Base::Select(): no viewframe" );
937  if (!pViewFrm)
938  return;
939  pViewFrm->ShowChildWindow(SID_SIDEBAR);
940  ::sfx2::sidebar::Sidebar::ShowPanel(u"StyleListPanel", pViewFrm->GetFrame().GetFrameInterface(), true);
941 }
942 
943 IMPL_LINK(SvxStyleBox_Base, SelectHdl, weld::ComboBox&, rCombo, void)
944 {
945  Select(rCombo.changed_by_direct_pick()); // only when picked from the list
946 }
947 
948 IMPL_LINK_NOARG(SvxStyleBox_Base, ActivateHdl, weld::ComboBox&, bool)
949 {
950  Select(true);
951  return true;
952 }
953 
954 void SvxStyleBox_Base::Select(bool bNonTravelSelect)
955 {
956  if (!bNonTravelSelect)
957  return;
958 
959  OUString aSearchEntry(m_xWidget->get_active_text());
960  bool bDoIt = true, bClear = false;
961  if( bInSpecialMode )
962  {
963  if( aSearchEntry == aClearFormatKey && m_xWidget->get_active() == 0 )
964  {
965  aSearchEntry = sDefaultStyle;
966  bClear = true;
967  //not only apply default style but also call 'ClearFormatting'
968  Sequence< PropertyValue > aEmptyVals;
969  SfxToolBoxControl::Dispatch( m_xDispatchProvider, ".uno:ResetAttributes",
970  aEmptyVals);
971  }
972  else if (aSearchEntry == aMoreKey && m_xWidget->get_active() == (m_xWidget->get_count() - 1))
973  {
974  Application::PostUserEvent(LINK(nullptr, SvxStyleBox_Base, ShowMoreHdl));
975  //tdf#113214 change text back to previous entry
976  set_active_or_entry_text(m_xWidget->get_saved_value());
977  bDoIt = false;
978  }
979  }
980 
981  //Do we need to create a new style?
983  SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
984  SfxStyleSheetBase* pStyle = nullptr;
985 
986  bool bCreateNew = false;
987 
988  if ( pPool )
989  {
990  pStyle = pPool->First(eStyleFamily);
991  while ( pStyle && pStyle->GetName() != aSearchEntry )
992  pStyle = pPool->Next();
993  }
994 
995  if ( !pStyle )
996  {
997  // cannot find the style for whatever reason
998  // therefore create a new style
999  bCreateNew = true;
1000  }
1001 
1002  /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1003  This instance may be deleted in the meantime (i.e. when a dialog is opened
1004  while in Dispatch()), accessing members will crash in this case. */
1005  ReleaseFocus();
1006 
1007  if( !bDoIt )
1008  return;
1009 
1010  if ( bClear )
1011  set_active_or_entry_text(aSearchEntry);
1012  m_xWidget->save_value();
1013 
1014  Sequence< PropertyValue > aArgs( 2 );
1015  aArgs[0].Value <<= aSearchEntry;
1016  aArgs[1].Name = "Family";
1017  aArgs[1].Value <<= sal_Int16( eStyleFamily );
1018  if( bCreateNew )
1019  {
1020  aArgs[0].Name = "Param";
1021  SfxToolBoxControl::Dispatch( m_xDispatchProvider, ".uno:StyleNewByExample", aArgs);
1022  }
1023  else
1024  {
1025  aArgs[0].Name = "Template";
1026  SfxToolBoxControl::Dispatch( m_xDispatchProvider, m_aCommand, aArgs );
1027  }
1028 }
1029 
1030 void SvxStyleBox_Base::SetFamily( SfxStyleFamily eNewFamily )
1031 {
1032  eStyleFamily = eNewFamily;
1033 }
1034 
1035 IMPL_LINK_NOARG(SvxStyleBox_Base, FocusOutHdl, weld::Widget&, void)
1036 {
1037  if (!m_xWidget->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus
1038  set_active_or_entry_text(m_xWidget->get_saved_value());
1039 }
1040 
1041 IMPL_LINK(SvxStyleBox_Base, KeyInputHdl, const KeyEvent&, rKEvt, bool)
1042 {
1043  return DoKeyInput(rKEvt);
1044 }
1045 
1046 bool SvxStyleBox_Base::DoKeyInput(const KeyEvent& rKEvt)
1047 {
1048  bool bHandled = false;
1049 
1050  sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
1051 
1052  switch (nCode)
1053  {
1054  case KEY_TAB:
1055  bRelease = false;
1056  Select(true);
1057  break;
1058  case KEY_ESCAPE:
1059  set_active_or_entry_text(m_xWidget->get_saved_value());
1060  if (!m_rCtrl.IsInSidebar())
1061  {
1062  ReleaseFocus();
1063  bHandled = true;
1064  }
1065  break;
1066  }
1067 
1068  return bHandled;
1069 }
1070 
1071 bool SvxStyleBox_Impl::DoKeyInput(const KeyEvent& rKEvt)
1072 {
1073  return SvxStyleBox_Base::DoKeyInput(rKEvt) || ChildKeyInput(rKEvt);
1074 }
1075 
1076 void SvxStyleBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1077 {
1078  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1079  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
1080  {
1081  SetOptimalSize();
1082  }
1083 
1085 }
1086 
1087 bool SvxStyleBox_Base::AdjustFontForItemHeight(OutputDevice& rDevice, tools::Rectangle const & rTextRect, tools::Long nHeight)
1088 {
1089  if (rTextRect.Bottom() > nHeight)
1090  {
1091  // the text does not fit, adjust the font size
1092  double ratio = static_cast< double >( nHeight ) / rTextRect.Bottom();
1093  vcl::Font aFont(rDevice.GetFont());
1094  Size aPixelSize(aFont.GetFontSize());
1095  aPixelSize.setWidth( aPixelSize.Width() * ratio );
1096  aPixelSize.setHeight( aPixelSize.Height() * ratio );
1097  aFont.SetFontSize(aPixelSize);
1098  rDevice.SetFont(aFont);
1099  return true;
1100  }
1101  return false;
1102 }
1103 
1104 void SvxStyleBox_Impl::SetOptimalSize()
1105 {
1106  // set width in chars low so the size request will not be overridden
1107  m_xWidget->set_entry_width_chars(1);
1108  // tdf#132338 purely using this calculation to keep things their traditional width
1109  Size aSize(LogicToPixel(Size((COMBO_WIDTH_IN_CHARS + 3) * 4, 0), MapMode(MapUnit::MapAppFont)));
1110  m_xWidget->set_size_request(aSize.Width(), -1);
1111 
1112  SetSizePixel(get_preferred_size());
1113 }
1114 
1115 void SvxStyleBox_Base::UserDrawEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const OUString &rStyleName)
1116 {
1117  // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as
1118  // nBorder, and we are adding 1 in order to look better when
1119  // italics is present
1120  const int nLeftDistance = 8;
1121 
1122  tools::Rectangle aTextRect;
1123  rRenderContext.GetTextBoundRect(aTextRect, rStyleName);
1124 
1125  Point aPos(rRect.TopLeft());
1126  aPos.AdjustX(nLeftDistance );
1127 
1128  if (!AdjustFontForItemHeight(rRenderContext, aTextRect, rRect.GetHeight()))
1129  aPos.AdjustY((rRect.GetHeight() - aTextRect.Bottom() ) / 2);
1130 
1131  rRenderContext.DrawText(aPos, rStyleName);
1132 }
1133 
1134 void SvxStyleBox_Base::SetupEntry(vcl::RenderContext& rRenderContext, sal_Int32 nItem, const tools::Rectangle& rRect, std::u16string_view rStyleName, bool bIsNotSelected)
1135 {
1136  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1137  if (!bIsNotSelected)
1138  rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
1139  else
1140  rRenderContext.SetTextColor(rStyleSettings.GetDialogTextColor());
1141 
1142  // handle the push-button
1143  if (!bIsNotSelected)
1144  {
1145  if (nItem == 0 || nItem == m_xWidget->get_count() - 1)
1146  m_xWidget->set_item_menu(OString::number(nItem), nullptr);
1147  else
1148  {
1149  m_nLastItemWithMenu = nItem;
1150  m_xWidget->set_item_menu(OString::number(nItem), m_xMenu.get());
1151  }
1152  }
1153 
1154  if (nItem <= 0 || nItem >= m_xWidget->get_count() - 1)
1155  return;
1156 
1158  SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
1159  SfxStyleSheetBase* pStyle = nullptr;
1160 
1161  if ( pPool )
1162  {
1163  pStyle = pPool->First(eStyleFamily);
1164  while (pStyle && pStyle->GetName() != rStyleName)
1165  pStyle = pPool->Next();
1166  }
1167 
1168  if (!pStyle )
1169  return;
1170 
1171  std::optional<SfxItemSet> const pItemSet(pStyle->GetItemSetForPreview());
1172  if (!pItemSet) return;
1173 
1174  const SvxFontItem * const pFontItem =
1175  pItemSet->GetItem<SvxFontItem>(SID_ATTR_CHAR_FONT);
1176  const SvxFontHeightItem * const pFontHeightItem =
1177  pItemSet->GetItem<SvxFontHeightItem>(SID_ATTR_CHAR_FONTHEIGHT);
1178 
1179  if ( !(pFontItem && pFontHeightItem) )
1180  return;
1181 
1182  Size aFontSize( 0, pFontHeightItem->GetHeight() );
1183  Size aPixelSize(rRenderContext.LogicToPixel(aFontSize, MapMode(pShell->GetMapUnit())));
1184 
1185  // setup the font properties
1186  SvxFont aFont;
1187  aFont.SetFamilyName(pFontItem->GetFamilyName());
1188  aFont.SetStyleName(pFontItem->GetStyleName());
1189  aFont.SetFontSize(aPixelSize);
1190 
1191  const SfxPoolItem *pItem = pItemSet->GetItem( SID_ATTR_CHAR_WEIGHT );
1192  if ( pItem )
1193  aFont.SetWeight( static_cast< const SvxWeightItem* >( pItem )->GetWeight() );
1194 
1195  pItem = pItemSet->GetItem( SID_ATTR_CHAR_POSTURE );
1196  if ( pItem )
1197  aFont.SetItalic( static_cast< const SvxPostureItem* >( pItem )->GetPosture() );
1198 
1199  pItem = pItemSet->GetItem( SID_ATTR_CHAR_CONTOUR );
1200  if ( pItem )
1201  aFont.SetOutline( static_cast< const SvxContourItem* >( pItem )->GetValue() );
1202 
1203  pItem = pItemSet->GetItem( SID_ATTR_CHAR_SHADOWED );
1204  if ( pItem )
1205  aFont.SetShadow( static_cast< const SvxShadowedItem* >( pItem )->GetValue() );
1206 
1207  pItem = pItemSet->GetItem( SID_ATTR_CHAR_RELIEF );
1208  if ( pItem )
1209  aFont.SetRelief( static_cast< const SvxCharReliefItem* >( pItem )->GetValue() );
1210 
1211  pItem = pItemSet->GetItem( SID_ATTR_CHAR_UNDERLINE );
1212  if ( pItem )
1213  aFont.SetUnderline( static_cast< const SvxUnderlineItem* >( pItem )->GetLineStyle() );
1214 
1215  pItem = pItemSet->GetItem( SID_ATTR_CHAR_OVERLINE );
1216  if ( pItem )
1217  aFont.SetOverline( static_cast< const SvxOverlineItem* >( pItem )->GetValue() );
1218 
1219  pItem = pItemSet->GetItem( SID_ATTR_CHAR_STRIKEOUT );
1220  if ( pItem )
1221  aFont.SetStrikeout( static_cast< const SvxCrossedOutItem* >( pItem )->GetStrikeout() );
1222 
1223  pItem = pItemSet->GetItem( SID_ATTR_CHAR_CASEMAP );
1224  if ( pItem )
1225  aFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
1226 
1227  pItem = pItemSet->GetItem( SID_ATTR_CHAR_EMPHASISMARK );
1228  if ( pItem )
1229  aFont.SetEmphasisMark( static_cast< const SvxEmphasisMarkItem* >( pItem )->GetEmphasisMark() );
1230 
1231  // setup the device & draw
1232  Color aFontCol = COL_AUTO, aBackCol = COL_AUTO;
1233 
1234  rRenderContext.SetFont(aFont);
1235 
1236  pItem = pItemSet->GetItem( SID_ATTR_CHAR_COLOR );
1237  // text color, when nothing is selected
1238  if ( (nullptr != pItem) && bIsNotSelected)
1239  aFontCol = static_cast< const SvxColorItem* >( pItem )->GetValue();
1240 
1241  drawing::FillStyle style = drawing::FillStyle_NONE;
1242  // which kind of Fill style is selected
1243  pItem = pItemSet->GetItem( XATTR_FILLSTYLE );
1244  // only when ok and not selected
1245  if ( (nullptr != pItem) && bIsNotSelected)
1246  style = static_cast< const XFillStyleItem* >( pItem )->GetValue();
1247 
1248  switch(style)
1249  {
1250  case drawing::FillStyle_SOLID:
1251  {
1252  // set background color
1253  pItem = pItemSet->GetItem( XATTR_FILLCOLOR );
1254  if ( nullptr != pItem )
1255  aBackCol = static_cast< const XFillColorItem* >( pItem )->GetColorValue();
1256 
1257  if ( aBackCol != COL_AUTO )
1258  {
1259  rRenderContext.SetFillColor(aBackCol);
1260  rRenderContext.DrawRect(rRect);
1261  }
1262  }
1263  break;
1264 
1265  default: break;
1266  //TODO Draw the other background styles: gradient, hatching and bitmap
1267  }
1268 
1269  // when the font and background color are too similar, adjust the Font-Color
1270  if( (aFontCol != COL_AUTO) || (aBackCol != COL_AUTO) )
1271  aFontCol = TestColorsVisible(aFontCol, (aBackCol != COL_AUTO) ? aBackCol : rRenderContext.GetBackground().GetColor());
1272 
1273  // set text color
1274  if ( aFontCol != COL_AUTO )
1275  rRenderContext.SetTextColor(aFontCol);
1276 }
1277 
1278 IMPL_LINK(SvxStyleBox_Base, CustomRenderHdl, weld::ComboBox::render_args, aPayload, void)
1279 {
1280  vcl::RenderContext& rRenderContext = std::get<0>(aPayload);
1281  const ::tools::Rectangle& rRect = std::get<1>(aPayload);
1282  bool bSelected = std::get<2>(aPayload);
1283  const OUString& rId = std::get<3>(aPayload);
1284 
1285  sal_uInt32 nIndex = rId.toUInt32();
1286 
1287  OUString aStyleName(m_xWidget->get_text(nIndex));
1288 
1289  rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::FONT | PushFlags::TEXTCOLOR);
1290 
1291  SetupEntry(rRenderContext, nIndex, rRect, aStyleName, !bSelected);
1292 
1293  UserDrawEntry(rRenderContext, rRect, aStyleName);
1294 
1295  rRenderContext.Pop();
1296 }
1297 
1298 void SvxStyleBox_Base::CalcOptimalExtraUserWidth(vcl::RenderContext& rRenderContext)
1299 {
1300  if (m_nMaxUserDrawFontWidth)
1301  return;
1302 
1303  tools::Long nMaxNormalFontWidth = 0;
1304  sal_Int32 nEntryCount = m_xWidget->get_count();
1305  for (sal_Int32 i = 0; i < nEntryCount; ++i)
1306  {
1307  OUString sStyleName(get_text(i));
1308  tools::Rectangle aTextRectForDefaultFont;
1309  rRenderContext.GetTextBoundRect(aTextRectForDefaultFont, sStyleName);
1310 
1311  const tools::Long nWidth = aTextRectForDefaultFont.GetWidth();
1312 
1313  nMaxNormalFontWidth = std::max(nWidth, nMaxNormalFontWidth);
1314  }
1315 
1316  m_nMaxUserDrawFontWidth = nMaxNormalFontWidth;
1317  for (sal_Int32 i = 1; i < nEntryCount-1; ++i)
1318  {
1319  OUString sStyleName(get_text(i));
1320 
1321  rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::FONT | PushFlags::TEXTCOLOR);
1322  SetupEntry(rRenderContext, i, tools::Rectangle(0, 0, RECT_MAX, ITEM_HEIGHT), sStyleName, true);
1323  tools::Rectangle aTextRectForActualFont;
1324  rRenderContext.GetTextBoundRect(aTextRectForActualFont, sStyleName);
1325  if (AdjustFontForItemHeight(rRenderContext, aTextRectForActualFont, ITEM_HEIGHT))
1326  {
1327  //Font didn't fit, so it was changed, refetch with final font size
1328  rRenderContext.GetTextBoundRect(aTextRectForActualFont, sStyleName);
1329  }
1330  rRenderContext.Pop();
1331 
1332  const int nWidth = aTextRectForActualFont.GetWidth() + m_xWidget->get_menu_button_width() + BUTTON_PADDING;
1333 
1334  m_nMaxUserDrawFontWidth = std::max(nWidth, m_nMaxUserDrawFontWidth);
1335  }
1336 }
1337 
1338 // test is the color between Font- and background-color to be identify
1339 // return is always the Font-Color
1340 // when both light or dark, change the Contrast
1341 // in other case do not change the origin color
1342 // when the color is R=G=B=128 the DecreaseContrast make 128 the need an exception
1343 Color SvxStyleBox_Base::TestColorsVisible(const Color &FontCol, const Color &BackCol)
1344 {
1345  constexpr sal_uInt8 ChgVal = 60; // increase/decrease the Contrast
1346 
1347  Color retCol = FontCol;
1348  if ((FontCol.IsDark() == BackCol.IsDark()) && (FontCol.IsBright() == BackCol.IsBright()))
1349  {
1350  sal_uInt8 lumi = retCol.GetLuminance();
1351 
1352  if((lumi > 120) && (lumi < 140))
1353  retCol.DecreaseLuminance(ChgVal / 2);
1354  else
1355  retCol.DecreaseContrast(ChgVal);
1356  }
1357 
1358  return retCol;
1359 }
1360 
1361 IMPL_LINK(SvxStyleBox_Base, DumpAsPropertyTreeHdl, tools::JsonWriter&, rJsonWriter, void)
1362 {
1363  {
1364  auto entriesNode = rJsonWriter.startNode("entries");
1365  for (int i = 0, nEntryCount = m_xWidget->get_count(); i < nEntryCount; ++i)
1366  {
1367  auto entryNode = rJsonWriter.startNode("");
1368  rJsonWriter.put("", m_xWidget->get_text(i));
1369  }
1370  }
1371 
1372  int nActive = m_xWidget->get_active();
1373  rJsonWriter.put("selectedCount", static_cast<sal_Int32>(nActive == -1 ? 0 : 1));
1374 
1375  {
1376  auto selectedNode = rJsonWriter.startNode("selectedEntries");
1377  if (nActive != -1)
1378  {
1379  auto node = rJsonWriter.startNode("");
1380  rJsonWriter.put("", static_cast<sal_Int32>(nActive));
1381  }
1382  }
1383 
1384  rJsonWriter.put("command", ".uno:StyleApply");
1385 }
1386 
1387 static bool lcl_GetDocFontList(const FontList** ppFontList, SvxFontNameBox_Base* pBox)
1388 {
1389  bool bChanged = false;
1390  const SfxObjectShell* pDocSh = SfxObjectShell::Current();
1391  const SvxFontListItem* pFontListItem = nullptr;
1392 
1393  if ( pDocSh )
1394  pFontListItem =
1395  static_cast<const SvxFontListItem*>(pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ));
1396  else
1397  {
1398  ::std::unique_ptr<FontList> aFontList(new FontList(Application::GetDefaultDevice()));
1399  *ppFontList = aFontList.get();
1400  pBox->SetOwnFontList(std::move(aFontList));
1401  bChanged = true;
1402  }
1403 
1404  if ( pFontListItem )
1405  {
1406  const FontList* pNewFontList = pFontListItem->GetFontList();
1407  DBG_ASSERT( pNewFontList, "Doc-FontList not available!" );
1408 
1409  // No old list, but a new list
1410  if ( !*ppFontList && pNewFontList )
1411  {
1412  // => take over
1413  *ppFontList = pNewFontList;
1414  bChanged = true;
1415  }
1416  else
1417  {
1418  // Comparing the font lists is not perfect.
1419  // When you change the font list in the Doc, you can track
1420  // changes here only on the Listbox, because ppFontList
1421  // has already been updated.
1422  bChanged =
1423  ( ( *ppFontList != pNewFontList ) ||
1424  pBox->GetListCount() != pNewFontList->GetFontNameCount() );
1425  // HACK: Comparing is incomplete
1426 
1427  if ( bChanged )
1428  *ppFontList = pNewFontList;
1429  }
1430 
1431  if ( pBox )
1432  pBox->set_sensitive(true);
1433  }
1434  else if ( pBox && ( pDocSh || !ppFontList ))
1435  {
1436  // Disable box only when we have a SfxObjectShell and didn't get a font list OR
1437  // we don't have a SfxObjectShell and no current font list.
1438  // It's possible that we currently have no SfxObjectShell, but a current font list.
1439  // See #i58471: When a user set the focus into the font name combo box and opens
1440  // the help window with F1. After closing the help window, we disable the font name
1441  // combo box. The SfxObjectShell::Current() method returns in that case zero. But the
1442  // font list hasn't changed and therefore the combo box shouldn't be disabled!
1443  pBox->set_sensitive(false);
1444  }
1445 
1446  // Fill the FontBox, also the new list if necessary
1447  if ( pBox && bChanged )
1448  {
1449  if ( *ppFontList )
1450  pBox->Fill( *ppFontList );
1451  else
1452  pBox->Clear();
1453  }
1454  return bChanged;
1455 }
1456 
1457 SvxFontNameBox_Base::SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget,
1458  const Reference<XDispatchProvider>& rDispatchProvider,
1459  const Reference<XFrame>& rFrame,
1460  SvxFontNameToolBoxControl& rCtrl)
1461  : m_xListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Common/Font/View"))
1462  , m_aWYSIWYG(m_xListener, "ShowFontBoxWYSIWYG", *this)
1463  , m_aHistory(m_xListener, "History", *this)
1464  , m_rCtrl(rCtrl)
1465  , m_xWidget(new FontNameBox(std::move(xWidget)))
1466  , pFontList(nullptr)
1467  , nFtCount(0)
1468  , bRelease(true)
1469  , m_xDispatchProvider(rDispatchProvider)
1470  , m_xFrame(rFrame)
1471  , mbCheckingUnknownFont(false)
1472 {
1473  EnableControls();
1474 
1475  m_xWidget->connect_changed(LINK(this, SvxFontNameBox_Base, SelectHdl));
1476  m_xWidget->connect_key_press(LINK(this, SvxFontNameBox_Base, KeyInputHdl));
1477  m_xWidget->connect_entry_activate(LINK(this, SvxFontNameBox_Base, ActivateHdl));
1478  m_xWidget->connect_focus_in(LINK(this, SvxFontNameBox_Base, FocusInHdl));
1479  m_xWidget->connect_focus_out(LINK(this, SvxFontNameBox_Base, FocusOutHdl));
1480  m_xWidget->connect_get_property_tree(LINK(this, SvxFontNameBox_Base, DumpAsPropertyTreeHdl));
1481 
1482  m_xWidget->set_entry_width_chars(COMBO_WIDTH_IN_CHARS + 5);
1483 }
1484 
1485 SvxFontNameBox_Impl::SvxFontNameBox_Impl(vcl::Window* pParent, const Reference<XDispatchProvider>& rDispatchProvider,
1486  const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl)
1487  : InterimItemWindow(pParent, "svx/ui/fontnamebox.ui", "FontNameBox")
1488  , SvxFontNameBox_Base(m_xBuilder->weld_combo_box("fontnamecombobox"), rDispatchProvider, rFrame, rCtrl)
1489 {
1490  set_id("fontnamecombobox");
1491  SetOptimalSize();
1492 }
1493 
1494 void SvxFontNameBox_Base::FillList()
1495 {
1496  if (!m_xWidget) // e.g. disposed
1497  return;
1498  // Save old Selection, set back in the end
1499  int nStartPos, nEndPos;
1500  m_xWidget->get_entry_selection_bounds(nStartPos, nEndPos);
1501 
1502  // Did Doc-Fontlist change?
1503  lcl_GetDocFontList(&pFontList, this);
1504 
1505  m_xWidget->select_entry_region(nStartPos, nEndPos);
1506 }
1507 
1508 void SvxFontNameBox_Base::CheckAndMarkUnknownFont()
1509 {
1510  if (mbCheckingUnknownFont) //tdf#117537 block rentry
1511  return;
1512  mbCheckingUnknownFont = true;
1513  OUString fontname = m_xWidget->get_active_text();
1514  lcl_GetDocFontList( &pFontList, this );
1515  // If the font is unknown, show it in italic.
1516  vcl::Font font = m_xWidget->get_entry_font();
1517  if( pFontList != nullptr && pFontList->IsAvailable( fontname ))
1518  {
1519  if( font.GetItalic() != ITALIC_NONE )
1520  {
1521  font.SetItalic( ITALIC_NONE );
1522  m_xWidget->set_entry_font(font);
1523  m_xWidget->set_tooltip_text(SvxResId(RID_SVXSTR_CHARFONTNAME));
1524  }
1525  }
1526  else
1527  {
1528  if( font.GetItalic() != ITALIC_NORMAL )
1529  {
1530  font.SetItalic( ITALIC_NORMAL );
1531  m_xWidget->set_entry_font(font);
1532  m_xWidget->set_tooltip_text(SvxResId(RID_SVXSTR_CHARFONTNAME_NOTAVAILABLE));
1533  }
1534  }
1535  mbCheckingUnknownFont = false;
1536 }
1537 
1538 void SvxFontNameBox_Base::Update( const css::awt::FontDescriptor* pFontDesc )
1539 {
1540  if ( pFontDesc )
1541  {
1542  aCurFont.SetFamilyName ( pFontDesc->Name );
1543  aCurFont.SetFamily ( FontFamily( pFontDesc->Family ) );
1544  aCurFont.SetStyleName ( pFontDesc->StyleName );
1545  aCurFont.SetPitch ( FontPitch( pFontDesc->Pitch ) );
1546  aCurFont.SetCharSet ( rtl_TextEncoding( pFontDesc->CharSet ) );
1547  }
1548  OUString aCurName = aCurFont.GetFamilyName();
1549  OUString aText = m_xWidget->get_active_text();
1550  if (aText != aCurName)
1551  set_active_or_entry_text(aCurName);
1552 }
1553 
1554 void SvxFontNameBox_Base::set_active_or_entry_text(const OUString& rText)
1555 {
1556  m_xWidget->set_active_or_entry_text(rText);
1557  CheckAndMarkUnknownFont();
1558 }
1559 
1560 IMPL_LINK_NOARG(SvxFontNameBox_Base, FocusInHdl, weld::Widget&, void)
1561 {
1562  FillList();
1563 }
1564 
1565 IMPL_LINK(SvxFontNameBox_Base, KeyInputHdl, const KeyEvent&, rKEvt, bool)
1566 {
1567  return DoKeyInput(rKEvt);
1568 }
1569 
1570 bool SvxFontNameBox_Base::DoKeyInput(const KeyEvent& rKEvt)
1571 {
1572  bool bHandled = false;
1573 
1574  sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
1575 
1576  switch (nCode)
1577  {
1578  case KEY_TAB:
1579  bRelease = false;
1580  Select(true);
1581  break;
1582 
1583  case KEY_ESCAPE:
1584  set_active_or_entry_text(m_xWidget->get_saved_value());
1585  if (!m_rCtrl.IsInSidebar())
1586  {
1587  ReleaseFocus_Impl();
1588  bHandled = true;
1589  }
1590  EndPreview();
1591  break;
1592  }
1593 
1594  return bHandled;
1595 }
1596 
1597 bool SvxFontNameBox_Impl::DoKeyInput(const KeyEvent& rKEvt)
1598 {
1599  return SvxFontNameBox_Base::DoKeyInput(rKEvt) || ChildKeyInput(rKEvt);
1600 }
1601 
1602 IMPL_LINK_NOARG(SvxFontNameBox_Base, FocusOutHdl, weld::Widget&, void)
1603 {
1604  if (!m_xWidget->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus
1605  {
1606  set_active_or_entry_text(m_xWidget->get_saved_value());
1607  // send EndPreview
1608  EndPreview();
1609  }
1610 }
1611 
1612 void SvxFontNameBox_Impl::SetOptimalSize()
1613 {
1614  // set width in chars low so the size request will not be overridden
1615  m_xWidget->set_entry_width_chars(1);
1616  // tdf#132338 purely using this calculation to keep things their traditional width
1617  Size aSize(LogicToPixel(Size((COMBO_WIDTH_IN_CHARS +5) * 4, 0), MapMode(MapUnit::MapAppFont)));
1618  m_xWidget->set_size_request(aSize.Width(), -1);
1619 
1620  SetSizePixel(get_preferred_size());
1621 }
1622 
1623 void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1624 {
1625  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1626  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
1627  {
1628  SetOptimalSize();
1629  }
1630  else if ( ( rDCEvt.GetType() == DataChangedEventType::FONTS ) ||
1631  ( rDCEvt.GetType() == DataChangedEventType::DISPLAY ) )
1632  {
1633  // The old font list in shell has likely been destroyed at this point, so we need to get
1634  // the new one before doing anything further.
1635  lcl_GetDocFontList( &pFontList, this );
1636  }
1637 }
1638 
1639 void SvxFontNameBox_Base::ReleaseFocus_Impl()
1640 {
1641  if ( !bRelease )
1642  {
1643  bRelease = true;
1644  return;
1645  }
1646  if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
1647  m_xFrame->getContainerWindow()->setFocus();
1648 }
1649 
1650 void SvxFontNameBox_Base::EnableControls()
1651 {
1652  bool bEnableMRU = m_aHistory.get();
1653  sal_uInt16 nEntries = bEnableMRU ? MAX_MRU_FONTNAME_ENTRIES : 0;
1654 
1655  bool bNewWYSIWYG = m_aWYSIWYG.get();
1656  bool bOldWYSIWYG = m_xWidget->IsWYSIWYGEnabled();
1657 
1658  if (m_xWidget->get_max_mru_count() != nEntries || bNewWYSIWYG != bOldWYSIWYG)
1659  {
1660  // refill in the next GetFocus-Handler
1661  pFontList = nullptr;
1662  Clear();
1663  m_xWidget->set_max_mru_count(nEntries);
1664  }
1665 
1666  if (bNewWYSIWYG != bOldWYSIWYG)
1667  m_xWidget->EnableWYSIWYG(bNewWYSIWYG);
1668 }
1669 
1670 IMPL_LINK(SvxFontNameBox_Base, SelectHdl, weld::ComboBox&, rCombo, void)
1671 {
1672  Select(rCombo.changed_by_direct_pick()); // only when picked from the list
1673 }
1674 
1675 IMPL_LINK_NOARG(SvxFontNameBox_Base, ActivateHdl, weld::ComboBox&, bool)
1676 {
1677  Select(true);
1678  return true;
1679 }
1680 
1681 void SvxFontNameBox_Base::Select(bool bNonTravelSelect)
1682 {
1683  Sequence< PropertyValue > aArgs( 1 );
1684  std::unique_ptr<SvxFontItem> pFontItem;
1685  if ( pFontList )
1686  {
1687  FontMetric aFontMetric( pFontList->Get(m_xWidget->get_active_text(),
1688  aCurFont.GetWeight(),
1689  aCurFont.GetItalic() ) );
1690  aCurFont = aFontMetric;
1691 
1692  pFontItem.reset( new SvxFontItem( aFontMetric.GetFamilyType(),
1693  aFontMetric.GetFamilyName(),
1694  aFontMetric.GetStyleName(),
1695  aFontMetric.GetPitch(),
1696  aFontMetric.GetCharSet(),
1697  SID_ATTR_CHAR_FONT ) );
1698 
1699  Any a;
1700  pFontItem->QueryValue( a );
1701  aArgs[0].Value = a;
1702  }
1703 
1704  if (bNonTravelSelect)
1705  {
1706  CheckAndMarkUnknownFont();
1707  // #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1708  // This instance may be deleted in the meantime (i.e. when a dialog is opened
1709  // while in Dispatch()), accessing members will crash in this case.
1710  ReleaseFocus_Impl();
1711  EndPreview();
1712  if (pFontItem)
1713  {
1714  aArgs[0].Name = "CharFontName";
1715  SfxToolBoxControl::Dispatch( m_xDispatchProvider,
1716  ".uno:CharFontName",
1717  aArgs );
1718  }
1719  }
1720  else
1721  {
1722  if (pFontItem)
1723  {
1724  aArgs[0].Name = "CharPreviewFontName";
1725  SfxToolBoxControl::Dispatch( m_xDispatchProvider,
1726  ".uno:CharPreviewFontName",
1727  aArgs );
1728  }
1729  }
1730 }
1731 
1732 IMPL_LINK(SvxFontNameBox_Base, DumpAsPropertyTreeHdl, tools::JsonWriter&, rJsonWriter, void)
1733 {
1734  {
1735  auto entriesNode = rJsonWriter.startNode("entries");
1736  for (int i = 0, nEntryCount = m_xWidget->get_count(); i < nEntryCount; ++i)
1737  {
1738  auto entryNode = rJsonWriter.startNode("");
1739  rJsonWriter.put("", m_xWidget->get_text(i));
1740  }
1741  }
1742 
1743  int nSelectedEntry = m_xWidget->get_active();
1744  rJsonWriter.put("selectedCount", static_cast<sal_Int32>(nSelectedEntry == -1 ? 0 : 1));
1745 
1746  {
1747  auto selectedNode = rJsonWriter.startNode("selectedEntries");
1748  if (nSelectedEntry != -1)
1749  {
1750  auto entryNode = rJsonWriter.startNode("");
1751  rJsonWriter.put("", m_xWidget->get_text(nSelectedEntry));
1752  }
1753  }
1754 
1755  rJsonWriter.put("command", ".uno:CharFontName");
1756 }
1757 
1758 ColorWindow::ColorWindow(const OUString& rCommand,
1759  std::shared_ptr<PaletteManager> const & rPaletteManager,
1760  ColorStatus& rColorStatus,
1761  sal_uInt16 nSlotId,
1762  const Reference< XFrame >& rFrame,
1763  const MenuOrToolMenuButton& rMenuButton,
1764  TopLevelParentFunction const& rTopLevelParentFunction,
1765  ColorSelectFunction const & rColorSelectFunction)
1766  : WeldToolbarPopup(rFrame, rMenuButton.get_widget(), "svx/ui/colorwindow.ui", "palette_popup_window")
1767  , theSlotId(nSlotId)
1768  , maCommand(rCommand)
1769  , maMenuButton(rMenuButton)
1770  , mxPaletteManager(rPaletteManager)
1771  , mrColorStatus(rColorStatus)
1772  , maTopLevelParentFunction(rTopLevelParentFunction)
1773  , maColorSelectFunction(rColorSelectFunction)
1774  , mxColorSet(new SvxColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin", true)))
1775  , mxRecentColorSet(new SvxColorValueSet(nullptr))
1776  , mxPaletteListBox(m_xBuilder->weld_combo_box("palette_listbox"))
1777  , mxButtonAutoColor(m_xBuilder->weld_button("auto_color_button"))
1778  , mxButtonNoneColor(m_xBuilder->weld_button("none_color_button"))
1779  , mxButtonPicker(m_xBuilder->weld_button("color_picker_button"))
1780  , mxAutomaticSeparator(m_xBuilder->weld_widget("separator4"))
1781  , mxColorSetWin(new weld::CustomWeld(*m_xBuilder, "colorset", *mxColorSet))
1782  , mxRecentColorSetWin(new weld::CustomWeld(*m_xBuilder, "recent_colorset", *mxRecentColorSet))
1783  , mpDefaultButton(nullptr)
1784 {
1787 
1788  switch ( theSlotId )
1789  {
1790  case SID_ATTR_CHAR_COLOR_BACKGROUND:
1791  case SID_BACKGROUND_COLOR:
1792  case SID_ATTR_CHAR_BACK_COLOR:
1793  case SID_TABLE_CELL_BACKGROUND_COLOR:
1794  {
1795  mxButtonAutoColor->set_label( SvxResId( RID_SVXSTR_NOFILL ) );
1796  break;
1797  }
1798  case SID_AUTHOR_COLOR:
1799  {
1800  mxButtonAutoColor->set_label( SvxResId( RID_SVXSTR_BY_AUTHOR ) );
1801  break;
1802  }
1803  case SID_BMPMASK_COLOR:
1804  {
1805  mxButtonAutoColor->set_label( SvxResId( RID_SVXSTR_TRANSPARENT ) );
1806  break;
1807  }
1808  case SID_ATTR_CHAR_COLOR:
1809  case SID_ATTR_CHAR_COLOR2:
1810  case SID_EXTRUSION_3D_COLOR:
1811  {
1812  mxButtonAutoColor->set_label(EditResId(RID_SVXSTR_AUTOMATIC));
1813  break;
1814  }
1815  case SID_FM_CTL_PROPERTIES:
1816  {
1817  mxButtonAutoColor->set_label( SvxResId( RID_SVXSTR_DEFAULT ) );
1818  break;
1819  }
1820  default:
1821  {
1822  mxButtonAutoColor->hide();
1823  mxAutomaticSeparator->hide();
1824  break;
1825  }
1826  }
1827 
1828  mxPaletteListBox->connect_changed(LINK(this, ColorWindow, SelectPaletteHdl));
1829  std::vector<OUString> aPaletteList = mxPaletteManager->GetPaletteList();
1830  mxPaletteListBox->freeze();
1831  for (const auto& rPalette : aPaletteList)
1832  mxPaletteListBox->append_text(rPalette);
1833  mxPaletteListBox->thaw();
1834  OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
1835  mxPaletteListBox->set_active_text(aPaletteName);
1836  const int nSelectedEntry(mxPaletteListBox->get_active());
1837  if (nSelectedEntry != -1)
1838  mxPaletteManager->SetPalette(nSelectedEntry);
1839 
1840  mxButtonAutoColor->connect_clicked(LINK(this, ColorWindow, AutoColorClickHdl));
1841  mxButtonNoneColor->connect_clicked(LINK(this, ColorWindow, AutoColorClickHdl));
1842  mxButtonPicker->connect_clicked(LINK(this, ColorWindow, OpenPickerClickHdl));
1843 
1844  mxColorSet->SetSelectHdl(LINK( this, ColorWindow, SelectHdl));
1845  mxRecentColorSet->SetSelectHdl(LINK( this, ColorWindow, SelectHdl));
1846  m_xTopLevel->set_help_id(HID_POPUP_COLOR);
1847  mxColorSet->SetHelpId(HID_POPUP_COLOR_CTRL);
1848 
1849  mxPaletteManager->ReloadColorSet(*mxColorSet);
1850  const sal_uInt32 nMaxItems(SvxColorValueSet::getMaxRowCount() * SvxColorValueSet::getColumnCount());
1851  Size aSize = mxColorSet->layoutAllVisible(nMaxItems);
1852  mxColorSet->set_size_request(aSize.Width(), aSize.Height());
1853 
1854  mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
1855  aSize = mxRecentColorSet->layoutAllVisible(mxPaletteManager->GetRecentColorCount());
1856  mxRecentColorSet->set_size_request(aSize.Width(), aSize.Height());
1857 
1858  AddStatusListener( ".uno:ColorTableState" );
1860  if ( maCommand == ".uno:FrameLineColor" )
1861  {
1862  AddStatusListener( ".uno:BorderTLBR" );
1863  AddStatusListener( ".uno:BorderBLTR" );
1864  }
1865 }
1866 
1868 {
1869  if (mxColorSet->IsNoSelection() && mpDefaultButton)
1871  else
1872  mxColorSet->GrabFocus();
1873 }
1874 
1876 {
1877  mxButtonNoneColor->show();
1878 }
1879 
1881 {
1882 }
1883 
1885 {
1886  Color aColor = pColorSet->GetItemColor(pColorSet->GetSelectedItemId());
1887  OUString sColorName = pColorSet->GetItemText(pColorSet->GetSelectedItemId());
1888  return std::make_pair(aColor, sColorName);
1889 }
1890 
1891 namespace
1892 {
1893  NamedColor GetAutoColor(sal_uInt16 nSlotId)
1894  {
1895  Color aColor;
1896  OUString sColorName;
1897  switch (nSlotId)
1898  {
1899  case SID_ATTR_CHAR_COLOR_BACKGROUND:
1900  case SID_BACKGROUND_COLOR:
1901  case SID_ATTR_CHAR_BACK_COLOR:
1902  case SID_TABLE_CELL_BACKGROUND_COLOR:
1903  aColor = COL_TRANSPARENT;
1904  sColorName = SvxResId(RID_SVXSTR_NOFILL);
1905  break;
1906  case SID_AUTHOR_COLOR:
1907  aColor = COL_TRANSPARENT;
1908  sColorName = SvxResId(RID_SVXSTR_BY_AUTHOR);
1909  break;
1910  case SID_BMPMASK_COLOR:
1911  aColor = COL_TRANSPARENT;
1912  sColorName = SvxResId(RID_SVXSTR_TRANSPARENT);
1913  break;
1914  case SID_FM_CTL_PROPERTIES:
1915  aColor = COL_TRANSPARENT;
1916  sColorName = SvxResId(RID_SVXSTR_DEFAULT);
1917  break;
1918  case SID_ATTR_CHAR_COLOR:
1919  case SID_ATTR_CHAR_COLOR2:
1920  case SID_EXTRUSION_3D_COLOR:
1921  default:
1922  aColor = COL_AUTO;
1923  sColorName = EditResId(RID_SVXSTR_AUTOMATIC);
1924  break;
1925  }
1926 
1927  return std::make_pair(aColor, sColorName);
1928  }
1929 
1930  NamedColor GetNoneColor()
1931  {
1932  return std::make_pair(COL_NONE_COLOR, comphelper::LibreOfficeKit::isActive() ? SvxResId(RID_SVXSTR_INVISIBLE)
1933  : SvxResId(RID_SVXSTR_NONE));
1934  }
1935 }
1936 
1938 {
1939  if (!mxColorSet->IsNoSelection())
1940  return GetSelectEntryColor(mxColorSet.get());
1941  if (!mxRecentColorSet->IsNoSelection())
1942  return GetSelectEntryColor(mxRecentColorSet.get());
1943  if (mxButtonNoneColor.get() == mpDefaultButton)
1944  return GetNoneColor();
1945  return GetAutoColor();
1946 }
1947 
1948 IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, void)
1949 {
1950  NamedColor aNamedColor = GetSelectEntryColor(pColorSet);
1951 
1952  if (pColorSet != mxRecentColorSet.get())
1953  {
1954  mxPaletteManager->AddRecentColor(aNamedColor.first, aNamedColor.second);
1955  if (!maMenuButton.get_active())
1956  mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
1957  }
1958 
1959  maSelectedLink.Call(aNamedColor);
1960 
1961  // deliberate take a copy here in case maMenuButton.set_inactive
1962  // triggers a callback that destroys ourself
1963  ColorSelectFunction aColorSelectFunction(maColorSelectFunction);
1964  OUString sCommand(maCommand);
1965 
1966  maMenuButton.set_inactive();
1967 
1968  aColorSelectFunction(sCommand, aNamedColor);
1969 }
1970 
1971 IMPL_LINK_NOARG(ColorWindow, SelectPaletteHdl, weld::ComboBox&, void)
1972 {
1973  int nPos = mxPaletteListBox->get_active();
1974  mxPaletteManager->SetPalette( nPos );
1975  mxPaletteManager->ReloadColorSet(*mxColorSet);
1976  mxColorSet->layoutToGivenHeight(mxColorSet->GetOutputSizePixel().Height(), mxPaletteManager->GetColorCount());
1977 }
1978 
1980 {
1981  return ::GetAutoColor(theSlotId);
1982 }
1983 
1984 IMPL_LINK(ColorWindow, AutoColorClickHdl, weld::Button&, rButton, void)
1985 {
1986  NamedColor aNamedColor = &rButton == mxButtonAutoColor.get() ? GetAutoColor() : GetNoneColor();
1987 
1988  mxColorSet->SetNoSelection();
1989  mxRecentColorSet->SetNoSelection();
1990  mpDefaultButton = &rButton;
1991 
1992  maSelectedLink.Call(aNamedColor);
1993 
1994  // deliberate take a copy here in case maMenuButton.set_inactive
1995  // triggers a callback that destroys ourself
1996  ColorSelectFunction aColorSelectFunction(maColorSelectFunction);
1997  OUString sCommand(maCommand);
1998 
1999  maMenuButton.set_inactive();
2000 
2001  aColorSelectFunction(sCommand, aNamedColor);
2002 }
2003 
2004 IMPL_LINK_NOARG(ColorWindow, OpenPickerClickHdl, weld::Button&, void)
2005 {
2006  // copy before set_inactive
2007  auto nColor = GetSelectEntryColor().first;
2008  auto pParentWindow = maTopLevelParentFunction();
2009  OUString sCommand = maCommand;
2010  std::shared_ptr<PaletteManager> xPaletteManager(mxPaletteManager);
2011 
2012  maMenuButton.set_inactive();
2013 
2014  xPaletteManager->PopupColorPicker(pParentWindow, sCommand, nColor);
2015 }
2016 
2018 {
2019  mxColorSet->SetNoSelection();
2020  mxRecentColorSet->SetNoSelection();
2021  mpDefaultButton = nullptr;
2022 }
2023 
2025 {
2026  if (!mxColorSet->IsNoSelection())
2027  return false;
2028  if (!mxRecentColorSet->IsNoSelection())
2029  return false;
2030  return !mxButtonAutoColor->get_visible() && !mxButtonNoneColor->get_visible();
2031 }
2032 
2033 void ColorWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent )
2034 {
2035  if (rEvent.FeatureURL.Complete == ".uno:ColorTableState")
2036  {
2037  if (rEvent.IsEnabled && mxPaletteManager->GetPalette() == 0)
2038  {
2039  mxPaletteManager->ReloadColorSet(*mxColorSet);
2040  mxColorSet->layoutToGivenHeight(mxColorSet->GetOutputSizePixel().Height(), mxPaletteManager->GetColorCount());
2041  }
2042  }
2043  else
2044  {
2045  mrColorStatus.statusChanged(rEvent);
2047  }
2048 }
2049 
2051 {
2052  for (size_t i = 1; i <= pColorSet->GetItemCount(); ++i)
2053  {
2054  if (rColor == pColorSet->GetItemColor(i))
2055  {
2056  pColorSet->SelectItem(i);
2057  return true;
2058  }
2059  }
2060  return false;
2061 }
2062 
2063 void ColorWindow::SelectEntry(const NamedColor& rNamedColor)
2064 {
2065  SetNoSelection();
2066 
2067  const Color &rColor = rNamedColor.first;
2068 
2069  if (mxButtonAutoColor->get_visible() && (rColor == COL_TRANSPARENT || rColor == COL_AUTO))
2070  {
2072  return;
2073  }
2074 
2075  if (mxButtonNoneColor->get_visible() && rColor == COL_NONE_COLOR)
2076  {
2078  return;
2079  }
2080 
2081  // try current palette
2082  bool bFoundColor = SelectValueSetEntry(mxColorSet.get(), rColor);
2083  // try recently used
2084  if (!bFoundColor)
2085  bFoundColor = SelectValueSetEntry(mxRecentColorSet.get(), rColor);
2086  // if it's not there, add it there now to the end of the recently used
2087  // so its available somewhere handy, but not without trashing the
2088  // whole recently used
2089  if (!bFoundColor)
2090  {
2091  const OUString& rColorName = rNamedColor.second;
2092  mxPaletteManager->AddRecentColor(rColor, rColorName, false);
2093  mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
2094  SelectValueSetEntry(mxRecentColorSet.get(), rColor);
2095  }
2096 }
2097 
2098 void ColorWindow::SelectEntry(const Color& rColor)
2099 {
2100  OUString sColorName = "#" + rColor.AsRGBHexString().toAsciiUpperCase();
2101  ColorWindow::SelectEntry(std::make_pair(rColor, sColorName));
2102 }
2103 
2106  maTLBRColor( COL_TRANSPARENT ),
2107  maBLTRColor( COL_TRANSPARENT )
2108 {
2109 }
2110 
2112 {
2113 }
2114 
2115 void ColorStatus::statusChanged( const css::frame::FeatureStateEvent& rEvent )
2116 {
2117  Color aColor( COL_TRANSPARENT );
2118  css::table::BorderLine2 aTable;
2119 
2120  if ( rEvent.State >>= aTable )
2121  {
2122  SvxBorderLine aLine;
2123  SvxBoxItem::LineToSvxLine( aTable, aLine, false );
2124  if ( !aLine.isEmpty() )
2125  aColor = aLine.GetColor();
2126  }
2127  else
2128  rEvent.State >>= aColor;
2129 
2130  if ( rEvent.FeatureURL.Path == "BorderTLBR" )
2131  maTLBRColor = aColor;
2132  else if ( rEvent.FeatureURL.Path == "BorderBLTR" )
2133  maBLTRColor = aColor;
2134  else
2135  maColor = aColor;
2136 }
2137 
2139 {
2140  Color aColor( maColor );
2141 
2142  if ( maTLBRColor != COL_TRANSPARENT )
2143  {
2144  if ( aColor != maTLBRColor && aColor != COL_TRANSPARENT )
2145  return COL_TRANSPARENT;
2146  aColor = maTLBRColor;
2147  }
2148 
2149  if ( maBLTRColor != COL_TRANSPARENT )
2150  {
2151  if ( aColor != maBLTRColor && aColor != COL_TRANSPARENT )
2152  return COL_TRANSPARENT;
2153  return maBLTRColor;
2154  }
2155 
2156  return aColor;
2157 }
2158 
2159 
2160 SvxFrameWindow_Impl::SvxFrameWindow_Impl(SvxFrameToolBoxControl* pControl, weld::Widget* pParent)
2161  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/floatingframeborder.ui", "FloatingFrameBorder")
2162  , mxControl(pControl)
2163  , mxFrameSet(new SvxFrmValueSet_Impl)
2164  , mxFrameSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxFrameSet))
2165  , bParagraphMode(false)
2166 {
2167  mxFrameSet->SetStyle(WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT);
2168  AddStatusListener(".uno:BorderReducedMode");
2169  InitImageList();
2170 
2171  /*
2172  * 1 2 3 4 5
2173  * ------------------------------------------------------
2174  * NONE LEFT RIGHT LEFTRIGHT DIAGONALLEFT
2175  * TOP BOTTOM TOPBOTTOM OUTER DIAGONALRIGHT
2176  * ------------------------------------------------------
2177  * HOR HORINNER VERINNER ALL CRISSCROSS <- can be switched of via bParagraphMode
2178  */
2179 
2180  sal_uInt16 i = 0;
2181 
2182  for ( i=1; i<11; i++ )
2183  mxFrameSet->InsertItem(i, Image(aImgVec[i-1].first), aImgVec[i-1].second);
2184 
2185  //bParagraphMode should have been set in StateChanged
2186  if ( !bParagraphMode )
2187  for ( i = 11; i < 16; i++ )
2188  mxFrameSet->InsertItem(i, Image(aImgVec[i-1].first), aImgVec[i-1].second);
2189 
2190  mxFrameSet->SetColCount( 5 );
2191  mxFrameSet->SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) );
2192  CalcSizeValueSet();
2193 
2194  mxFrameSet->SetHelpId( HID_POPUP_FRAME );
2195  mxFrameSet->SetAccessibleName( SvxResId(RID_SVXSTR_FRAME) );
2196 }
2197 
2198 namespace {
2199 
2200 enum class FrmValidFlags {
2201  NONE = 0x00,
2202  Left = 0x01,
2203  Right = 0x02,
2204  Top = 0x04,
2205  Bottom = 0x08,
2206  HInner = 0x10,
2207  VInner = 0x20,
2208  AllMask = 0x3f,
2209 };
2210 
2211 }
2212 
2213 namespace o3tl {
2214  template<> struct typed_flags<FrmValidFlags> : is_typed_flags<FrmValidFlags, 0x3f> {};
2215 }
2216 
2217 // By default unset lines remain unchanged.
2218 // Via Shift unset lines are reset
2219 
2220 IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void)
2221 {
2222  SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER );
2223  SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER );
2224  SvxBorderLine theDefLine;
2225 
2226  // diagonal left border
2227  SvxBorderLine dLeftBorderLine( nullptr, 1 );
2228  SvxLineItem dLeftLineItem( SID_ATTR_BORDER_DIAG_TLBR );
2229 
2230  // diagonal right border
2231  SvxBorderLine dRightBorderLine( nullptr, 1 );
2232  SvxLineItem dRightLineItem( SID_ATTR_BORDER_DIAG_BLTR );
2233 
2234  SvxBorderLine *pLeft = nullptr,
2235  *pRight = nullptr,
2236  *pTop = nullptr,
2237  *pBottom = nullptr;
2238  sal_uInt16 nSel = mxFrameSet->GetSelectedItemId();
2239  sal_uInt16 nModifier = mxFrameSet->GetModifier();
2240  FrmValidFlags nValidFlags = FrmValidFlags::NONE;
2241 
2242  theDefLine.GuessLinesWidths(theDefLine.GetBorderLineStyle(),
2244  switch ( nSel )
2245  {
2246  case 1: nValidFlags |= FrmValidFlags::AllMask;
2247  // set nullptr to remove diagonal lines
2248  dLeftLineItem.SetLine(nullptr);
2249  dRightLineItem.SetLine(nullptr);
2250  break; // NONE
2251  case 2: pLeft = &theDefLine;
2252  nValidFlags |= FrmValidFlags::Left;
2253  break; // LEFT
2254  case 3: pRight = &theDefLine;
2255  nValidFlags |= FrmValidFlags::Right;
2256  break; // RIGHT
2257  case 4: pLeft = pRight = &theDefLine;
2258  nValidFlags |= FrmValidFlags::Right|FrmValidFlags::Left;
2259  break; // LEFTRIGHT
2260  case 5: dLeftLineItem.SetLine(&dLeftBorderLine);
2261  break; // DIAGONAL LEFT
2262  case 6: pTop = &theDefLine;
2263  nValidFlags |= FrmValidFlags::Top;
2264  break; // TOP
2265  case 7: pBottom = &theDefLine;
2266  nValidFlags |= FrmValidFlags::Bottom;
2267  break; // BOTTOM
2268  case 8: pTop = pBottom = &theDefLine;
2269  nValidFlags |= FrmValidFlags::Bottom|FrmValidFlags::Top;
2270  break; // TOPBOTTOM
2271  case 9: pLeft = pRight = pTop = pBottom = &theDefLine;
2272  nValidFlags |= FrmValidFlags::Left | FrmValidFlags::Right | FrmValidFlags::Top | FrmValidFlags::Bottom;
2273  break; // OUTER
2274  case 10:
2275  dRightLineItem.SetLine(&dRightBorderLine);
2276  break; // DIAGONAL RIGHT
2277 
2278  // Inner Table:
2279  case 11: // HOR
2280  pTop = pBottom = &theDefLine;
2281  aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::HORI );
2282  aBorderInner.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
2283  nValidFlags |= FrmValidFlags::HInner|FrmValidFlags::Top|FrmValidFlags::Bottom;
2284  break;
2285 
2286  case 12: // HORINNER
2287  pLeft = pRight = pTop = pBottom = &theDefLine;
2288  aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::HORI );
2289  aBorderInner.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
2290  nValidFlags |= FrmValidFlags::Right|FrmValidFlags::Left|FrmValidFlags::HInner|FrmValidFlags::Top|FrmValidFlags::Bottom;
2291  break;
2292 
2293  case 13: // VERINNER
2294  pLeft = pRight = pTop = pBottom = &theDefLine;
2295  aBorderInner.SetLine( nullptr, SvxBoxInfoItemLine::HORI );
2296  aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::VERT );
2297  nValidFlags |= FrmValidFlags::Right|FrmValidFlags::Left|FrmValidFlags::VInner|FrmValidFlags::Top|FrmValidFlags::Bottom;
2298  break;
2299 
2300  case 14: // ALL
2301  pLeft = pRight = pTop = pBottom = &theDefLine;
2302  aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::HORI );
2303  aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::VERT );
2304  nValidFlags |= FrmValidFlags::AllMask;
2305  break;
2306 
2307  case 15:
2308  // set both diagonal lines to draw criss-cross line
2309  dLeftLineItem.SetLine(&dLeftBorderLine);
2310  dRightLineItem.SetLine(&dRightBorderLine);
2311  break; // CRISS-CROSS
2312 
2313  default:
2314  break;
2315  }
2316 
2317  if (nSel == 5)
2318  {
2319  // apply diagonal left border
2320  Any a;
2321  Sequence< PropertyValue > aArgs( 1 );
2322  aArgs[0].Name = "BorderTLBR";
2323  dLeftLineItem.QueryValue( a );
2324  aArgs[0].Value = a;
2325 
2326  mxControl->dispatchCommand( ".uno:BorderTLBR", aArgs );
2327  }
2328  else if (nSel == 10)
2329  {
2330  // apply diagonal right border
2331  Any a;
2332  Sequence< PropertyValue > aArgs( 1 );
2333  aArgs[0].Name = "BorderBLTR";
2334  dRightLineItem.QueryValue( a );
2335  aArgs[0].Value = a;
2336 
2337  mxControl->dispatchCommand( ".uno:BorderBLTR", aArgs );
2338  }
2339  else if (nSel == 15)
2340  {
2341  // to draw criss-cross line,
2342  // we need to set diagonal left and
2343  // diagonal right border together
2344 
2345  // apply diagonal left border (TLBR)
2346  Any aLeft;
2347  Sequence< PropertyValue > aArgsTLBR( 1 );
2348  aArgsTLBR[0].Name = "BorderTLBR";
2349  dLeftLineItem.QueryValue( aLeft );
2350  aArgsTLBR[0].Value = aLeft;
2351 
2352  // apply diagonal right border (BLTR)
2353  Any aRight;
2354  Sequence< PropertyValue > aArgsBLTR( 1 );
2355  aArgsBLTR[0].Name = "BorderBLTR";
2356  dRightLineItem.QueryValue( aRight );
2357  aArgsBLTR[0].Value = aRight;
2358 
2359  // execute dispatchCommand for both of them
2360  mxControl->dispatchCommand( ".uno:BorderTLBR", aArgsTLBR );
2361  mxControl->dispatchCommand( ".uno:BorderBLTR", aArgsBLTR );
2362  }
2363  else
2364  {
2365  aBorderOuter.SetLine( pLeft, SvxBoxItemLine::LEFT );
2366  aBorderOuter.SetLine( pRight, SvxBoxItemLine::RIGHT );
2367  aBorderOuter.SetLine( pTop, SvxBoxItemLine::TOP );
2368  aBorderOuter.SetLine( pBottom, SvxBoxItemLine::BOTTOM );
2369 
2370  if(nModifier == KEY_SHIFT)
2371  nValidFlags |= FrmValidFlags::AllMask;
2372  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::TOP, bool(nValidFlags&FrmValidFlags::Top ));
2373  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, bool(nValidFlags&FrmValidFlags::Bottom ));
2374  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, bool(nValidFlags&FrmValidFlags::Left));
2375  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, bool(nValidFlags&FrmValidFlags::Right ));
2376  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::HORI, bool(nValidFlags&FrmValidFlags::HInner ));
2377  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::VERT, bool(nValidFlags&FrmValidFlags::VInner));
2378  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
2379  aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISABLE, false );
2380 
2381  // if nSel == 1, we should remove all lines from the cell.
2382  // additionally, we should remove diagonal borders here,
2383  // because diagonal left and right borders are NOT
2384  // the member of aBorderOuter and aBorderInner.
2385  if (nSel == 1)
2386  {
2387  // remove left diagonal line
2388  {
2389  Any a;
2390  Sequence< PropertyValue > aArgs( 1 );
2391  aArgs[0].Name = "BorderTLBR";
2392  dLeftLineItem.QueryValue( a );
2393  aArgs[0].Value = a;
2394 
2395  mxControl->dispatchCommand( ".uno:BorderTLBR", aArgs );
2396  }
2397 
2398  // remove right diagonal line
2399  {
2400  Any a;
2401  Sequence< PropertyValue > aArgs( 1 );
2402  aArgs[0].Name = "BorderBLTR";
2403  dRightLineItem.QueryValue( a );
2404  aArgs[0].Value = a;
2405 
2406  mxControl->dispatchCommand( ".uno:BorderBLTR", aArgs );
2407  }
2408  }
2409 
2410  Any a;
2411  Sequence< PropertyValue > aArgs( 2 );
2412  aArgs[0].Name = "OuterBorder";
2413  aBorderOuter.QueryValue( a );
2414  aArgs[0].Value = a;
2415  aArgs[1].Name = "InnerBorder";
2416  aBorderInner.QueryValue( a );
2417  aArgs[1].Value = a;
2418 
2419  mxControl->dispatchCommand( ".uno:SetBorderStyle", aArgs );
2420  }
2421 
2422  if (mxFrameSet)
2423  {
2424  /* #i33380# Moved the following line above the Dispatch() call.
2425  This instance may be deleted in the meantime (i.e. when a dialog is opened
2426  while in Dispatch()), accessing members will crash in this case. */
2427  mxFrameSet->SetNoSelection();
2428  }
2429 
2430  mxControl->EndPopupMode();
2431 }
2432 
2433 void SvxFrameWindow_Impl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
2434 {
2435  if ( rEvent.FeatureURL.Complete != ".uno:BorderReducedMode" )
2436  return;
2437 
2438  bool bValue;
2439  if ( !(rEvent.State >>= bValue) )
2440  return;
2441 
2442  bParagraphMode = bValue;
2443  //initial calls mustn't insert or remove elements
2444  if(!mxFrameSet->GetItemCount())
2445  return;
2446 
2447  bool bTableMode = ( mxFrameSet->GetItemCount() == 15 );
2448  bool bResize = false;
2449 
2450  if ( bTableMode && bParagraphMode )
2451  {
2452  for ( sal_uInt16 i = 11; i < 16; i++ )
2453  mxFrameSet->RemoveItem(i);
2454  bResize = true;
2455  }
2456  else if ( !bTableMode && !bParagraphMode )
2457  {
2458  for ( sal_uInt16 i = 11; i < 16; i++ )
2459  mxFrameSet->InsertItem(i, Image(aImgVec[i-1].first), aImgVec[i-1].second);
2460  bResize = true;
2461  }
2462 
2463  if ( bResize )
2464  {
2465  CalcSizeValueSet();
2466  }
2467 }
2468 
2469 void SvxFrameWindow_Impl::CalcSizeValueSet()
2470 {
2471  weld::DrawingArea* pDrawingArea = mxFrameSet->GetDrawingArea();
2472  const OutputDevice& rDevice = pDrawingArea->get_ref_device();
2473  Size aItemSize( 20 * rDevice.GetDPIScaleFactor(), 20 * rDevice.GetDPIScaleFactor() );
2474  Size aSize = mxFrameSet->CalcWindowSizePixel( aItemSize );
2475  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
2476  mxFrameSet->SetOutputSizePixel(aSize);
2477 }
2478 
2479 void SvxFrameWindow_Impl::InitImageList()
2480 {
2481  aImgVec = {
2482  {BitmapEx(RID_SVXBMP_FRAME1), SvxResId(RID_SVXSTR_TABLE_PRESET_NONE)},
2483  {BitmapEx(RID_SVXBMP_FRAME2), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYLEFT)},
2484  {BitmapEx(RID_SVXBMP_FRAME3), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYRIGHT)},
2485  {BitmapEx(RID_SVXBMP_FRAME4), SvxResId(RID_SVXSTR_PARA_PRESET_LEFTRIGHT)},
2486  {BitmapEx(RID_SVXBMP_FRAME14), SvxResId(RID_SVXSTR_PARA_PRESET_DIAGONALLEFT)}, // diagonal left border
2487 
2488  {BitmapEx(RID_SVXBMP_FRAME5), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYTOP)},
2489  {BitmapEx(RID_SVXBMP_FRAME6), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYTBOTTOM)},
2490  {BitmapEx(RID_SVXBMP_FRAME7), SvxResId(RID_SVXSTR_PARA_PRESET_TOPBOTTOM)},
2491  {BitmapEx(RID_SVXBMP_FRAME8), SvxResId(RID_SVXSTR_TABLE_PRESET_ONLYOUTER)},
2492  {BitmapEx(RID_SVXBMP_FRAME13), SvxResId(RID_SVXSTR_PARA_PRESET_DIAGONALRIGHT)}, // diagonal right border
2493 
2494  {BitmapEx(RID_SVXBMP_FRAME9), SvxResId(RID_SVXSTR_PARA_PRESET_TOPBOTTOMHORI)},
2495  {BitmapEx(RID_SVXBMP_FRAME10), SvxResId(RID_SVXSTR_TABLE_PRESET_OUTERHORI)},
2496  {BitmapEx(RID_SVXBMP_FRAME11), SvxResId(RID_SVXSTR_TABLE_PRESET_OUTERVERI)},
2497  {BitmapEx(RID_SVXBMP_FRAME12), SvxResId(RID_SVXSTR_TABLE_PRESET_OUTERALL)},
2498  {BitmapEx(RID_SVXBMP_FRAME15), SvxResId(RID_SVXSTR_PARA_PRESET_CRISSCROSS)} // criss-cross border
2499  };
2500 }
2501 
2502 static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
2503 {
2504  return SvxBorderLine::threeDMediumColor( aMain );
2505 }
2506 
2507 SvxLineWindow_Impl::SvxLineWindow_Impl(SvxFrameToolBoxControl* pControl, weld::Widget* pParent)
2508  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/floatingframeborder.ui", "FloatingFrameBorder")
2509  , m_xControl(pControl)
2510  , m_xLineStyleLb(new LineListBox)
2511  , m_xLineStyleLbWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xLineStyleLb))
2512  , m_bIsWriter(false)
2513 {
2514  try
2515  {
2516  Reference< lang::XServiceInfo > xServices(m_xFrame->getController()->getModel(), UNO_QUERY_THROW);
2517  m_bIsWriter = xServices->supportsService("com.sun.star.text.TextDocument");
2518  }
2519  catch(const uno::Exception& )
2520  {
2521  }
2522 
2523  m_xLineStyleLb->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_TABSTOP) );
2524 
2525  m_xLineStyleLb->SetSourceUnit( FieldUnit::TWIP );
2526  m_xLineStyleLb->SetNone( comphelper::LibreOfficeKit::isActive() ? SvxResId(RID_SVXSTR_INVISIBLE)
2527  :SvxResId(RID_SVXSTR_NONE) );
2528 
2529  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::SOLID ), SvxBorderLineStyle::SOLID );
2530  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::DOTTED ), SvxBorderLineStyle::DOTTED );
2531  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::DASHED ), SvxBorderLineStyle::DASHED );
2532 
2533  // Double lines
2534  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::DOUBLE ), SvxBorderLineStyle::DOUBLE );
2535  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::THINTHICK_SMALLGAP ), SvxBorderLineStyle::THINTHICK_SMALLGAP, 20 );
2536  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::THINTHICK_MEDIUMGAP ), SvxBorderLineStyle::THINTHICK_MEDIUMGAP );
2537  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::THINTHICK_LARGEGAP ), SvxBorderLineStyle::THINTHICK_LARGEGAP );
2538  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::THICKTHIN_SMALLGAP ), SvxBorderLineStyle::THICKTHIN_SMALLGAP, 20 );
2539  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::THICKTHIN_MEDIUMGAP ), SvxBorderLineStyle::THICKTHIN_MEDIUMGAP );
2540  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::THICKTHIN_LARGEGAP ), SvxBorderLineStyle::THICKTHIN_LARGEGAP );
2541 
2542  // Engraved / Embossed
2543  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::EMBOSSED ), SvxBorderLineStyle::EMBOSSED, 15,
2544  &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor,
2545  &lcl_mediumColor );
2546  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::ENGRAVED ), SvxBorderLineStyle::ENGRAVED, 15,
2547  &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor,
2548  &lcl_mediumColor );
2549 
2550  // Inset / Outset
2551  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::OUTSET ), SvxBorderLineStyle::OUTSET, 10,
2552  &SvxBorderLine::lightColor, &SvxBorderLine::darkColor );
2553  m_xLineStyleLb->InsertEntry( SvxBorderLine::getWidthImpl( SvxBorderLineStyle::INSET ), SvxBorderLineStyle::INSET, 10,
2554  &SvxBorderLine::darkColor, &SvxBorderLine::lightColor );
2555  Size aSize = m_xLineStyleLb->SetWidth( 20 ); // 1pt by default
2556 
2557  m_xLineStyleLb->SetSelectHdl( LINK( this, SvxLineWindow_Impl, SelectHdl ) );
2558 
2559  m_xContainer->set_help_id(HID_POPUP_LINE);
2560 
2561  aSize.AdjustWidth(6);
2562  aSize.AdjustHeight(6);
2563  aSize = m_xLineStyleLb->CalcWindowSizePixel(aSize);
2564  m_xLineStyleLb->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
2565  m_xLineStyleLb->SetOutputSizePixel(aSize);
2566 }
2567 
2568 IMPL_LINK_NOARG(SvxLineWindow_Impl, SelectHdl, ValueSet*, void)
2569 {
2570  SvxLineItem aLineItem( SID_FRAME_LINESTYLE );
2571  SvxBorderLineStyle nStyle = m_xLineStyleLb->GetSelectEntryStyle();
2572 
2573  if ( m_xLineStyleLb->GetSelectItemPos( ) > 0 )
2574  {
2575  SvxBorderLine aTmp;
2576  aTmp.SetBorderLineStyle( nStyle );
2577  aTmp.SetWidth( 20 ); // TODO Make it depend on a width field
2578  aLineItem.SetLine( &aTmp );
2579  }
2580  else
2581  aLineItem.SetLine( nullptr );
2582 
2583  Any a;
2584  Sequence< PropertyValue > aArgs( 1 );
2585  aArgs[0].Name = "LineStyle";
2586  aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 );
2587  aArgs[0].Value = a;
2588 
2589  m_xControl->dispatchCommand( ".uno:LineStyle", aArgs );
2590 
2591  m_xControl->EndPopupMode();
2592 }
2593 
2595  const Reference< XDispatchProvider >& rDispatchProvider,
2596  sal_uInt16 nSlotId, // Family-ID
2597  const OUString& rCommand, // .uno: command bound to this item
2598  SvxStyleToolBoxControl& rTbxCtl ) // controller instance, which the item is assigned to.
2599  : SfxStatusListener( rDispatchProvider, nSlotId, rCommand ),
2600  rControl( rTbxCtl )
2601 {
2602 }
2603 
2605  SfxItemState eState, const SfxPoolItem* pState )
2606 {
2607  switch ( GetId() )
2608  {
2609  case SID_STYLE_FAMILY1:
2610  case SID_STYLE_FAMILY2:
2611  case SID_STYLE_FAMILY3:
2612  case SID_STYLE_FAMILY4:
2613  case SID_STYLE_FAMILY5:
2614  {
2615  const sal_uInt16 nIdx = GetId() - SID_STYLE_FAMILY_START;
2616 
2617  if ( SfxItemState::DEFAULT == eState )
2618  {
2619  const SfxTemplateItem* pStateItem =
2620  dynamic_cast<const SfxTemplateItem*>( pState );
2621  DBG_ASSERT( pStateItem != nullptr, "SfxTemplateItem expected" );
2622  rControl.SetFamilyState( nIdx, pStateItem );
2623  }
2624  else
2625  rControl.SetFamilyState( nIdx, nullptr );
2626  break;
2627  }
2628  }
2629 }
2630 
2632 {
2633  OUString aClearForm;
2634  OUString aMore;
2635  ::std::vector< std::pair< OUString, OUString > > aDefaultStyles;
2638 
2640  std::unique_ptr<SvxStyleBox_Base> m_xWeldBox;
2641  SvxStyleBox_Base* m_pBox;
2642 
2644  :aClearForm ( SvxResId( RID_SVXSTR_CLEARFORM ) )
2645  ,aMore ( SvxResId( RID_SVXSTR_MORE_STYLES ) )
2646  ,bSpecModeWriter ( false )
2647  ,bSpecModeCalc ( false )
2648  ,m_pBox ( nullptr )
2649  {
2650 
2651 
2652  }
2654  {
2655  aDefaultStyles.clear();
2656 
2657  //now convert the default style names to the localized names
2658  try
2659  {
2660  Reference< style::XStyleFamiliesSupplier > xStylesSupplier( xModel, UNO_QUERY_THROW );
2661  Reference< lang::XServiceInfo > xServices( xModel, UNO_QUERY_THROW );
2662  bSpecModeWriter = xServices->supportsService("com.sun.star.text.TextDocument");
2663  if(bSpecModeWriter)
2664  {
2666  xStylesSupplier->getStyleFamilies()->getByName("ParagraphStyles") >>=
2667  xParaStyles;
2668  static const std::vector<OUString> aWriterStyles =
2669  {
2670  "Standard",
2671  "Text body",
2672  "Title",
2673  "Subtitle",
2674  "Heading 1",
2675  "Heading 2",
2676  "Heading 3",
2677  "Heading 4",
2678  "Quotations",
2679  "Preformatted Text"
2680  };
2681  for( const OUString& aStyle: aWriterStyles )
2682  {
2683  try
2684  {
2686  xParaStyles->getByName( aStyle ) >>= xStyle;
2687  OUString sName;
2688  xStyle->getPropertyValue("DisplayName") >>= sName;
2689  if( !sName.isEmpty() )
2690  aDefaultStyles.push_back(
2691  std::pair<OUString, OUString>(aStyle, sName) );
2692  }
2693  catch( const uno::Exception& )
2694  {}
2695  }
2696 
2697  }
2698  else if( (
2699  bSpecModeCalc = xServices->supportsService(
2700  "com.sun.star.sheet.SpreadsheetDocument")))
2701  {
2702  static const char* aCalcStyles[] =
2703  {
2704  "Default",
2705  "Accent 1",
2706  "Accent 2",
2707  "Accent 3",
2708  "Heading 1",
2709  "Heading 2",
2710  "Result"
2711  };
2713  xStylesSupplier->getStyleFamilies()->getByName("CellStyles") >>= xCellStyles;
2714  for(const char* pCalcStyle : aCalcStyles)
2715  {
2716  try
2717  {
2718  const OUString sStyleName( OUString::createFromAscii( pCalcStyle ) );
2719  if( xCellStyles->hasByName( sStyleName ) )
2720  {
2721  Reference< beans::XPropertySet > xStyle( xCellStyles->getByName( sStyleName), UNO_QUERY_THROW );
2722  OUString sName;
2723  xStyle->getPropertyValue("DisplayName") >>= sName;
2724  if( !sName.isEmpty() )
2725  aDefaultStyles.push_back(
2726  std::pair<OUString, OUString>(sStyleName, sName) );
2727  }
2728  }
2729  catch( const uno::Exception& )
2730  {}
2731  }
2732  }
2733  }
2734  catch(const uno::Exception& )
2735  {
2736  OSL_FAIL("error while initializing style names");
2737  }
2738  }
2739 };
2740 
2741 // mapping table from bound items. BE CAREFUL this table must be in the
2742 // same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n
2743 // MAX_FAMILIES must also be correctly set!
2745 {
2746  ".uno:CharStyle",
2747  ".uno:ParaStyle",
2748  ".uno:FrameStyle",
2749  ".uno:PageStyle",
2750  ".uno:TemplateFamily5"
2751 };
2752 
2754  : pImpl(new Impl)
2755  , pStyleSheetPool(nullptr)
2756  , nActFamily(0xffff)
2757 {
2758  for (sal_uInt16 i = 0; i < MAX_FAMILIES; ++i)
2759  {
2760  m_xBoundItems[i].clear();
2761  pFamilyState[i] = nullptr;
2762  }
2763 }
2764 
2766 {
2767 }
2768 
2769 void SAL_CALL SvxStyleToolBoxControl::initialize(const Sequence<Any>& rArguments)
2770 {
2772 
2773  // After initialize we should have a valid frame member where we can retrieve our
2774  // dispatch provider.
2775  if ( !m_xFrame.is() )
2776  return;
2777 
2778  pImpl->InitializeStyles(m_xFrame->getController()->getModel());
2779  Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY );
2780  for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
2781  {
2782  m_xBoundItems[i] = new SfxStyleControllerItem_Impl( xDispatchProvider,
2783  SID_STYLE_FAMILY_START + i,
2784  OUString::createFromAscii( StyleSlotToStyleCommand[i] ),
2785  *this );
2786  pFamilyState[i] = nullptr;
2787  }
2788 }
2789 
2790 // XComponent
2792 {
2794 
2795  SolarMutexGuard aSolarMutexGuard;
2796  pImpl->m_xVclBox.disposeAndClear();
2797  pImpl->m_xWeldBox.reset();
2798  pImpl->m_pBox = nullptr;
2799 
2801  {
2802  if (!pBoundItem)
2803  continue;
2804  pBoundItem->UnBind();
2805  }
2806  unbindListener();
2807 
2808  for( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
2809  {
2810  if ( m_xBoundItems[i].is() )
2811  {
2812  try
2813  {
2814  m_xBoundItems[i]->dispose();
2815  }
2816  catch ( Exception& )
2817  {
2818  }
2819 
2820  m_xBoundItems[i].clear();
2821  }
2822  pFamilyState[i].reset();
2823  }
2824  pStyleSheetPool = nullptr;
2825  pImpl.reset();
2826 }
2827 
2829 {
2830  return "com.sun.star.comp.svx.StyleToolBoxControl";
2831 }
2832 
2833 sal_Bool SvxStyleToolBoxControl::supportsService( const OUString& rServiceName )
2834 {
2835  return cppu::supportsService( this, rServiceName );
2836 }
2837 
2839 {
2840  return { "com.sun.star.frame.ToolbarController" };
2841 }
2842 
2843 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
2845  css::uno::XComponentContext*,
2846  css::uno::Sequence<css::uno::Any> const & )
2847 {
2848  return cppu::acquire( new SvxStyleToolBoxControl() );
2849 }
2850 
2852 {
2854  pBoundItem->ReBind();
2855  bindListener();
2856 }
2857 
2859 {
2860  switch ( nActFamily-1 + SID_STYLE_FAMILY_START )
2861  {
2862  case SID_STYLE_FAMILY1: return SfxStyleFamily::Char;
2863  case SID_STYLE_FAMILY2: return SfxStyleFamily::Para;
2864  case SID_STYLE_FAMILY3: return SfxStyleFamily::Frame;
2865  case SID_STYLE_FAMILY4: return SfxStyleFamily::Page;
2866  case SID_STYLE_FAMILY5: return SfxStyleFamily::Pseudo;
2867  default:
2868  OSL_FAIL( "unknown style family" );
2869  break;
2870  }
2871  return SfxStyleFamily::Para;
2872 }
2873 
2875 {
2876  SvxStyleBox_Base* pBox = pImpl->m_pBox;
2877 
2878  DBG_ASSERT( pStyleSheetPool, "StyleSheetPool not found!" );
2879  DBG_ASSERT( pBox, "Control not found!" );
2880 
2881  if ( !(pStyleSheetPool && pBox && nActFamily!=0xffff) )
2882  return;
2883 
2884  const SfxStyleFamily eFamily = GetActFamily();
2885  SfxStyleSheetBase* pStyle = nullptr;
2886  bool bDoFill = false;
2887 
2888  auto xIter = pStyleSheetPool->CreateIterator(eFamily, SfxStyleSearchBits::Used);
2889  sal_uInt16 nCount = xIter->Count();
2890 
2891  // Check whether fill is necessary
2892  pStyle = xIter->First();
2895  if ( nCount != pBox->get_count() )
2896  {
2897  bDoFill = true;
2898  }
2899  else
2900  {
2901  sal_uInt16 i= 0;
2902  while ( pStyle && !bDoFill )
2903  {
2904  bDoFill = ( pBox->get_text(i) != pStyle->GetName() );
2905  pStyle = xIter->Next();
2906  i++;
2907  }
2908  }
2909 
2910  if ( !bDoFill )
2911  return;
2912 
2913  OUString aStrSel(pBox->get_active_text());
2914  pBox->freeze();
2915  pBox->clear();
2916 
2917  std::vector<OUString> aStyles;
2918 
2919  {
2920  pStyle = xIter->Next();
2921 
2922  if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
2923  {
2924  while ( pStyle )
2925  {
2926  // sort out default styles
2927  bool bInsert = true;
2928  OUString aName( pStyle->GetName() );
2929  for( auto const & _i: pImpl->aDefaultStyles )
2930  {
2931  if( _i.first == aName || _i.second == aName )
2932  {
2933  bInsert = false;
2934  break;
2935  }
2936  }
2937 
2938  if( bInsert )
2939  aStyles.push_back(aName);
2940  pStyle = xIter->Next();
2941  }
2942  }
2943  else
2944  {
2945  while ( pStyle )
2946  {
2947  aStyles.push_back(pStyle->GetName());
2948  pStyle = xIter->Next();
2949  }
2950  }
2951  }
2952 
2953  if (pImpl->bSpecModeWriter || pImpl->bSpecModeCalc)
2954  {
2955  pBox->append_text(pImpl->aClearForm);
2956  pBox->insert_separator(1, "separator");
2957 
2958  // insert default styles
2959  for (const auto &rStyle : pImpl->aDefaultStyles)
2960  pBox->append_text(rStyle.second);
2961  }
2962 
2963  std::sort(aStyles.begin(), aStyles.end());
2964 
2965  for (const auto& rStyle : aStyles)
2966  pBox->append_text(rStyle);
2967 
2968  if ((pImpl->bSpecModeWriter || pImpl->bSpecModeCalc) && !comphelper::LibreOfficeKit::isActive())
2969  pBox->append_text(pImpl->aMore);
2970 
2971  pBox->thaw();
2972  pBox->set_active_or_entry_text(aStrSel);
2973  pBox->SetFamily( eFamily );
2974 }
2975 
2976 void SvxStyleToolBoxControl::SelectStyle( const OUString& rStyleName )
2977 {
2978  SvxStyleBox_Base* pBox = pImpl->m_pBox;
2979  DBG_ASSERT( pBox, "Control not found!" );
2980 
2981  if ( !pBox )
2982  return;
2983 
2984  OUString aStrSel(pBox->get_active_text());
2985 
2986  if ( !rStyleName.isEmpty() )
2987  {
2988  OUString aNewStyle = rStyleName;
2989 
2990  auto aFound = std::find_if(pImpl->aDefaultStyles.begin(), pImpl->aDefaultStyles.end(),
2991  [rStyleName] (auto it) { return it.first == rStyleName || it.second == rStyleName; }
2992  );
2993 
2994  if (aFound != pImpl->aDefaultStyles.end())
2995  aNewStyle = aFound->second;
2996 
2997  if ( aNewStyle != aStrSel )
2998  pBox->set_active_or_entry_text( aNewStyle );
2999  }
3000  else
3001  pBox->set_active(-1);
3002  pBox->save_value();
3003 }
3004 
3006 {
3007  SfxStyleSheetBasePool* pPool = nullptr;
3008  SfxObjectShell* pDocShell = SfxObjectShell::Current();
3009 
3010  if ( pDocShell )
3011  pPool = pDocShell->GetStyleSheetPool();
3012 
3013  sal_uInt16 i;
3014  for ( i=0; i<MAX_FAMILIES; i++ )
3015  if( pFamilyState[i] )
3016  break;
3017 
3018  if ( i==MAX_FAMILIES || !pPool )
3019  {
3020  pStyleSheetPool = pPool;
3021  return;
3022  }
3023 
3024 
3025  const SfxTemplateItem* pItem = nullptr;
3026 
3027  if ( nActFamily == 0xffff || nullptr == (pItem = pFamilyState[nActFamily-1].get()) )
3028  // Current range not within allowed ranges or default
3029  {
3030  pStyleSheetPool = pPool;
3031  nActFamily = 2;
3032 
3033  pItem = pFamilyState[nActFamily-1].get();
3034  if ( !pItem )
3035  {
3036  nActFamily++;
3037  pItem = pFamilyState[nActFamily-1].get();
3038  }
3039  }
3040  else if ( pPool != pStyleSheetPool )
3041  pStyleSheetPool = pPool;
3042 
3043  FillStyleBox(); // Decides by itself whether Fill is needed
3044 
3045  if ( pItem )
3046  SelectStyle( pItem->GetStyleName() );
3047 }
3048 
3050  const SfxTemplateItem* pItem )
3051 {
3052  pFamilyState[nIdx].reset( pItem == nullptr ? nullptr : new SfxTemplateItem( *pItem ) );
3053  Update();
3054 }
3055 
3056 void SvxStyleToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
3057 {
3058  SolarMutexGuard aGuard;
3059 
3060  if (m_pToolbar)
3061  m_pToolbar->set_item_sensitive(m_aCommandURL.toUtf8(), rEvent.IsEnabled);
3062  else
3063  {
3064  ToolBox* pToolBox = nullptr;
3066  if (!getToolboxId( nId, &pToolBox ) )
3067  return;
3068  pToolBox->EnableItem( nId, rEvent.IsEnabled );
3069  }
3070 
3071  if (rEvent.IsEnabled)
3072  Update();
3073 }
3074 
3075 css::uno::Reference<css::awt::XWindow> SvxStyleToolBoxControl::createItemWindow(const css::uno::Reference< css::awt::XWindow>& rParent)
3076 {
3077  uno::Reference< awt::XWindow > xItemWindow;
3078 
3079  if (m_pBuilder)
3080  {
3081  SolarMutexGuard aSolarMutexGuard;
3082 
3083  std::unique_ptr<weld::ComboBox> xWidget(m_pBuilder->weld_combo_box("applystyle"));
3084 
3085  xItemWindow = css::uno::Reference<css::awt::XWindow>(new weld::TransportAsXWindow(xWidget.get()));
3086 
3087  pImpl->m_xWeldBox.reset(new SvxStyleBox_Base(std::move(xWidget),
3088  ".uno:StyleApply",
3089  SfxStyleFamily::Para,
3090  Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
3091  m_xFrame,
3092  pImpl->aClearForm,
3093  pImpl->aMore,
3094  pImpl->bSpecModeWriter || pImpl->bSpecModeCalc, *this));
3095  pImpl->m_pBox = pImpl->m_xWeldBox.get();
3096  }
3097  else
3098  {
3099  VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(rParent);
3100  if ( pParent )
3101  {
3102  SolarMutexGuard aSolarMutexGuard;
3103 
3104  pImpl->m_xVclBox = VclPtr<SvxStyleBox_Impl>::Create(pParent,
3105  ".uno:StyleApply",
3106  SfxStyleFamily::Para,
3107  Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
3108  m_xFrame,
3109  pImpl->aClearForm,
3110  pImpl->aMore,
3111  pImpl->bSpecModeWriter || pImpl->bSpecModeCalc, *this);
3112  pImpl->m_pBox = pImpl->m_xVclBox.get();
3113  xItemWindow = VCLUnoHelper::GetInterface(pImpl->m_xVclBox);
3114  }
3115  }
3116 
3117  if (pImpl->m_pBox && !pImpl->aDefaultStyles.empty())
3118  pImpl->m_pBox->SetDefaultStyle(pImpl->aDefaultStyles[0].second);
3119 
3120  return xItemWindow;
3121 }
3122 
3123 SvxFontNameToolBoxControl::SvxFontNameToolBoxControl()
3124  : m_pBox(nullptr)
3125 {
3126 }
3127 
3128 void SvxFontNameBox_Base::statusChanged_Impl( const css::frame::FeatureStateEvent& rEvent )
3129 {
3130  if ( !rEvent.IsEnabled )
3131  {
3132  set_sensitive(false);
3133  Update( nullptr );
3134  }
3135  else
3136  {
3137  set_sensitive(true);
3138 
3139  css::awt::FontDescriptor aFontDesc;
3140  if ( rEvent.State >>= aFontDesc )
3141  Update(&aFontDesc);
3142  else
3143  set_active_or_entry_text("");
3144  m_xWidget->save_value();
3145  }
3146 }
3147 
3148 void SvxFontNameToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
3149 {
3150  SolarMutexGuard aGuard;
3151  m_pBox->statusChanged_Impl(rEvent);
3152 
3153  if (m_pToolbar)
3154  m_pToolbar->set_item_sensitive(m_aCommandURL.toUtf8(), rEvent.IsEnabled);
3155  else
3156  {
3157  ToolBox* pToolBox = nullptr;
3159  if (!getToolboxId( nId, &pToolBox ) )
3160  return;
3161  pToolBox->EnableItem( nId, rEvent.IsEnabled );
3162  }
3163 }
3164 
3165 css::uno::Reference<css::awt::XWindow> SvxFontNameToolBoxControl::createItemWindow(const css::uno::Reference<css::awt::XWindow>& rParent)
3166 {
3167  uno::Reference< awt::XWindow > xItemWindow;
3168 
3169  if (m_pBuilder)
3170  {
3171  SolarMutexGuard aSolarMutexGuard;
3172 
3173  std::unique_ptr<weld::ComboBox> xWidget(m_pBuilder->weld_combo_box("fontnamecombobox"));
3174 
3175  xItemWindow = css::uno::Reference<css::awt::XWindow>(new weld::TransportAsXWindow(xWidget.get()));
3176 
3177  m_xWeldBox.reset(new SvxFontNameBox_Base(std::move(xWidget),
3178  Reference<XDispatchProvider>(m_xFrame->getController(), UNO_QUERY),
3179  m_xFrame, *this));
3180  m_pBox = m_xWeldBox.get();
3181  }
3182  else
3183  {
3184  VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(rParent);
3185  if ( pParent )
3186  {
3187  SolarMutexGuard aSolarMutexGuard;
3188  m_xVclBox = VclPtr<SvxFontNameBox_Impl>::Create(pParent,
3189  Reference<XDispatchProvider>(m_xFrame->getController(), UNO_QUERY),
3190  m_xFrame, *this);
3191  m_pBox = m_xVclBox.get();
3192  xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox);
3193  }
3194  }
3195 
3196  return xItemWindow;
3197 }
3198 
3199 void SvxFontNameToolBoxControl::dispose()
3200 {
3201  ToolboxController::dispose();
3202 
3203  SolarMutexGuard aSolarMutexGuard;
3204  m_xVclBox.disposeAndClear();
3205  m_xWeldBox.reset();
3206  m_pBox = nullptr;
3207 }
3208 
3209 OUString SvxFontNameToolBoxControl::getImplementationName()
3210 {
3211  return "com.sun.star.comp.svx.FontNameToolBoxControl";
3212 }
3213 
3214 sal_Bool SvxFontNameToolBoxControl::supportsService( const OUString& rServiceName )
3215 {
3216  return cppu::supportsService( this, rServiceName );
3217 }
3218 
3219 css::uno::Sequence< OUString > SvxFontNameToolBoxControl::getSupportedServiceNames()
3220 {
3221  return { "com.sun.star.frame.ToolbarController" };
3222 }
3223 
3224 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
3226  css::uno::XComponentContext*,
3227  css::uno::Sequence<css::uno::Any> const & )
3228 {
3229  return cppu::acquire( new SvxFontNameToolBoxControl() );
3230 }
3231 
3232 SvxColorToolBoxControl::SvxColorToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext ) :
3233  ImplInheritanceHelper( rContext, nullptr, OUString() ),
3234  m_bSplitButton(true),
3235  m_nSlotId(0),
3236  m_aColorSelectFunction(PaletteManager::DispatchColorCommand)
3237 {
3238 }
3239 
3240 namespace {
3241 
3242 sal_uInt16 MapCommandToSlotId(const OUString& rCommand)
3243 {
3244  if (rCommand == ".uno:Color")
3245  return SID_ATTR_CHAR_COLOR;
3246  else if (rCommand == ".uno:FontColor")
3247  return SID_ATTR_CHAR_COLOR2;
3248  else if (rCommand == ".uno:BackColor")
3249  return SID_ATTR_CHAR_COLOR_BACKGROUND;
3250  else if (rCommand == ".uno:CharBackColor")
3251  return SID_ATTR_CHAR_BACK_COLOR;
3252  else if (rCommand == ".uno:BackgroundColor")
3253  return SID_BACKGROUND_COLOR;
3254  else if (rCommand == ".uno:TableCellBackgroundColor")
3255  return SID_TABLE_CELL_BACKGROUND_COLOR;
3256  else if (rCommand == ".uno:Extrusion3DColor")
3257  return SID_EXTRUSION_3D_COLOR;
3258  else if (rCommand == ".uno:XLineColor")
3259  return SID_ATTR_LINE_COLOR;
3260  else if (rCommand == ".uno:FillColor")
3261  return SID_ATTR_FILL_COLOR;
3262  else if (rCommand == ".uno:FrameLineColor")
3263  return SID_FRAME_LINECOLOR;
3264 
3265  SAL_WARN("svx.tbxcrtls", "Unknown color command: " << rCommand);
3266  return 0;
3267 }
3268 
3269 }
3270 
3271 void SvxColorToolBoxControl::initialize( const css::uno::Sequence<css::uno::Any>& rArguments )
3272 {
3273  PopupWindowController::initialize( rArguments );
3274 
3275  m_nSlotId = MapCommandToSlotId( m_aCommandURL );
3276 
3277  if ( m_nSlotId == SID_ATTR_LINE_COLOR || m_nSlotId == SID_ATTR_FILL_COLOR ||
3278  m_nSlotId == SID_FRAME_LINECOLOR || m_nSlotId == SID_BACKGROUND_COLOR )
3279  {
3280  // Sidebar uses wide buttons for those.
3281  m_bSplitButton = !m_bSidebar;
3282  }
3283 
3284  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(getCommandURL(), getModuleName());
3286 
3287  OString aId(m_aCommandURL.toUtf8());
3288 
3289  if (m_pToolbar)
3290  {
3291  mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
3292  m_pToolbar->set_item_popover(aId, mxPopoverContainer->getTopLevel());
3293  m_xBtnUpdater.reset(new svx::ToolboxButtonColorUpdater(m_nSlotId, aId, m_pToolbar, !m_bSplitButton, aCommandLabel, m_xFrame));
3294  return;
3295  }
3296 
3297  ToolBox* pToolBox = nullptr;
3298  ToolBoxItemId nId;
3299  if (getToolboxId(nId, &pToolBox))
3300  {
3301  m_xBtnUpdater.reset( new svx::VclToolboxButtonColorUpdater( m_nSlotId, nId, pToolBox, !m_bSplitButton, aCommandLabel, m_aCommandURL, m_xFrame ) );
3302  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ( m_bSplitButton ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) );
3303  }
3304 }
3305 
3307 {
3308  PopupWindowController::update();
3309 
3310  switch( m_nSlotId )
3311  {
3312  case SID_ATTR_CHAR_COLOR2:
3313  addStatusListener( ".uno:CharColorExt");
3314  break;
3315 
3316  case SID_ATTR_CHAR_COLOR_BACKGROUND:
3317  addStatusListener( ".uno:CharBackgroundExt");
3318  break;
3319 
3320  case SID_FRAME_LINECOLOR:
3321  addStatusListener( ".uno:BorderTLBR");
3322  addStatusListener( ".uno:BorderBLTR");
3323  break;
3324  }
3325 }
3326 
3328 {
3329  if (!m_xPaletteManager)
3330  {
3331  m_xPaletteManager = std::make_shared<PaletteManager>();
3332  m_xPaletteManager->SetBtnUpdater(m_xBtnUpdater.get());
3333  }
3334 }
3335 
3337 {
3338  if (m_xPaletteManager)
3339  m_xPaletteManager->SetBtnUpdater(nullptr);
3340 }
3341 
3343 {
3344  m_aColorSelectFunction = aColorSelectFunction;
3345  if (m_xPaletteManager)
3346  m_xPaletteManager->SetColorSelectFunction(aColorSelectFunction);
3347 }
3348 
3350 {
3351  const css::uno::Reference<css::awt::XWindow> xParent = m_xFrame->getContainerWindow();
3352  return Application::GetFrameWeld(xParent);
3353 }
3354 
3355 std::unique_ptr<WeldToolbarPopup> SvxColorToolBoxControl::weldPopupWindow()
3356 {
3358 
3359  const OString aId(m_aCommandURL.toUtf8());
3360 
3361  auto xPopover = std::make_unique<ColorWindow>(
3362  m_aCommandURL,
3365  m_nSlotId,
3366  m_xFrame,
3367  MenuOrToolMenuButton(m_pToolbar, aId),
3368  [this] { return GetParentFrame(); },
3370 
3371  if ( m_bSplitButton )
3372  xPopover->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) );
3373 
3374  return xPopover;
3375 }
3376 
3378 {
3379  ToolBox* pToolBox = nullptr;
3380  ToolBoxItemId nId;
3381  if (!getToolboxId(nId, &pToolBox))
3382  return nullptr;
3383 
3385 
3386  auto xPopover = std::make_unique<ColorWindow>(
3387  m_aCommandURL,
3390  m_nSlotId,
3391  m_xFrame,
3392  MenuOrToolMenuButton(this, pToolBox, nId),
3393  [this] { return GetParentFrame(); },
3395 
3396  if ( m_bSplitButton )
3397  xPopover->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) );
3398 
3399  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
3400  std::move(xPopover), true);
3401 
3402  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(m_aCommandURL, m_sModuleName);
3404  mxInterimPopover->SetText(aWindowTitle);
3405 
3406  mxInterimPopover->Show();
3407 
3408  return mxInterimPopover;
3409 }
3410 
3411 IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void)
3412 {
3413  m_xBtnUpdater->Update(rColor);
3414 }
3415 
3416 void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
3417 {
3418  ToolBox* pToolBox = nullptr;
3419  ToolBoxItemId nId;
3420  if (!getToolboxId(nId, &pToolBox) && !m_pToolbar)
3421  return;
3422 
3423  if ( rEvent.FeatureURL.Complete == m_aCommandURL )
3424  {
3425  if (m_pToolbar)
3426  m_pToolbar->set_item_sensitive(m_aCommandURL.toUtf8(), rEvent.IsEnabled);
3427  else
3428  pToolBox->EnableItem( nId, rEvent.IsEnabled );
3429  }
3430 
3431  bool bValue;
3432  if ( !m_bSplitButton )
3433  {
3434  m_aColorStatus.statusChanged( rEvent );
3435  m_xBtnUpdater->Update( m_aColorStatus.GetColor() );
3436  }
3437  else if ( rEvent.State >>= bValue )
3438  {
3439  if (m_pToolbar)
3440  m_pToolbar->set_item_active(m_aCommandURL.toUtf8(), bValue);
3441  else if (pToolBox)
3442  pToolBox->CheckItem( nId, bValue );
3443  }
3444 }
3445 
3446 void SvxColorToolBoxControl::execute(sal_Int16 /*nSelectModifier*/)
3447 {
3448  if ( !m_bSplitButton )
3449  {
3450  if (m_pToolbar)
3451  {
3452  // Toggle the popup also when toolbutton is activated
3453  const OString aId(m_aCommandURL.toUtf8());
3454  m_pToolbar->set_menu_item_active(aId, !m_pToolbar->get_menu_item_active(aId));
3455  }
3456  else
3457  {
3458  // Open the popup also when Enter key is pressed.
3459  createPopupWindow();
3460  }
3461  return;
3462  }
3463 
3464  OUString aCommand = m_aCommandURL;
3465  Color aColor = m_xBtnUpdater->GetCurrentColor();
3466 
3467  switch( m_nSlotId )
3468  {
3469  case SID_ATTR_CHAR_COLOR2 :
3470  aCommand = ".uno:CharColorExt";
3471  break;
3472 
3473  case SID_ATTR_CHAR_COLOR_BACKGROUND :
3474  aCommand = ".uno:CharBackgroundExt";
3475  break;
3476  }
3477 
3478  auto aArgs( comphelper::InitPropertySequence( {
3479  { m_aCommandURL.copy(5), css::uno::makeAny(aColor) }
3480  } ) );
3481  dispatchCommand( aCommand, aArgs );
3482 
3484  OUString sColorName = m_xBtnUpdater->GetCurrentColorName();
3485  m_xPaletteManager->AddRecentColor(aColor, sColorName);
3486 }
3487 
3489 {
3490  // We mark this controller as a sub-toolbar controller, so we get notified
3491  // (through updateImage method) on button image changes, and could redraw
3492  // the last used color on top of it.
3493  return true;
3494 }
3495 
3497 {
3498  m_xBtnUpdater->Update(m_xBtnUpdater->GetCurrentColor(), true);
3499 }
3500 
3502 {
3503  return OUString();
3504 }
3505 
3506 void SvxColorToolBoxControl::functionSelected( const OUString& /*rCommand*/ )
3507 {
3508 }
3509 
3511 {
3512  return "com.sun.star.comp.svx.ColorToolBoxControl";
3513 }
3514 
3516 {
3517  return { "com.sun.star.frame.ToolbarController" };
3518 }
3519 
3520 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
3522  css::uno::XComponentContext* rContext,
3523  css::uno::Sequence<css::uno::Any> const & )
3524 {
3525  return cppu::acquire( new SvxColorToolBoxControl( rContext ) );
3526 }
3527 
3528 SvxFrameToolBoxControl::SvxFrameToolBoxControl( const css::uno::Reference< css::uno::XComponentContext >& rContext )
3529  : svt::PopupWindowController( rContext, nullptr, OUString() )
3530 {
3531 }
3532 
3533 void SAL_CALL SvxFrameToolBoxControl::execute(sal_Int16 /*KeyModifier*/)
3534 {
3535  if (m_pToolbar)
3536  {
3537  // Toggle the popup also when toolbutton is activated
3538  const OString aId(m_aCommandURL.toUtf8());
3539  m_pToolbar->set_menu_item_active(aId, !m_pToolbar->get_menu_item_active(aId));
3540  }
3541  else
3542  {
3543  // Open the popup also when Enter key is pressed.
3544  createPopupWindow();
3545  }
3546 }
3547 
3548 void SvxFrameToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
3549 {
3550  svt::PopupWindowController::initialize( rArguments );
3551 
3552  if (m_pToolbar)
3553  {
3554  mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
3555  m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel());
3556  }
3557 
3558  ToolBox* pToolBox = nullptr;
3559  ToolBoxItemId nId;
3560  if (getToolboxId(nId, &pToolBox))
3561  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
3562 }
3563 
3564 std::unique_ptr<WeldToolbarPopup> SvxFrameToolBoxControl::weldPopupWindow()
3565 {
3566  if ( m_aCommandURL == ".uno:LineStyle" )
3567  return std::make_unique<SvxLineWindow_Impl>(this, m_pToolbar);
3568  return std::make_unique<SvxFrameWindow_Impl>(this, m_pToolbar);
3569 }
3570 
3571 VclPtr<vcl::Window> SvxFrameToolBoxControl::createVclPopupWindow( vcl::Window* pParent )
3572 {
3573  if ( m_aCommandURL == ".uno:LineStyle" )
3574  {
3575  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
3576  std::make_unique<SvxLineWindow_Impl>(this, pParent->GetFrameWeld()));
3577 
3578  mxInterimPopover->Show();
3579 
3580  mxInterimPopover->SetText(SvxResId(RID_SVXSTR_FRAME_STYLE));
3581 
3582  return mxInterimPopover;
3583  }
3584 
3585  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
3586  std::make_unique<SvxFrameWindow_Impl>(this, pParent->GetFrameWeld()));
3587 
3588  mxInterimPopover->Show();
3589 
3590  mxInterimPopover->SetText(SvxResId(RID_SVXSTR_FRAME));
3591 
3592  return mxInterimPopover;
3593 }
3594 
3595 OUString SvxFrameToolBoxControl::getImplementationName()
3596 {
3597  return "com.sun.star.comp.svx.FrameToolBoxControl";
3598 }
3599 
3600 css::uno::Sequence< OUString > SvxFrameToolBoxControl::getSupportedServiceNames()
3601 {
3602  return { "com.sun.star.frame.ToolbarController" };
3603 }
3604 
3605 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
3607  css::uno::XComponentContext* rContext,
3608  css::uno::Sequence<css::uno::Any> const & )
3609 {
3610  return cppu::acquire( new SvxFrameToolBoxControl( rContext ) );
3611 }
3612 
3613 SvxCurrencyToolBoxControl::SvxCurrencyToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext ) :
3614  PopupWindowController( rContext, nullptr, OUString() ),
3615  m_eLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() ),
3616  m_nFormatKey( NUMBERFORMAT_ENTRY_NOT_FOUND )
3617 {
3618 }
3619 
3620 SvxCurrencyToolBoxControl::~SvxCurrencyToolBoxControl() {}
3621 
3622 namespace
3623 {
3624  class SvxCurrencyList_Impl : public WeldToolbarPopup
3625  {
3626  private:
3628  std::unique_ptr<weld::Label> m_xLabel;
3629  std::unique_ptr<weld::TreeView> m_xCurrencyLb;
3630  std::unique_ptr<weld::Button> m_xOkBtn;
3631  OUString& m_rSelectedFormat;
3632  LanguageType& m_eSelectedLanguage;
3633 
3634  std::vector<OUString> m_aFormatEntries;
3635  LanguageType m_eFormatLanguage;
3636  DECL_LINK(RowActivatedHdl, weld::TreeView&, bool);
3637  DECL_LINK(OKHdl, weld::Button&, void);
3638 
3639  virtual void GrabFocus() override;
3640 
3641  public:
3642  SvxCurrencyList_Impl(SvxCurrencyToolBoxControl* pControl, weld::Widget* pParent, OUString& rSelectedFormat, LanguageType& eSelectedLanguage)
3643  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/currencywindow.ui", "CurrencyWindow")
3644  , m_xControl(pControl)
3645  , m_xLabel(m_xBuilder->weld_label("label"))
3646  , m_xCurrencyLb(m_xBuilder->weld_tree_view("currency"))
3647  , m_xOkBtn(m_xBuilder->weld_button("ok"))
3648  , m_rSelectedFormat(rSelectedFormat)
3649  , m_eSelectedLanguage(eSelectedLanguage)
3650  {
3651  std::vector< OUString > aList;
3652  std::vector< sal_uInt16 > aCurrencyList;
3653  const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable();
3654  sal_uInt16 nLen = rCurrencyTable.size();
3655 
3656  SvNumberFormatter aFormatter( m_xControl->getContext(), LANGUAGE_SYSTEM );
3657  m_eFormatLanguage = aFormatter.GetLanguage();
3658 
3659  SvxCurrencyToolBoxControl::GetCurrencySymbols( aList, true, aCurrencyList );
3660 
3661  sal_uInt16 nPos = 0, nCount = 0;
3662  sal_Int32 nSelectedPos = -1;
3663  bool bIsSymbol;
3664  NfWSStringsDtor aStringsDtor;
3665 
3666  OUString sLongestString;
3667 
3668  m_xCurrencyLb->freeze();
3669  for( const auto& rItem : aList )
3670  {
3671  sal_uInt16& rCurrencyIndex = aCurrencyList[ nCount ];
3672  if ( rCurrencyIndex < nLen )
3673  {
3674  m_xCurrencyLb->append_text(rItem);
3675 
3676  if (rItem.getLength() > sLongestString.getLength())
3677  sLongestString = rItem;
3678 
3679  const NfCurrencyEntry& aCurrencyEntry = rCurrencyTable[ rCurrencyIndex ];
3680 
3681  bIsSymbol = nPos >= nLen;
3682 
3683  sal_uInt16 nDefaultFormat = aFormatter.GetCurrencyFormatStrings( aStringsDtor, aCurrencyEntry, bIsSymbol );
3684  const OUString& rFormatStr = aStringsDtor[ nDefaultFormat ];
3685  m_aFormatEntries.push_back( rFormatStr );
3686  if( rFormatStr == m_rSelectedFormat )
3687  nSelectedPos = nPos;
3688  ++nPos;
3689  }
3690  ++nCount;
3691  }
3692  m_xCurrencyLb->thaw();
3693  // enable multiple selection enabled so we can start with nothing selected
3694  m_xCurrencyLb->set_selection_mode(SelectionMode::Multiple);
3695  m_xCurrencyLb->connect_row_activated( LINK( this, SvxCurrencyList_Impl, RowActivatedHdl ) );
3696  m_xLabel->set_label(SvxResId(RID_SVXSTR_TBLAFMT_CURRENCY));
3697  m_xCurrencyLb->select( nSelectedPos );
3698  m_xOkBtn->connect_clicked(LINK(this, SvxCurrencyList_Impl, OKHdl));
3699 
3700  // gtk will initially make a best guess depending on the first few entries, so copy the probable
3701  // longest entry to the start temporarily and force in the width at this point
3702  m_xCurrencyLb->insert_text(0, sLongestString);
3703  m_xCurrencyLb->set_size_request(m_xCurrencyLb->get_preferred_size().Width(), m_xCurrencyLb->get_height_rows(12));
3704  m_xCurrencyLb->remove(0);
3705  }
3706  };
3707 
3708  void SvxCurrencyList_Impl::GrabFocus()
3709  {
3710  m_xCurrencyLb->grab_focus();
3711  }
3712 
3713  IMPL_LINK_NOARG(SvxCurrencyList_Impl, OKHdl, weld::Button&, void)
3714  {
3715  RowActivatedHdl(*m_xCurrencyLb);
3716  }
3717 
3718  IMPL_LINK_NOARG(SvxCurrencyList_Impl, RowActivatedHdl, weld::TreeView&, bool)
3719  {
3720  if (!m_xControl.is())
3721  return true;
3722 
3723  // multiple selection enabled so we can start with nothing selected,
3724  // so force single selection after something is picked
3725  int nSelected = m_xCurrencyLb->get_selected_index();
3726  if (nSelected == -1)
3727  return true;
3728 
3729  m_xCurrencyLb->set_selection_mode(SelectionMode::Single);
3730 
3731  m_rSelectedFormat = m_aFormatEntries[nSelected];
3732  m_eSelectedLanguage = m_eFormatLanguage;
3733 
3734  m_xControl->execute(nSelected + 1);
3735 
3736  m_xControl->EndPopupMode();
3737 
3738  return true;
3739  }
3740 }
3741 
3742 void SvxCurrencyToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
3743 {
3744  PopupWindowController::initialize(rArguments);
3745 
3746  if (m_pToolbar)
3747  {
3748  mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
3749  m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel());
3750  return;
3751  }
3752 
3753  ToolBox* pToolBox = nullptr;
3754  ToolBoxItemId nId;
3755  if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
3756  pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWN | pToolBox->GetItemBits(nId));
3757 }
3758 
3759 std::unique_ptr<WeldToolbarPopup> SvxCurrencyToolBoxControl::weldPopupWindow()
3760 {
3761  return std::make_unique<SvxCurrencyList_Impl>(this, m_pToolbar, m_aFormatString, m_eLanguage);
3762 }
3763 
3764 VclPtr<vcl::Window> SvxCurrencyToolBoxControl::createVclPopupWindow( vcl::Window* pParent )
3765 {
3766  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
3767  std::make_unique<SvxCurrencyList_Impl>(this, pParent->GetFrameWeld(), m_aFormatString, m_eLanguage));
3768 
3769  mxInterimPopover->Show();
3770 
3771  return mxInterimPopover;
3772 }
3773 
3774 void SvxCurrencyToolBoxControl::execute( sal_Int16 nSelectModifier )
3775 {
3776  sal_uInt32 nFormatKey;
3777  if (m_aFormatString.isEmpty())
3778  nFormatKey = NUMBERFORMAT_ENTRY_NOT_FOUND;
3779  else
3780  {
3781  if ( nSelectModifier > 0 )
3782  {
3783  try
3784  {
3785  uno::Reference< util::XNumberFormatsSupplier > xRef( m_xFrame->getController()->getModel(), uno::UNO_QUERY );
3786  uno::Reference< util::XNumberFormats > rxNumberFormats( xRef->getNumberFormats(), uno::UNO_SET_THROW );
3787  css::lang::Locale aLocale = LanguageTag::convertToLocale( m_eLanguage );
3788  nFormatKey = rxNumberFormats->queryKey( m_aFormatString, aLocale, false );
3789  if ( nFormatKey == NUMBERFORMAT_ENTRY_NOT_FOUND )
3790  nFormatKey = rxNumberFormats->addNew( m_aFormatString, aLocale );
3791  }
3792  catch( const uno::Exception& )
3793  {
3794  nFormatKey = m_nFormatKey;
3795  }
3796  }
3797  else
3798  nFormatKey = m_nFormatKey;
3799  }
3800 
3801  if( nFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
3802  {
3803  Sequence< PropertyValue > aArgs( 1 );
3804  aArgs[0].Name = "NumberFormatCurrency";
3805  aArgs[0].Value <<= nFormatKey;
3806  dispatchCommand( m_aCommandURL, aArgs );
3807  m_nFormatKey = nFormatKey;
3808  }
3809  else
3810  PopupWindowController::execute( nSelectModifier );
3811 }
3812 
3813 OUString SvxCurrencyToolBoxControl::getImplementationName()
3814 {
3815  return "com.sun.star.comp.svx.CurrencyToolBoxControl";
3816 }
3817 
3818 css::uno::Sequence<OUString> SvxCurrencyToolBoxControl::getSupportedServiceNames()
3819 {
3820  return { "com.sun.star.frame.ToolbarController" };
3821 }
3822 
3823 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
3825  css::uno::XComponentContext* rContext,
3826  css::uno::Sequence<css::uno::Any> const & )
3827 {
3828  return cppu::acquire( new SvxCurrencyToolBoxControl( rContext ) );
3829 }
3830 
3831 Reference< css::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
3832 {
3833  FillList();
3835 }
3836 
3837 //static
3838 void SvxCurrencyToolBoxControl::GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag,
3839  std::vector<sal_uInt16>& rCurrencyList )
3840 {
3841  rCurrencyList.clear();
3842 
3843  const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable();
3844  sal_uInt16 nCount = rCurrencyTable.size();
3845 
3846  sal_uInt16 nStart = 1;
3847 
3848  OUString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol() ) + " " );
3850  rCurrencyTable[0].GetLanguage() ) );
3851 
3852  rList.push_back( aString );
3853  rCurrencyList.push_back( sal_uInt16(-1) ); // nAuto
3854 
3855  if( bFlag )
3856  {
3857  rList.push_back( aString );
3858  rCurrencyList.push_back( 0 );
3859  ++nStart;
3860  }
3861 
3863  aCollator.loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0 );
3864 
3865  static const OUStringLiteral aTwoSpace(u" ");
3866 
3867  for( sal_uInt16 i = 1; i < nCount; ++i )
3868  {
3869  OUString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol() ) );
3870  aStr += aTwoSpace;
3871  aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol() );
3872  aStr += aTwoSpace;
3874  rCurrencyTable[i].GetLanguage() ) );
3875 
3876  std::vector<OUString>::size_type j = nStart;
3877  for( ; j < rList.size(); ++j )
3878  if ( aCollator.compareString( aStr, rList[j] ) < 0 )
3879  break; // insert before first greater than
3880 
3881  rList.insert( rList.begin() + j, aStr );
3882  rCurrencyList.insert( rCurrencyList.begin() + j, i );
3883  }
3884 
3885  // Append ISO codes to symbol list.
3886  // XXX If this is to be changed, various other places would had to be
3887  // adapted that assume this order!
3888  std::vector<OUString>::size_type nCont = rList.size();
3889 
3890  for ( sal_uInt16 i = 1; i < nCount; ++i )
3891  {
3892  bool bInsert = true;
3893  OUString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol() ) );
3894 
3895  std::vector<OUString>::size_type j = nCont;
3896  for ( ; j < rList.size() && bInsert; ++j )
3897  {
3898  if( rList[j] == aStr )
3899  bInsert = false;
3900  else if ( aCollator.compareString( aStr, rList[j] ) < 0 )
3901  break; // insert before first greater than
3902  }
3903  if ( bInsert )
3904  {
3905  rList.insert( rList.begin() + j, aStr );
3906  rCurrencyList.insert( rCurrencyList.begin() + j, i );
3907  }
3908  }
3909 }
3910 
3912  : mpControl(pControl)
3913 {
3914 }
3915 
3917  [[maybe_unused]] const OUString& /*rCommand*/, const NamedColor& rColor)
3918 {
3919  mpControl->Selected(rColor);
3920 }
3921 
3923 {
3924  if (!m_xPaletteManager)
3925  {
3926  m_xPaletteManager = std::make_shared<PaletteManager>();
3927  m_xPaletteManager->SetColorSelectFunction(std::ref(m_aColorWrapper));
3928  }
3929 }
3930 
3931 void ColorListBox::SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton)
3932 {
3933  m_nSlotId = nSlotId;
3934  m_bShowNoneButton = bShowNoneButton;
3935  m_xButton->set_popover(nullptr);
3936  m_xColorWindow.reset();
3937  m_aSelectedColor = bShowNoneButton ? GetNoneColor() : GetAutoColor(m_nSlotId);
3940 }
3941 
3942 ColorListBox::ColorListBox(std::unique_ptr<weld::MenuButton> pControl, TopLevelParentFunction const& rTopLevelParentFunction)
3943  : m_xButton(std::move(pControl))
3944  , m_aColorWrapper(this)
3945  , m_aAutoDisplayColor(Application::GetSettings().GetStyleSettings().GetDialogColor())
3946  , m_nSlotId(0)
3947  , m_bShowNoneButton(false)
3948  , m_aTopLevelParentFunction(rTopLevelParentFunction)
3949 {
3950  m_xButton->connect_toggled(LINK(this, ColorListBox, ToggleHdl));
3951  m_aSelectedColor = GetAutoColor(m_nSlotId);
3952  LockWidthRequest();
3954 }
3955 
3956 IMPL_LINK(ColorListBox, ToggleHdl, weld::Toggleable&, rButton, void)
3957 {
3958  if (rButton.get_active())
3959  {
3960  ColorWindow* pColorWindow = getColorWindow();
3961  if (pColorWindow && !comphelper::LibreOfficeKit::isActive())
3962  pColorWindow->GrabFocus();
3963  }
3964 }
3965 
3967 {
3968 }
3969 
3971 {
3972  if (!m_xColorWindow)
3973  const_cast<ColorListBox*>(this)->createColorWindow();
3974  return m_xColorWindow.get();
3975 }
3976 
3978 {
3979  const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
3980  const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : nullptr;
3981  css::uno::Reference<css::frame::XFrame> xFrame(pFrame ? pFrame->GetFrameInterface() : uno::Reference<css::frame::XFrame>());
3982 
3984 
3985  m_xColorWindow.reset(new ColorWindow(
3986  OUString() /*m_aCommandURL*/,
3989  m_nSlotId,
3990  xFrame,
3991  m_xButton.get(),
3993  m_aColorWrapper));
3994 
3995  SetNoSelection();
3996  m_xButton->set_popover(m_xColorWindow->getTopLevel());
3997  if (m_bShowNoneButton)
3998  m_xColorWindow->ShowNoneButton();
3999  m_xColorWindow->SelectEntry(m_aSelectedColor);
4000 }
4001 
4003 {
4004  if (rColor.second.trim().isEmpty())
4005  {
4006  SelectEntry(rColor.first);
4007  return;
4008  }
4009  ColorWindow* pColorWindow = getColorWindow();
4010  pColorWindow->SelectEntry(rColor);
4011  m_aSelectedColor = pColorWindow->GetSelectEntryColor();
4013 }
4014 
4016 {
4017  ColorWindow* pColorWindow = getColorWindow();
4018  pColorWindow->SelectEntry(rColor);
4019  m_aSelectedColor = pColorWindow->GetSelectEntryColor();
4021 }
4022 
4024 {
4025  ShowPreview(rColor);
4026  m_aSelectedColor = rColor;
4027  if (m_aSelectedLink.IsSet())
4028  m_aSelectedLink.Call(*this);
4029 }
4030 
4031 //to avoid the box resizing every time the color is changed to
4032 //the optimal size of the individual color, get the longest
4033 //standard color and stick with that as the size for all
4035 {
4036  NamedColor aLongestColor;
4037  tools::Long nMaxStandardColorTextWidth = 0;
4038  XColorListRef const xColorTable = XColorList::CreateStdColorList();
4039  for (tools::Long i = 0; i != xColorTable->Count(); ++i)
4040  {
4041  XColorEntry& rEntry = *xColorTable->GetColor(i);
4042  auto nColorTextWidth = m_xButton->get_pixel_size(rEntry.GetName()).Width();
4043  if (nColorTextWidth > nMaxStandardColorTextWidth)
4044  {
4045  nMaxStandardColorTextWidth = nColorTextWidth;
4046  aLongestColor.second = rEntry.GetName();
4047  }
4048  }
4049  ShowPreview(aLongestColor);
4050  m_xButton->set_size_request(m_xButton->get_preferred_size().Width(), -1);
4051 }
4052 
4054 {
4055  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
4056  Size aImageSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
4057 
4059  xDevice->SetOutputSize(aImageSize);
4060  const tools::Rectangle aRect(Point(0, 0), aImageSize);
4061  if (m_bShowNoneButton && rColor.first == COL_NONE_COLOR)
4062  {
4063  const Color aW(COL_WHITE);
4064  const Color aG(0xef, 0xef, 0xef);
4065  xDevice->DrawCheckered(aRect.TopLeft(), aRect.GetSize(), 8, aW, aG);
4066  xDevice->SetFillColor();
4067  }
4068  else
4069  {
4070  if (rColor.first == COL_AUTO)
4071  xDevice->SetFillColor(m_aAutoDisplayColor);
4072  else
4073  xDevice->SetFillColor(rColor.first);
4074  }
4075 
4076  xDevice->SetLineColor(rStyleSettings.GetDisableColor());
4077  xDevice->DrawRect(aRect);
4078 
4079  m_xButton->set_image(xDevice.get());
4080  m_xButton->set_label(rColor.second);
4081 }
4082 
4084  : m_pMenuButton(pMenuButton)
4085  , m_pToolbar(nullptr)
4086  , m_pControl(nullptr)
4087  , m_nId(0)
4088 {
4089 }
4090 
4092  : m_pMenuButton(nullptr)
4093  , m_pToolbar(pToolbar)
4094  , m_aIdent(rIdent)
4095  , m_pControl(nullptr)
4096  , m_nId(0)
4097 {
4098 }
4099 
4101  : m_pMenuButton(nullptr)
4102  , m_pToolbar(nullptr)
4103  , m_pControl(pControl)
4104  , m_xToolBox(pToolbar)
4105  , m_nId(nId)
4106 {
4107 }
4108 
4110 {
4111 }
4112 
4114 {
4115  if (m_pMenuButton)
4116  return m_pMenuButton->get_active();
4117  if (m_pToolbar)
4119  return m_xToolBox->GetDownItemId() == m_nId;
4120 }
4121 
4123 {
4124  if (m_pMenuButton)
4125  {
4126  if (m_pMenuButton->get_active())
4127  m_pMenuButton->set_active(false);
4128  return;
4129  }
4130  if (m_pToolbar)
4131  {
4134  return;
4135  }
4136  m_pControl->EndPopupMode();
4137 }
4138 
4140 {
4141  if (m_pMenuButton)
4142  return m_pMenuButton;
4143  if (m_pToolbar)
4144  return m_pToolbar;
4145  return m_xToolBox->GetFrameWeld();
4146 }
4147 
4148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString AsRGBHexString() const
static void ShowPanel(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame, bool bFocus=false)
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
static NamedColor GetSelectEntryColor(ValueSet const *pColorSet)
Definition: tbcontrl.cxx:1884
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
std::pair< Color, OUString > NamedColor
Definition: Palette.hxx:29
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
const Wallpaper & GetBackground() const
FieldUnit
FrmValidFlags
Definition: tbcontrl.cxx:2200
sal_Int32 nIndex
std::tuple< vcl::RenderContext &, const tools::Rectangle &, bool, const OUString & > render_args
virtual std::optional< SfxItemSet > GetItemSetForPreview()
SvxColorToolBoxControl * m_pControl
Definition: colorwindow.hxx:62
virtual void set_menu_item_active(const OString &rIdent, bool bActive)=0
std::unique_ptr< SvxStyleBox_Base > m_xWeldBox
Definition: tbcontrl.cxx:2640
virtual void SAL_CALL dispose() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
Definition: tbcontrl.cxx:3271
void set_inactive() const
Definition: tbcontrl.cxx:4122
#define COMBO_WIDTH_IN_CHARS
Definition: tbcontrl.cxx:107
void setWidth(tools::Long nWidth)
tools::Long GetDistForWidth(tools::Long nWidth)
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void AddStatusListener(const OUString &rCommandURL)
ColorListBox * mpControl
Definition: colorbox.hxx:26
weld::Toolbar * m_pToolbar
Definition: colorwindow.hxx:59
const Color & GetHighlightTextColor() const
std::unique_ptr< ContentProperties > pData
std::string GetValue
Reference< XControl > m_xControl
enum SAL_DLLPUBLIC_RTTI FillStyle
OUString GetItemCommand(ToolBoxItemId nItemId) const
static XColorListRef CreateStdColorList()
Definition: xtabcolr.cxx:31
virtual OUString SAL_CALL getImplementationName() override=0
int n1
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
OUString maCommand
Definition: colorwindow.hxx:85
ValueSet(std::unique_ptr< weld::ScrolledWindow > pScrolledWindow)
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
Reference< XFrame > xFrame
void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton=false)
Definition: tbcontrl.cxx:3931
void LockWidthRequest()
Definition: tbcontrl.cxx:4034
virtual std::unique_ptr< ComboBox > weld_combo_box(const OString &id)=0
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
sal_uInt8 GetLuminance() const
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
Color GetColorLine1(const Color &rMain)
Color GetColorLine2(const Color &rMain)
sal_Int64 n
std::unique_ptr< SfxTemplateItem > pFamilyState[MAX_FAMILIES]
Definition: tbcontrl.hxx:190
css::uno::Reference< css::lang::XComponent > m_xFrame
VclPtr< ToolBox > m_xToolBox
Definition: colorwindow.hxx:63
VclPtr< SvxStyleBox_Impl > m_xVclBox
Definition: tbcontrl.cxx:2639
weld::Builder * m_pBuilder
sal_Int16 nId
Color GetColorDist(const Color &rMain, const Color &rDefault)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
sal_uInt16 GetCode() const
static OUString GetLineStyleName(SvxBorderLineStyle eStyle)
void SetFamilyState(sal_uInt16 nIdx, const SfxTemplateItem *pItem)
Definition: tbcontrl.cxx:3049
DataChangedEventType GetType() const
virtual void SAL_CALL update() override
Definition: tbcontrl.cxx:2851
basegfx::BColor maColor
const Color & GetLabelTextColor() const
sal_uInt16 GetSelectedItemId() const
static SfxObjectShell * Current()
void InitializeStyles(const Reference< frame::XModel > &xModel)
Definition: tbcontrl.cxx:2653
void SetLine(const editeng::SvxBorderLine *pNew)
std::unique_ptr< Impl > pImpl
Definition: tbcontrl.hxx:158
virtual OUString SAL_CALL getImplementationName() override
Definition: tbcontrl.cxx:2828
static const NfCurrencyTable & GetTheCurrencyTable()
#define MAX_FAMILIES
Definition: tbcontrl.hxx:186
const Size & GetListBoxPreviewDefaultPixelSize() const
SvxColorToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
Definition: tbcontrl.cxx:3232
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: tbcontrl.hxx:209
virtual OUString SAL_CALL getSubToolbarName() override
Definition: tbcontrl.cxx:3501
std::unique_ptr< weld::Label > m_xLabel
virtual void GrabFocus() override
Definition: tbcontrl.cxx:1867
weld::MenuButton * m_pMenuButton
Definition: colorwindow.hxx:57
virtual void SAL_CALL dispose() override
Definition: tbcontrl.cxx:2791
NONE
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
SvxBorderLineStyle
friend class SfxStyleControllerItem_Impl
Definition: tbcontrl.hxx:197
static bool SelectValueSetEntry(SvxColorValueSet *pColorSet, const Color &rColor)
Definition: tbcontrl.cxx:2050
weld::Window * GetFrameWeld() const
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: tbcontrl.cxx:2833
static sal_uInt32 getColumnCount()
virtual void SAL_CALL updateImage() override
Definition: tbcontrl.cxx:3496
sal_Int64 WinBits
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
FontItalic GetItalic()
Reference< XNameAccess > m_xContainer
IMPL_LINK(SvxStyleBox_Base, CustomGetSizeHdl, OutputDevice &, rArg, Size)
Definition: tbcontrl.cxx:872
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
void SetNoSelection()
Definition: colorbox.hxx:69
int n2
void Enable(bool bEnable=true, bool bChild=true)
const OUString & GetName() const
PropertiesInfo aProperties
void DecreaseContrast(sal_uInt8 cContDec)
size_t pos
const vcl::Font & GetFont() const
#define WB_ITEMBORDER
ColorStatus & mrColorStatus
Definition: colorwindow.hxx:88
tools::Long GetLine2ForWidth(tools::Long nWidth)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(const css::uno::Reference< css::awt::XWindow > &rParent) override
Definition: tbcontrl.cxx:3075
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_CurrencyToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)
Definition: tbcontrl.cxx:3824
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
SfxFrame & GetFrame() const
int nCount
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
void Selected(const NamedColor &rNamedColor)
Definition: tbcontrl.cxx:4023
virtual void GetFocus() override
AllSettingsFlags GetFlags() const
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static bool lcl_GetDocFontList(const FontList **ppFontList, SvxFontNameBox_Base *pBox)
Definition: tbcontrl.cxx:1387
tools::Long GetLine1ForWidth(tools::Long nWidth)
constexpr tools::Long GetWidth() const
virtual void statusChanged(const css::frame::FeatureStateEvent &Event)
#define HID_POPUP_LINE
Definition: helpids.h:36
void DrawLine(OutputDevice &rDev, const Point &rP1, const Point &rP2, sal_uInt32 nWidth, SvxBorderLineStyle nDashing)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: tbcontrl.cxx:3515
SfxStyleFamily
constexpr tools::Long getHeight() const
virtual OutputDevice & get_ref_device()=0
IMPL_LINK_NOARG(SvxStyleBox_Base, ActivateHdl, weld::ComboBox &, bool)
Definition: tbcontrl.cxx:948
void operator()(const OUString &rCommand, const NamedColor &rColor)
Definition: tbcontrl.cxx:3916
std::unique_ptr< weld::ComboBox > mxPaletteListBox
Definition: colorwindow.hxx:94
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
sal_uInt16 nCode
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: tbcontrl.cxx:2838
ColorWindow(const OUString &rCommand, std::shared_ptr< PaletteManager > const &rPaletteManager, ColorStatus &rColorStatus, sal_uInt16 nSlotId, const css::uno::Reference< css::frame::XFrame > &rFrame, const MenuOrToolMenuButton &rMenuButton, TopLevelParentFunction const &rTopLevelParentFunction, ColorSelectFunction const &rColorSelectFunction)
Definition: tbcontrl.cxx:1758
bool IsNoSelection() const
Definition: tbcontrl.cxx:2024
void DrawRect(const tools::Rectangle &rRect)
const OUString & GetStyleName() const
std::unique_ptr< weld::Container > m_xTopLevel
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual void SAL_CALL functionSelected(const OUString &rCommand) override
Definition: tbcontrl.cxx:3506
const OUString & GetName() const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
void SelectEntry(const NamedColor &rColor)
Definition: tbcontrl.cxx:4002
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow()
const Color & GetDisableColor() const
Right
std::unique_ptr< weld::Button > mxButtonPicker
Definition: colorwindow.hxx:97
TopLevelParentFunction m_aTopLevelParentFunction
Definition: colorbox.hxx:43
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_StyleToolBoxControl_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: tbcontrl.cxx:2844
#define COL_NONE_COLOR
Definition: colorwindow.hxx:49
#define DBG_ASSERT(sCon, aError)
void DecreaseLuminance(sal_uInt8 cLumDec)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: tbcontrl.cxx:2769
int i
uno_Any a
Reference< XTextListener > m_xListener
bool IsDark() const
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
Definition: tbcontrl.cxx:3377
std::unique_ptr< weld::Button > mxButtonNoneColor
Definition: colorwindow.hxx:96
std::unique_ptr< SvxColorValueSet > mxRecentColorSet
Definition: colorwindow.hxx:93
OUString sName
float approximate_digit_width() const
#define LANGUAGE_SYSTEM
LanguageType GetLanguage(SwWrtShell &rSh, sal_uInt16 nLangWhichId)
#define HID_POPUP_COLOR_CTRL
Definition: helpids.h:34
rtl::Reference< SfxStyleControllerItem_Impl > m_xBoundItems[MAX_FAMILIES]
Definition: tbcontrl.hxx:189
ColorStatus m_aColorStatus
Definition: tbcontrl.hxx:210
OUString aId
ToolBoxItemId m_nId
Definition: colorwindow.hxx:64
bool IsBright() const
weld::Button * mpDefaultButton
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:34
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
const Color & GetColor() const
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
Definition: tbcontrl.cxx:3355
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
std::unique_ptr< weld::Widget > mxAutomaticSeparator
Definition: colorwindow.hxx:98
virtual void set_active(bool active)=0
void SetFillColor()
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent)=0
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const Color & GetFieldColor() const
OUString ApplyLreOrRleEmbedding(const OUString &rText)
DECL_LINK(FocusHdl, weld::Widget &, void)
virtual OUString SAL_CALL getImplementationName() override
Definition: tbcontrl.cxx:3510
float u
unsigned char sal_Bool
void SetTextColor(const Color &rColor)
std::shared_ptr< PaletteManager > mxPaletteManager
Definition: colorwindow.hxx:87
OUString GetItemText(sal_uInt16 nItemId) const
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
Definition: tbcontrl.cxx:3416
void ShowNoneButton()
Definition: tbcontrl.cxx:1875
::std::vector< std::pair< OUString, OUString > > aDefaultStyles
Definition: tbcontrl.cxx:2635
ITALIC_NONE
sal_uInt16 GetModifier() const
const OUString & GetStyleName() const
FontPitch
std::unique_ptr< weld::Button > mxButtonAutoColor
Definition: colorwindow.hxx:95
SfxStyleFamily GetActFamily() const
Definition: tbcontrl.cxx:2858
#define ITEM_HEIGHT
Definition: tbcontrl.cxx:831
void Clear(EHistoryType eHistory)
std::function< weld::Window *()> TopLevelParentFunction
Definition: colorwindow.hxx:29
SvxBorderLineStyle GetStyle() const
exports com.sun.star. style
ColorStatus m_aColorStatus
Definition: colorbox.hxx:44
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
void Disable(bool bChild=true)
static const char * StyleSlotToStyleCommand[MAX_FAMILIES]
Definition: tbcontrl.cxx:2744
const sal_uInt16 theSlotId
Definition: colorwindow.hxx:84
float GetDPIScaleFactor() const
void createColorWindow()
Definition: tbcontrl.cxx:3977
constexpr Point TopLeft() const
virtual ~ColorWindow() override
Definition: tbcontrl.cxx:1880
ColorSelectFunction m_aColorSelectFunction
Definition: tbcontrl.hxx:213
virtual void SAL_CALL execute(sal_Int16 nSelectModifier) override
Definition: tbcontrl.cxx:3446
MenuOrToolMenuButton(weld::MenuButton *pMenuButton)
Definition: tbcontrl.cxx:4083
#define HID_POPUP_COLOR
Definition: helpids.h:33
size_t GetFontNameCount() const
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
NamedColor m_aSelectedColor
Definition: colorbox.hxx:39
constexpr tools::Long Bottom() const
void SelectItem(sal_uInt16 nItemId)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
SfxStyleControllerItem_Impl(const Reference< XDispatchProvider > &rDispatchProvider, sal_uInt16 nSlotId, const OUString &rCommand, SvxStyleToolBoxControl &rTbxCtl)
Definition: tbcontrl.cxx:2594
weld::Window * GetParentFrame() const
Definition: tbcontrl.cxx:3349
const LanguageTag & getLocale()
ValueSet & operator=(const ValueSet &)=delete
WinBits const WB_3DLOOK
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
FontFamily
std::unique_ptr< svx::ToolboxButtonColorUpdaterBase > m_xBtnUpdater
Definition: tbcontrl.hxx:208
Fill
ColorListBox(std::unique_ptr< weld::MenuButton > pControl, TopLevelParentFunction const &rTopLevelParentFunction)
Definition: tbcontrl.cxx:3942
const OUString & GetFamilyName() const
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
const vcl::KeyCode & GetKeyCode() const
tools::Long GetMinWidth() const
virtual ~SvxColorToolBoxControl() override
Definition: tbcontrl.cxx:3336
constexpr Size GetSize() const
static Color lcl_mediumColor(Color aMain, Color)
Definition: tbcontrl.cxx:2502
void EnsurePaletteManager()
Definition: tbcontrl.cxx:3922
static SfxViewFrame * Current()
void SetNone(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
SfxItemState
#define WB_NO_DIRECTSELECT
ListBoxColorWrapper(ColorListBox *pControl)
Definition: tbcontrl.cxx:3911
void SelectStyle(const OUString &rStyleName)
Definition: tbcontrl.cxx:2976
static constexpr sal_uInt32 getMaxRowCount()
bool get_active() const
Definition: tbcontrl.cxx:4113
size_t GetItemCount() const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
constexpr tools::Long Height() const
ITALIC_NORMAL
unsigned char sal_uInt8
std::unique_ptr< ColorWindow > m_xColorWindow
Definition: colorbox.hxx:33
constexpr sal_uInt16 KEY_ESCAPE
void SetFont(const vcl::Font &rNewFont)
virtual void grab_focus()=0
SfxStyleSheetBase * Next()
virtual void dispose() override
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
MapUnit GetMapUnit() const
tools::Long GetTextHeight() const
OUString aName
Color m_aAutoDisplayColor
Definition: colorbox.hxx:37
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
ColorWindow * getColorWindow() const
Definition: tbcontrl.cxx:3970
virtual ~SvxStyleToolBoxControl() override
Definition: tbcontrl.cxx:2765
virtual sal_Bool SAL_CALL opensSubToolbar() override
Definition: tbcontrl.cxx:3488
tools::Long AdjustWidth(tools::Long n)
#define HID_STYLE_LISTBOX
Definition: helpids.h:39
Color GetColor()
Definition: tbcontrl.cxx:2138
static VclPtr< reference_type > Create(Arg &&...arg)
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: colorbox.hxx:42
void SelectEntry(const NamedColor &rColor)
Definition: tbcontrl.cxx:2063
Link< ColorListBox &, void > m_aSelectedLink
Definition: colorbox.hxx:35
virtual void SAL_CALL update() override
Definition: tbcontrl.cxx:3306
void setColorSelectFunction(const ColorSelectFunction &aColorSelectFunction)
Definition: tbcontrl.cxx:3342
Reference< XComponentContext > getProcessComponentContext()
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
virtual void setProperty(const css::uno::Any &aProperty) override
SfxStyleSheetBasePool * pStyleSheetPool
Definition: tbcontrl.hxx:188
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual void statusChanged(const css::frame::FeatureStateEvent &rEvent) override
Definition: tbcontrl.cxx:2033
const Color & GetWindowColor() const
bool m_bShowNoneButton
Definition: colorbox.hxx:41
sal_uInt16 m_nSlotId
Definition: colorbox.hxx:40
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_FrameToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)
Definition: tbcontrl.cxx:3606
tools::Long AdjustHeight(tools::Long n)
virtual bool get_menu_item_active(const OString &rIdent) const =0
void ShowChildWindow(sal_uInt16, bool bVisible=true)
WinBits const WB_TABSTOP
static OUString GetLanguageString(const LanguageType eType)
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, const tools::Long *pDXArray=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr) const
void SetItalic(FontItalic)
void setHeight(tools::Long nHeight)
std::function< void(const OUString &, const NamedColor &)> ColorSelectFunction
Definition: Palette.hxx:33
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
ListBoxColorWrapper m_aColorWrapper
Definition: colorbox.hxx:36
#define SAL_WARN(area, stream)
std::vector< OUString > NfWSStringsDtor
OUString aCommand
constexpr tools::Long getWidth() const
Color maTLBRColor
Definition: colorwindow.hxx:38
IMPL_STATIC_LINK_NOARG(SvxStyleBox_Base, ShowMoreHdl, void *, void)
Definition: tbcontrl.cxx:933
#define DEF_LINE_WIDTH_0
Left
std::unique_ptr< SvxColorValueSet > mxColorSet
Definition: colorwindow.hxx:92
#define HID_POPUP_FRAME
Definition: helpids.h:35
const FontList * GetFontList() const
size_t size() const
std::unique_ptr< weld::Image > m_xWidget
void dispose()
#define MAX_MRU_FONTNAME_ENTRIES
Definition: tbcontrl.cxx:105
#define WB_FLATVALUESET
SvxStyleBox_Base * m_pBox
Definition: tbcontrl.cxx:2641
constexpr sal_uInt16 KEY_SHIFT
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
const Size & GetSizePixel() const
const Color & GetDialogTextColor() const
void CheckItem(ToolBoxItemId nItemId, bool bCheck=true)
virtual void set_size_request(int nWidth, int nHeight)=0
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ColorToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)
Definition: tbcontrl.cxx:3521
void Push(PushFlags nFlags=PushFlags::ALL)
NamedColor GetSelectEntryColor() const
Definition: tbcontrl.cxx:1937
void statusChanged(const css::frame::FeatureStateEvent &rEvent)
Definition: tbcontrl.cxx:2115
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
virtual void GrabFocus()=0
Color maBLTRColor
Definition: colorwindow.hxx:39
std::unique_ptr< weld::MenuButton > m_xButton
Definition: colorbox.hxx:34
NamedColor GetAutoColor() const
Definition: tbcontrl.cxx:1979
virtual bool get_active() const =0
aStr
void Dispatch(const OUString &aCommand, css::uno::Sequence< css::beans::PropertyValue > const &aArgs)
#define BUTTON_PADDING
Definition: tbcontrl.cxx:830
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
Definition: tbcontrl.cxx:3056
sal_Int16 GetCaseMap(sal_Int32 nToken)
virtual void StateChangedAtStatusListener(SfxItemState eState, const SfxPoolItem *pState) override
Definition: tbcontrl.cxx:2604
Color GetItemColor(sal_uInt16 nItemId) const
static bool LineToSvxLine(const css::table::BorderLine &rLine, editeng::SvxBorderLine &rSvxLine, bool bConvert)
sal_uInt16 nPos
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: tbcontrl.cxx:3225
SvxStyleToolBoxControl & rControl
Definition: tbcontrl.cxx:827
ToolBoxItemId GetDownItemId() const
sal_uInt16 GetId() const
constexpr sal_uInt16 KEY_TAB
void ShowPreview(const NamedColor &rColor)
Definition: tbcontrl.cxx:4053
virtual void DataChanged(const DataChangedEvent &rDCEvt)
void SetNoSelection()
Definition: tbcontrl.cxx:2017
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
#define CONVERT_TWIPS
constexpr tools::Long GetHeight() const
weld::Widget * get_widget() const
Definition: tbcontrl.cxx:4139
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
OUString EditResId(TranslateId aId)
OUString sId