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