LibreOffice Module svx (master)  1
fillctrl.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 <sfx2/app.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <sfx2/viewsh.hxx>
27 #include <rtl/ustring.hxx>
28 #include <vcl/event.hxx>
29 #include <vcl/settings.hxx>
30 #include <vcl/toolbox.hxx>
31 #include <svx/svxids.hrc>
32 
33 #define TMP_STR_BEGIN "["
34 #define TMP_STR_END "]"
35 
36 #include <svx/drawitem.hxx>
37 #include <svx/xfillit0.hxx>
38 #include <svx/xtable.hxx>
39 #include <svx/fillctrl.hxx>
40 #include <svx/itemwin.hxx>
41 #include <svx/xflclit.hxx>
42 #include <svx/xflgrit.hxx>
43 #include <svx/xflhtit.hxx>
44 #include <svx/xbtmpit.hxx>
45 #include <memory>
46 
47 
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::util;
51 using namespace ::com::sun::star::beans;
52 using namespace ::com::sun::star::lang;
53 
55 
57  sal_uInt16 nSlotId,
58  sal_uInt16 nId,
59  ToolBox& rTbx )
60  : SfxToolBoxControl( nSlotId, nId, rTbx )
61  , mpStyleItem()
62  , mpColorItem()
63  , mpFillGradientItem()
64  , mpHatchItem()
65  , mpBitmapItem()
66  , mpFillControl(nullptr)
67  , mpLbFillType(nullptr)
68  , mpLbFillAttr(nullptr)
69  , meLastXFS(static_cast<drawing::FillStyle>(-1))
70  , mnLastPosGradient(0)
71  , mnLastPosHatch(0)
72  , mnLastPosBitmap(0)
73 {
74  addStatusListener( ".uno:FillColor");
75  addStatusListener( ".uno:FillGradient");
76  addStatusListener( ".uno:FillHatch");
77  addStatusListener( ".uno:FillBitmap");
78  addStatusListener( ".uno:ColorTableState");
79  addStatusListener( ".uno:GradientListState");
80  addStatusListener( ".uno:HatchListState");
81  addStatusListener( ".uno:BitmapListState");
82 }
83 
85 {
86 }
87 
89  sal_uInt16 nSID,
90  SfxItemState eState,
91  const SfxPoolItem* pState)
92 {
93  const bool bDisabled(SfxItemState::DISABLED == eState);
94 
95  switch(nSID)
96  {
97  case SID_ATTR_FILL_STYLE:
98  {
99  if(bDisabled)
100  {
103  mpLbFillAttr->Show();
106  mpToolBoxColor->Hide();
107  meLastXFS = static_cast<drawing::FillStyle>(-1);
108  mpStyleItem.reset();
109  }
110 
111  if(eState >= SfxItemState::DEFAULT)
112  {
113  const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState);
114 
115  if(pItem)
116  {
117  mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
118  mpLbFillType->Enable();
119  drawing::FillStyle eXFS = mpStyleItem->GetValue();
120  meLastXFS = eXFS;
121  mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS));
122 
123  if(drawing::FillStyle_NONE == eXFS)
124  {
127  }
128 
129  Update();
130  break;
131  }
132  }
133 
135  mpLbFillAttr->Show();
138  mpToolBoxColor->Hide();
139  meLastXFS = static_cast<drawing::FillStyle>(-1);
140  mpStyleItem.reset();
141  break;
142  }
143  case SID_ATTR_FILL_COLOR:
144  {
145  if(SfxItemState::DEFAULT == eState)
146  {
147  mpColorItem.reset(pState ? static_cast<XFillColorItem*>(pState->Clone()) : nullptr);
148  }
149 
150  if(mpStyleItem && drawing::FillStyle_SOLID == mpStyleItem->GetValue())
151  {
152  mpLbFillAttr->Hide();
153  mpToolBoxColor->Show();
154 
155  Update();
156  }
157  break;
158  }
159  case SID_ATTR_FILL_GRADIENT:
160  {
161  if(SfxItemState::DEFAULT == eState)
162  {
163  mpFillGradientItem.reset(pState ? static_cast<XFillGradientItem*>(pState->Clone()) : nullptr);
164  }
165 
166  if(mpStyleItem && drawing::FillStyle_GRADIENT == mpStyleItem->GetValue())
167  {
168  mpLbFillAttr->Show();
169  mpToolBoxColor->Hide();
170 
171  if(SfxItemState::DEFAULT == eState)
172  {
173  mpLbFillAttr->Enable();
174  Update();
175  }
176  else if(SfxItemState::DISABLED == eState )
177  {
180  }
181  else
182  {
184  }
185  }
186  break;
187  }
188  case SID_ATTR_FILL_HATCH:
189  {
190  if(SfxItemState::DEFAULT == eState)
191  {
192  mpHatchItem.reset(pState ? static_cast<XFillHatchItem*>(pState->Clone()) : nullptr);
193  }
194 
195  if(mpStyleItem && drawing::FillStyle_HATCH == mpStyleItem->GetValue())
196  {
197  mpLbFillAttr->Show();
198  mpToolBoxColor->Hide();
199 
200  if(SfxItemState::DEFAULT == eState)
201  {
202  mpLbFillAttr->Enable();
203  Update();
204  }
205  else if(SfxItemState::DISABLED == eState )
206  {
209  }
210  else
211  {
213  }
214  }
215  break;
216  }
217  case SID_ATTR_FILL_BITMAP:
218  {
219  if(SfxItemState::DEFAULT == eState)
220  {
221  mpBitmapItem.reset(pState ? static_cast<XFillBitmapItem*>(pState->Clone()) : nullptr);
222  }
223 
224  if(mpStyleItem && drawing::FillStyle_BITMAP == mpStyleItem->GetValue())
225  {
226  mpLbFillAttr->Show();
227  mpToolBoxColor->Hide();
228 
229  if(SfxItemState::DEFAULT == eState)
230  {
231  mpLbFillAttr->Enable();
232  Update();
233  }
234  else if(SfxItemState::DISABLED == eState )
235  {
238  }
239  else
240  {
242  }
243  }
244  break;
245  }
246  case SID_GRADIENT_LIST:
247  {
248  if(SfxItemState::DEFAULT == eState)
249  {
250  if(mpStyleItem && drawing::FillStyle_GRADIENT == mpStyleItem->GetValue())
251  {
253  {
254  const OUString aString( mpFillGradientItem->GetName() );
256 
257  mpLbFillAttr->Clear();
258  mpLbFillAttr->Enable();
259  mpLbFillAttr->Fill(pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList());
260  mpLbFillAttr->SelectEntry(aString);
261  }
262  else
263  {
265  }
266  }
267  }
268  break;
269  }
270  case SID_HATCH_LIST:
271  {
272  if(SfxItemState::DEFAULT == eState)
273  {
274  if(mpStyleItem && drawing::FillStyle_HATCH == mpStyleItem->GetValue())
275  {
276  if(mpHatchItem)
277  {
278  const OUString aString( mpHatchItem->GetName() );
280 
281  mpLbFillAttr->Clear();
282  mpLbFillAttr->Enable();
283  mpLbFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList());
284  mpLbFillAttr->SelectEntry(aString);
285  }
286  else
287  {
289  }
290  }
291  }
292  break;
293  }
294  case SID_BITMAP_LIST:
295  {
296  if(SfxItemState::DEFAULT == eState)
297  {
298  if(mpStyleItem && drawing::FillStyle_BITMAP == mpStyleItem->GetValue())
299  {
300  if(mpBitmapItem)
301  {
302  const OUString aString( mpBitmapItem->GetName() );
304 
305  mpLbFillAttr->Clear();
306  mpLbFillAttr->Enable();
307  mpLbFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList());
308  mpLbFillAttr->SelectEntry(aString);
309  }
310  else
311  {
313  }
314  }
315  }
316  break;
317  }
318  }
319 }
320 
322 {
323  if(mpStyleItem)
324  {
325  const drawing::FillStyle eXFS = mpStyleItem->GetValue();
327 
328  switch( eXFS )
329  {
330  case drawing::FillStyle_NONE:
331  {
332  mpLbFillAttr->Show();
333  mpToolBoxColor->Hide();
334  break;
335  }
336  case drawing::FillStyle_SOLID:
337  {
338  if(mpColorItem)
339  {
340  mpLbFillAttr->Hide();
341  mpToolBoxColor->Show();
342  }
343  break;
344  }
345  case drawing::FillStyle_GRADIENT:
346  {
347  mpLbFillAttr->Show();
348  mpToolBoxColor->Hide();
349 
350  if(pSh && pSh->GetItem(SID_GRADIENT_LIST))
351  {
352  mpLbFillAttr->Enable();
353  mpLbFillAttr->Clear();
354  mpLbFillAttr->Fill(pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList());
355 
357  {
358  const OUString aString(mpFillGradientItem->GetName());
359 
360  mpLbFillAttr->SelectEntry(aString);
361 
362  // Check if the entry is not in the list
363  if (mpLbFillAttr->GetSelectedEntry() != aString)
364  {
365  sal_Int32 nCount = mpLbFillAttr->GetEntryCount();
366  OUString aTmpStr;
367  if( nCount > 0 )
368  {
369  // Last entry gets tested against temporary entry
370  aTmpStr = mpLbFillAttr->GetEntry( nCount - 1 );
371  if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
372  aTmpStr.endsWith(TMP_STR_END) )
373  {
374  mpLbFillAttr->RemoveEntry(nCount - 1);
375  }
376  }
377  aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
378 
379  XGradientList aGradientList( "", ""/*TODO?*/ );
380  aGradientList.Insert(std::make_unique<XGradientEntry>(mpFillGradientItem->GetGradientValue(), aTmpStr));
381  aGradientList.SetDirty( false );
382  const BitmapEx aBmp = aGradientList.GetUiBitmap( 0 );
383 
384  if(!aBmp.IsEmpty())
385  {
386  mpLbFillAttr->InsertEntry(aGradientList.Get(0)->GetName(), Image(aBmp));
388  }
389  }
390 
391  }
392  else
393  {
395  }
396  }
397  else
398  {
400  }
401  break;
402  }
403  case drawing::FillStyle_HATCH:
404  {
405  mpLbFillAttr->Show();
406  mpToolBoxColor->Hide();
407 
408  if(pSh && pSh->GetItem(SID_HATCH_LIST))
409  {
410  mpLbFillAttr->Enable();
411  mpLbFillAttr->Clear();
412  mpLbFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList());
413 
414  if(mpHatchItem)
415  {
416  const OUString aString(mpHatchItem->GetName());
417 
418  mpLbFillAttr->SelectEntry( aString );
419 
420  // Check if the entry is not in the list
421  if( mpLbFillAttr->GetSelectedEntry() != aString )
422  {
423  const sal_Int32 nCount = mpLbFillAttr->GetEntryCount();
424  OUString aTmpStr;
425  if( nCount > 0 )
426  {
427  // Last entry gets tested against temporary entry
428  aTmpStr = mpLbFillAttr->GetEntry( nCount - 1 );
429  if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
430  aTmpStr.endsWith(TMP_STR_END) )
431  {
432  mpLbFillAttr->RemoveEntry( nCount - 1 );
433  }
434  }
435  aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
436 
437  XHatchList aHatchList( "", ""/*TODO?*/ );
438  aHatchList.Insert(std::make_unique<XHatchEntry>(mpHatchItem->GetHatchValue(), aTmpStr));
439  aHatchList.SetDirty( false );
440  const BitmapEx & aBmp = aHatchList.GetUiBitmap( 0 );
441 
442  if( !aBmp.IsEmpty() )
443  {
444  mpLbFillAttr->InsertEntry(aHatchList.GetHatch(0)->GetName(), Image(aBmp));
446  //delete pBmp;
447  }
448  }
449  }
450  else
451  {
453  }
454  }
455  else
456  {
458  }
459  break;
460  }
461  case drawing::FillStyle_BITMAP:
462  {
463  mpLbFillAttr->Show();
464  mpToolBoxColor->Hide();
465 
466  if(pSh && pSh->GetItem(SID_BITMAP_LIST))
467  {
468  mpLbFillAttr->Enable();
469  mpLbFillAttr->Clear();
470  mpLbFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList());
471 
472  if(mpBitmapItem)
473  {
474  const OUString aString(mpBitmapItem->GetName());
475 
476  mpLbFillAttr->SelectEntry(aString);
477 
478  // Check if the entry is not in the list
479  if (mpLbFillAttr->GetSelectedEntry() != aString)
480  {
481  sal_Int32 nCount = mpLbFillAttr->GetEntryCount();
482  OUString aTmpStr;
483  if( nCount > 0 )
484  {
485  // Last entry gets tested against temporary entry
486  aTmpStr = mpLbFillAttr->GetEntry(nCount - 1);
487  if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
488  aTmpStr.endsWith(TMP_STR_END) )
489  {
490  mpLbFillAttr->RemoveEntry(nCount - 1);
491  }
492  }
493  aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
494 
495  XBitmapListRef xBitmapList =
498  XPropertyListType::Bitmap, "TmpList", ""/*TODO?*/));
499  xBitmapList->Insert(std::make_unique<XBitmapEntry>(mpBitmapItem->GetGraphicObject(), aTmpStr));
500  xBitmapList->SetDirty( false );
501  mpLbFillAttr->Fill( xBitmapList );
503  }
504 
505  }
506  else
507  {
509  }
510  }
511  else
512  {
514  }
515  break;
516  }
517  default:
518  OSL_ENSURE(false, "Non supported FillType (!)");
519  break;
520  }
521  }
522 
523 }
524 
526 {
527  if(GetSlotId() == SID_ATTR_FILL_STYLE)
528  {
530 
537  mpToolBoxColor->InsertItem(".uno:FillColor", m_xFrame, ToolBoxItemBits::DROPDOWNONLY, Size(mpToolBoxColor->GetSizePixel().Width(), 0));
538 
539  mpLbFillType->SetSelectHdl(LINK(this,SvxFillToolBoxControl,SelectFillTypeHdl));
540  mpLbFillAttr->SetSelectHdl(LINK(this,SvxFillToolBoxControl,SelectFillAttrHdl));
541 
542  return mpFillControl.get();
543  }
544  return VclPtr<vcl::Window>();
545 }
546 
548  : Window(pParent, WB_DIALOGCONTROL)
549  , mpLbFillType(VclPtr<SvxFillTypeBox>::Create(this))
550  , mpToolBoxColor(VclPtr<sfx2::sidebar::SidebarToolBox>::Create(this))
551  , mpLbFillAttr(VclPtr<SvxFillAttrBox>::Create(this))
552 {
553  SetOptimalSize();
554 }
555 
557 {
558  disposeOnce();
559 }
560 
562 {
567 }
568 
569 IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox&, void)
570 {
571  const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpLbFillType->GetSelectedEntryPos());
572 
573  if(meLastXFS != eXFS)
574  {
575  mpLbFillAttr->Clear();
577  const XFillStyleItem aXFillStyleItem(eXFS);
578 
579  // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
580  // and one for setting the fill attribute itself, but add two SfxPoolItems to the
581  // call to get just one action at the SdrObject and to create only one Undo action, too.
582  // Checked that this works in all apps.
583  switch( eXFS )
584  {
585  default:
586  case drawing::FillStyle_NONE:
587  {
588  mpLbFillAttr->Show();
589  mpToolBoxColor->Hide();
590  mpLbFillType->Selected();
591  mpLbFillAttr->Disable();
592 
593  // #i122676# need to call a single SID_ATTR_FILL_STYLE change
595  SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
596  { &aXFillStyleItem });
597  break;
598  }
599  case drawing::FillStyle_SOLID:
600  {
601  mpLbFillAttr->Hide();
602  mpToolBoxColor->Show();
603  const OUString aTmpStr;
604  const ::Color aColor = mpColorItem->GetColorValue();
605  const XFillColorItem aXFillColorItem( aTmpStr, aColor );
606 
607  // #i122676# change FillStyle and Color in one call
609  SID_ATTR_FILL_COLOR, SfxCallMode::RECORD,
610  { &aXFillColorItem, &aXFillStyleItem });
611  break;
612  }
613  case drawing::FillStyle_GRADIENT:
614  {
615  mpLbFillAttr->Show();
616  mpToolBoxColor->Hide();
617 
618  if(pSh && pSh->GetItem(SID_GRADIENT_LIST))
619  {
620  if(!mpLbFillAttr->GetEntryCount())
621  {
622  mpLbFillAttr->Enable();
623  mpLbFillAttr->Clear();
624  mpLbFillAttr->Fill(pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList());
625  }
626 
627  mpLbFillAttr->AdaptDropDownLineCountToMaximum();
628 
629  if(LISTBOX_ENTRY_NOTFOUND != mnLastPosGradient)
630  {
631  const SvxGradientListItem * pItem = pSh->GetItem(SID_GRADIENT_LIST);
632 
633  if(mnLastPosGradient < pItem->GetGradientList()->Count())
634  {
635  const XGradient aGradient = pItem->GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient();
636  const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetEntry(mnLastPosGradient), aGradient);
637 
638  // #i122676# change FillStyle and Gradient in one call
640  SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD,
641  { &aXFillGradientItem, &aXFillStyleItem });
642  mpLbFillAttr->SelectEntryPos(mnLastPosGradient);
643  }
644  }
645  }
646  else
647  {
648  mpLbFillAttr->Disable();
649  }
650  break;
651  }
652  case drawing::FillStyle_HATCH:
653  {
654  mpLbFillAttr->Show();
655  mpToolBoxColor->Hide();
656 
657  if(pSh && pSh->GetItem(SID_HATCH_LIST))
658  {
659  if(!mpLbFillAttr->GetEntryCount())
660  {
661  mpLbFillAttr->Enable();
662  mpLbFillAttr->Clear();
663  mpLbFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList());
664  }
665 
666  mpLbFillAttr->AdaptDropDownLineCountToMaximum();
667 
668  if(LISTBOX_ENTRY_NOTFOUND != mnLastPosHatch)
669  {
670  const SvxHatchListItem * pItem = pSh->GetItem(SID_HATCH_LIST);
671 
672  if(mnLastPosHatch < pItem->GetHatchList()->Count())
673  {
674  const XHatch aHatch = pItem->GetHatchList()->GetHatch(mnLastPosHatch)->GetHatch();
675  const XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectedEntry(), aHatch);
676 
677  // #i122676# change FillStyle and Hatch in one call
679  SID_ATTR_FILL_HATCH, SfxCallMode::RECORD,
680  { &aXFillHatchItem, &aXFillStyleItem });
681  mpLbFillAttr->SelectEntryPos(mnLastPosHatch);
682  }
683  }
684  }
685  else
686  {
687  mpLbFillAttr->Disable();
688  }
689  break;
690  }
691  case drawing::FillStyle_BITMAP:
692  {
693  mpLbFillAttr->Show();
694  mpToolBoxColor->Hide();
695 
696  if(pSh && pSh->GetItem(SID_BITMAP_LIST))
697  {
698  if(!mpLbFillAttr->GetEntryCount())
699  {
700  mpLbFillAttr->Enable();
701  mpLbFillAttr->Clear();
702  mpLbFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList());
703  }
704 
705  mpLbFillAttr->AdaptDropDownLineCountToMaximum();
706 
707  if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap)
708  {
709  const SvxBitmapListItem * pItem = pSh->GetItem(SID_BITMAP_LIST);
710 
711  if(mnLastPosBitmap < pItem->GetBitmapList()->Count())
712  {
713  const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(mnLastPosBitmap);
714  const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectedEntry(), pXBitmapEntry->GetGraphicObject());
715 
716  // #i122676# change FillStyle and Bitmap in one call
718  SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
719  { &aXFillBitmapItem, &aXFillStyleItem });
720  mpLbFillAttr->SelectEntryPos(mnLastPosBitmap);
721  }
722  }
723  }
724  else
725  {
726  mpLbFillAttr->Disable();
727  }
728  break;
729  }
730  }
731 
732  meLastXFS = eXFS;
733 
734  if(drawing::FillStyle_NONE != eXFS)
735  {
736  mpLbFillType->Selected();
737  }
738  }
739 }
740 
741 IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void)
742 {
743  const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpLbFillType->GetSelectedEntryPos());
744  const XFillStyleItem aXFillStyleItem(eXFS);
746 
747  // #i122676# dependent from bFillStyleChange, do execute a single or two
748  // changes in one Execute call
749  const bool bFillStyleChange(meLastXFS != eXFS);
750 
751  switch(eXFS)
752  {
753  case drawing::FillStyle_SOLID:
754  {
755  if(bFillStyleChange)
756  {
757  // #i122676# Single FillStyle change call needed here
759  SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
760  { &aXFillStyleItem });
761  }
762  break;
763  }
764  case drawing::FillStyle_GRADIENT:
765  {
766  sal_Int32 nPos = mpLbFillAttr->GetSelectedEntryPos();
767 
768  if(LISTBOX_ENTRY_NOTFOUND == nPos)
769  {
770  nPos = mnLastPosGradient;
771  }
772 
773  if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_GRADIENT_LIST))
774  {
775  const SvxGradientListItem * pItem = pSh->GetItem(SID_GRADIENT_LIST);
776 
777  if(nPos < pItem->GetGradientList()->Count())
778  {
779  const XGradient aGradient = pItem->GetGradientList()->GetGradient(nPos)->GetGradient();
780  const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectedEntry(), aGradient);
781 
782  // #i122676# Change FillStyle and Gradinet in one call
784  SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD,
785  bFillStyleChange
786  ? std::initializer_list<SfxPoolItem const*>{ &aXFillGradientItem, &aXFillStyleItem }
787  : std::initializer_list<SfxPoolItem const*>{ &aXFillGradientItem });
788  }
789  }
790 
791  if(LISTBOX_ENTRY_NOTFOUND != nPos)
792  {
793  mnLastPosGradient = nPos;
794  }
795  break;
796  }
797  case drawing::FillStyle_HATCH:
798  {
799  sal_Int32 nPos = mpLbFillAttr->GetSelectedEntryPos();
800 
801  if(LISTBOX_ENTRY_NOTFOUND == nPos)
802  {
803  nPos = mnLastPosHatch;
804  }
805 
806  if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_HATCH_LIST))
807  {
808  const SvxHatchListItem * pItem = pSh->GetItem(SID_HATCH_LIST);
809 
810  if(nPos < pItem->GetHatchList()->Count())
811  {
812  const XHatch aHatch = pItem->GetHatchList()->GetHatch(nPos)->GetHatch();
813  const XFillHatchItem aXFillHatchItem( mpLbFillAttr->GetSelectedEntry(), aHatch);
814 
815  // #i122676# Change FillStyle and Hatch in one call
817  SID_ATTR_FILL_HATCH, SfxCallMode::RECORD,
818  bFillStyleChange
819  ? std::initializer_list<SfxPoolItem const*>{ &aXFillHatchItem, &aXFillStyleItem }
820  : std::initializer_list<SfxPoolItem const*>{ &aXFillHatchItem });
821  }
822  }
823 
824  if(LISTBOX_ENTRY_NOTFOUND != nPos)
825  {
826  mnLastPosHatch = nPos;
827  }
828  break;
829  }
830  case drawing::FillStyle_BITMAP:
831  {
832  sal_Int32 nPos = mpLbFillAttr->GetSelectedEntryPos();
833 
834  if(LISTBOX_ENTRY_NOTFOUND == nPos)
835  {
836  nPos = mnLastPosBitmap;
837  }
838 
839  if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_BITMAP_LIST))
840  {
841  const SvxBitmapListItem * pItem = pSh->GetItem(SID_BITMAP_LIST);
842 
843  if(nPos < pItem->GetBitmapList()->Count())
844  {
845  const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(nPos);
846  const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectedEntry(), pXBitmapEntry->GetGraphicObject());
847 
848  // #i122676# Change FillStyle and Bitmap in one call
850  SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
851  bFillStyleChange
852  ? std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem, &aXFillStyleItem }
853  : std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem });
854  }
855  }
856 
857  if(LISTBOX_ENTRY_NOTFOUND != nPos)
858  {
859  mnLastPosBitmap = nPos;
860  }
861  break;
862  }
863  default: break;
864  }
865 }
866 
868 {
869  Size aSize(GetOutputSizePixel());
870  long nH = aSize.Height();
871 
872  Size aTypeSize(mpLbFillType->get_preferred_size());
873  long nPrefHeight = aTypeSize.Height();
874  long nOffset = (nH - nPrefHeight)/2;
875  mpLbFillType->SetPosSizePixel(Point(0, nOffset), Size(aTypeSize.Width(), nPrefHeight));
876  nPrefHeight = mpToolBoxColor->get_preferred_size().Height();
877  nOffset = (nH - nPrefHeight)/2;
878  mpToolBoxColor->SetPosSizePixel(Point(aTypeSize.Width(), nOffset),Size(aSize.Width() - aTypeSize.Width(), nPrefHeight));
879  nPrefHeight = mpLbFillType->get_preferred_size().Height();
880  nOffset = (nH - nPrefHeight)/2;
881  mpLbFillAttr->SetPosSizePixel(Point(aTypeSize.Width(), nOffset),Size(aSize.Width() - aTypeSize.Width(), nPrefHeight));
882 }
883 
885 {
887  Size aFirstSize(mpToolBoxColor->get_preferred_size());
888  Size aSecondSize(mpLbFillAttr->get_preferred_size());
889  aSize.setHeight(std::max({aSize.Height(), aFirstSize.Height(), aSecondSize.Height()}));
890  aSize.setWidth(aSize.Width() + LogicToPixel(Size(55, 0), MapMode(MapUnit::MapAppFont)).Width());
891  SetSizePixel(aSize);
892 }
893 
895 {
896  if((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
897  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
898  {
899  SetOptimalSize();
900  }
901  Window::DataChanged(rDCEvt);
902 }
903 
904 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: xattr.cxx:1751
long Width() const
virtual ~FillControl() override
Definition: fillctrl.cxx:556
virtual void dispose() override
Definition: fillctrl.cxx:561
XPropertyEntry * Get(long nIndex) const
Definition: xtable.cxx:134
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
OUString GetSelectedEntry(sal_Int32 nSelIndex=0) const
std::unique_ptr< XFillBitmapItem > mpBitmapItem
Definition: fillctrl.hxx:51
long Height() const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
VclPtr< SvxFillTypeBox > mpLbFillType
Definition: fillctrl.hxx:54
SfxDispatcher * GetDispatcher()
void disposeAndClear()
static XBitmapListRef AsBitmapList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:389
std::unique_ptr< XFillColorItem > mpColorItem
Definition: fillctrl.hxx:48
css::uno::Reference< css::lang::XComponent > m_xFrame
virtual void SetSizePixel(const Size &rNewSize)
std::unique_ptr< XFillGradientItem > mpFillGradientItem
Definition: fillctrl.hxx:49
const XGradientListRef & GetGradientList() const
Definition: drawitem.hxx:73
void RemoveEntry(const OUString &rStr)
DataChangedEventType GetType() const
static SfxObjectShell * Current()
void Clear()
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: fillctrl.cxx:88
virtual void dispose() override
css::drawing::FillStyle meLastXFS
Definition: fillctrl.hxx:58
#define LISTBOX_ENTRY_NOTFOUND
void Insert(std::unique_ptr< XPropertyEntry > pEntry, long nIndex=std::numeric_limits< long >::max())
Definition: xtable.cxx:180
void SelectEntry(const OUString &rStr, bool bSelect=true)
void SetBackground()
void Enable(bool bEnable=true, bool bChild=true)
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fillctrl.cxx:894
sal_Int32 GetEntryCount() const
void Fill(const XHatchListRef &pList)
Definition: itemwin.cxx:572
int nCount
AllSettingsFlags GetFlags() const
virtual void InsertItem(const OUString &rCommand, const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBoxItemBits nBits, const Size &rRequestedSize, ImplToolItems::size_type nPos=APPEND)
OUString GetEntry(sal_Int32 nPos) const
const GraphicObject & GetGraphicObject() const
Definition: xtable.hxx:125
const OUString & GetName() const
const XHatchListRef & GetHatchList() const
Definition: drawitem.hxx:97
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
WinBits const WB_DIALOGCONTROL
bool IsEmpty() const
virtual ~SvxFillToolBoxControl() override
Definition: fillctrl.cxx:84
void SetOptimalSize()
Definition: fillctrl.cxx:884
#define TMP_STR_END
Definition: fillctrl.cxx:34
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Count
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:34
VclPtr< ToolBox > mpToolBoxColor
Definition: fillctrl.hxx:83
void SetNoSelection()
SvxFillToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx)
Definition: fillctrl.cxx:56
XHatchEntry * GetHatch(long nIndex) const
Definition: xtabhtch.cxx:53
Size get_preferred_size() const
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
Definition: xtable.cxx:318
std::unique_ptr< XFillHatchItem > mpHatchItem
Definition: fillctrl.hxx:50
void SetPaintTransparent(bool bTransparent)
Size GetOutputSizePixel() const
void SetSelectHdl(const Link< ListBox &, void > &rLink)
void SetDirty(bool bDirty)
Definition: xtable.hxx:192
VclPtr< FillControl > mpFillControl
Definition: fillctrl.hxx:53
const XBitmapListRef & GetBitmapList() const
Definition: drawitem.hxx:122
void Disable(bool bChild=true)
SFX_IMPL_TOOLBOX_CONTROL(SvxFillToolBoxControl, XFillStyleItem)
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
void reset(reference_type *pBody)
Point LogicToPixel(const Point &rLogicPt) const
Size GetSizePixel() const override
static SfxViewFrame * Current()
SfxItemState
#define TMP_STR_BEGIN
Definition: fillctrl.cxx:33
unsigned short GetSlotId() const
FillControl(vcl::Window *pParent)
Definition: fillctrl.cxx:547
IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox &, void)
Definition: fillctrl.cxx:569
std::unique_ptr< XFillStyleItem > mpStyleItem
Definition: fillctrl.hxx:47
VclPtr< SvxFillAttrBox > mpLbFillAttr
Definition: fillctrl.hxx:84
reference_type * get() const
BitmapEx GetUiBitmap(long nIndex) const
Definition: xtable.cxx:163
VclPtr< ToolBox > mpToolBoxColor
Definition: fillctrl.hxx:55
VclPtr< SvxFillTypeBox > mpLbFillType
Definition: fillctrl.hxx:82
virtual VclPtr< vcl::Window > CreateItemWindow(vcl::Window *pParent) override
Definition: fillctrl.cxx:525
VclPtr< SvxFillAttrBox > mpLbFillAttr
Definition: fillctrl.hxx:56
sal_uInt16 nPos
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
void setHeight(long nHeight)
virtual void Resize() override
Definition: fillctrl.cxx:867