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