LibreOffice Module svx (master)  1
LinePropertyPanelBase.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 <memory>
21 #include <osl/diagnose.h>
25 #include <svx/strings.hrc>
26 #include <svx/svxids.hrc>
27 #include <svx/dialmgr.hxx>
28 #include <sfx2/objsh.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <svx/xtable.hxx>
32 #include <svx/xdash.hxx>
33 #include <svx/drawitem.hxx>
34 #include <svx/svxitems.hrc>
35 #include <svtools/valueset.hxx>
36 #include <unotools/pathoptions.hxx>
37 #include <unotools/viewoptions.hxx>
38 #include <i18nlangtag/mslangid.hxx>
39 #include <svx/xlineit0.hxx>
40 #include <svx/xlndsit.hxx>
41 #include <vcl/svapp.hxx>
42 #include <svx/xlnwtit.hxx>
43 #include <vcl/lstbox.hxx>
44 #include <vcl/toolbox.hxx>
45 #include <svx/xlntrit.hxx>
46 #include <svx/xlnstit.hxx>
47 #include <svx/xlnedit.hxx>
48 #include <svx/xlncapit.hxx>
49 #include <svx/xlinjoit.hxx>
50 #include <bitmaps.hlst>
51 
52 using namespace css;
53 using namespace css::uno;
54 
55 const char UNO_SELECTWIDTH[] = ".uno:SelectWidth";
56 
57 namespace
58 {
59 
60 void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLineEndList& rList, const BitmapEx& rBitmapZero)
61 {
62  const sal_uInt32 nCount(rList.Count());
63  const OUString sNone(SvxResId(RID_SVXSTR_NONE));
64 
65  rListBoxStart.SetUpdateMode(false);
66  rListBoxEnd.SetUpdateMode(false);
67 
68  rListBoxStart.Clear();
69  rListBoxEnd.Clear();
70 
71  for(sal_uInt32 i(0); i < nCount; i++)
72  {
73  const XLineEndEntry* pEntry = rList.GetLineEnd(i);
74  const BitmapEx aBitmap = const_cast< XLineEndList& >(rList).GetUiBitmap(i);
75 
76  if(!aBitmap.IsEmpty())
77  {
78  BitmapEx aCopyStart(aBitmap);
79  BitmapEx aCopyEnd(aBitmap);
80 
81  const Size aBmpSize(aCopyStart.GetSizePixel());
82  const tools::Rectangle aCropRectStart(Point(), Size(aBmpSize.Width() / 2, aBmpSize.Height()));
83  const tools::Rectangle aCropRectEnd(Point(aBmpSize.Width() / 2, 0), Size(aBmpSize.Width() / 2, aBmpSize.Height()));
84 
85  aCopyStart.Crop(aCropRectStart);
86  rListBoxStart.InsertEntry(
87  pEntry->GetName(),
88  Image(aCopyStart));
89 
90  aCopyEnd.Crop(aCropRectEnd);
91  rListBoxEnd.InsertEntry(
92  pEntry->GetName(),
93  Image(aCopyEnd));
94  }
95  else
96  {
97  rListBoxStart.InsertEntry(pEntry->GetName());
98  rListBoxEnd.InsertEntry(pEntry->GetName());
99  }
100  }
101 
102  // add 'none' entries
103  if (!rBitmapZero.IsEmpty())
104  {
105  const Image aImg = rListBoxStart.GetEntryImage(0);
106  const Size aImgSize = aImg.GetSizePixel();
107 
108  // take solid line bitmap and crop it to the size of
109  // line cap entries
110  BitmapEx aCopyZero( rBitmapZero );
111  const tools::Rectangle aCropZero( Point(), aImgSize );
112  aCopyZero.Crop( aCropZero );
113 
114  // make it 1st item in list
115  rListBoxStart.InsertEntry( sNone, Image(aCopyZero), 0);
116  rListBoxEnd.InsertEntry( sNone, Image(aCopyZero), 0);
117  }
118  else
119  {
120  rListBoxStart.InsertEntry(sNone);
121  rListBoxEnd.InsertEntry(sNone);
122  }
123 
124  rListBoxStart.SetUpdateMode(true);
125  rListBoxEnd.SetUpdateMode(true);
126 }
127 
128 void FillLineStyleListBox(ListBox& rListBox, const XDashList& rList)
129 {
130  const sal_uInt32 nCount(rList.Count());
131  rListBox.SetUpdateMode(false);
132 
133  rListBox.Clear();
134 
135  // entry for 'none'
136  rListBox.InsertEntry(rList.GetStringForUiNoLine());
137 
138  // entry for solid line
139  rListBox.InsertEntry(rList.GetStringForUiSolidLine(),
140  Image( rList.GetBitmapForUISolidLine()));
141 
142  for(sal_uInt32 i(0); i < nCount; i++)
143  {
144  const XDashEntry* pEntry = rList.GetDash(i);
145  const BitmapEx & rBitmap = const_cast< XDashList& >(rList).GetUiBitmap(i);
146 
147  if(!rBitmap.IsEmpty())
148  {
149  rListBox.InsertEntry(pEntry->GetName(), Image(rBitmap));
150  }
151  else
152  {
153  rListBox.InsertEntry(pEntry->GetName());
154  }
155  }
156 
157  rListBox.SetUpdateMode(true);
158 }
159 
160 } // end of anonymous namespace
161 
162 namespace svx { namespace sidebar {
163 
164 LinePropertyPanelBase::LinePropertyPanelBase(
165  vcl::Window* pParent,
166  const uno::Reference<css::frame::XFrame>& rxFrame)
167 : PanelLayout(pParent, "LinePropertyPanel", "svx/ui/sidebarline.ui", rxFrame),
168  mpStyleItem(),
169  mpDashItem(),
170  mnTrans(0),
171  meMapUnit(MapUnit::MapMM),
172  mnWidthCoreValue(0),
173  mpStartItem(),
174  mpEndItem(),
175  mxLineWidthPopup(VclPtr<LineWidthPopup>::Create(*this)),
176  maIMGNone(StockImage::Yes, BMP_NONE_ICON),
177  mpIMGWidthIcon(),
178  mbWidthValuable(true),
179  mbArrowSupported(true)
180 {
181  get(mpFTWidth, "widthlabel");
182  get(mpTBWidth, "width");
183  get(mpTBColor, "color");
184  get(mpLBStyle, "linestyle");
185  get(mpFTTransparency, "translabel");
186  get(mpMFTransparent, "linetransparency");
187  get(mpLBStart, "beginarrowstyle");
188  get(mpLBEnd, "endarrowstyle");
189  get(mpFTEdgeStyle, "cornerlabel");
190  get(mpLBEdgeStyle, "edgestyle");
191  get(mpFTCapStyle, "caplabel");
192  get(mpLBCapStyle, "linecapstyle");
193  get(mpGridLineProps, "lineproperties");
194  get(mpBoxArrowProps, "arrowproperties");
195 
196  Initialize();
197 }
198 
200 {
201  disposeOnce();
202 }
203 
205 {
206  mxLineWidthPopup.disposeAndClear();
207  mpFTWidth.clear();
208  mpTBWidth.clear();
209  mpTBColor.clear();
210  mpLBStyle.clear();
213  mpLBStart.clear();
214  mpLBEnd.clear();
221 
223 }
224 
226 {
227  mpIMGWidthIcon.reset(new Image[8]);
228  mpIMGWidthIcon[0] = Image(StockImage::Yes, BMP_WIDTH1_ICON);
229  mpIMGWidthIcon[1] = Image(StockImage::Yes, BMP_WIDTH2_ICON);
230  mpIMGWidthIcon[2] = Image(StockImage::Yes, BMP_WIDTH3_ICON);
231  mpIMGWidthIcon[3] = Image(StockImage::Yes, BMP_WIDTH4_ICON);
232  mpIMGWidthIcon[4] = Image(StockImage::Yes, BMP_WIDTH5_ICON);
233  mpIMGWidthIcon[5] = Image(StockImage::Yes, BMP_WIDTH6_ICON);
234  mpIMGWidthIcon[6] = Image(StockImage::Yes, BMP_WIDTH7_ICON);
235  mpIMGWidthIcon[7] = Image(StockImage::Yes, BMP_WIDTH8_ICON);
236 
238  SelectLineStyle();
239  mpLBStyle->SetSelectHdl( LINK( this, LinePropertyPanelBase, ChangeLineStyleHdl ) );
241 
242  const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH);
243  mpTBWidth->SetItemImage(nIdWidth, mpIMGWidthIcon[0]);
244  mpTBWidth->SetItemBits( nIdWidth, mpTBWidth->GetItemBits( nIdWidth ) | ToolBoxItemBits::DROPDOWNONLY );
245  Link<ToolBox *, void> aLink2 = LINK(this, LinePropertyPanelBase, ToolboxWidthSelectHdl);
246  mpTBWidth->SetDropdownClickHdl ( aLink2 );
247  mpTBWidth->SetSelectHdl ( aLink2 );
248 
249  FillLineEndList();
250  SelectEndStyle(true);
251  SelectEndStyle(false);
252  mpLBStart->SetSelectHdl( LINK( this, LinePropertyPanelBase, ChangeStartHdl ) );
254  mpLBEnd->SetSelectHdl( LINK( this, LinePropertyPanelBase, ChangeEndHdl ) );
256 
257  mpMFTransparent->SetModifyHdl(LINK(this, LinePropertyPanelBase, ChangeTransparentHdl));
258 
259  mpLBEdgeStyle->SetSelectHdl( LINK( this, LinePropertyPanelBase, ChangeEdgeStyleHdl ) );
260 
261  mpLBCapStyle->SetSelectHdl( LINK( this, LinePropertyPanelBase, ChangeCapStyleHdl ) );
262 }
263 
265 {
266 }
267 
268 void LinePropertyPanelBase::updateLineStyle(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem)
269 {
270  if(bDisabled)
271  {
272  mpLBStyle->Disable();
273  }
274  else
275  {
276  mpLBStyle->Enable();
277  }
278 
279  if(bSetOrDefault)
280  {
281  if(pItem)
282  {
283  mpStyleItem.reset(static_cast<XLineStyleItem*>(pItem->Clone()));
284  }
285  }
286  else
287  {
288  mpStyleItem.reset();
289  }
290 
291  SelectLineStyle();
292 }
293 
294 void LinePropertyPanelBase::updateLineDash(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem)
295 {
296  if(bDisabled)
297  {
298  mpLBStyle->Disable();
299  }
300  else
301  {
302  mpLBStyle->Enable();
303  }
304 
305  if(bSetOrDefault)
306  {
307  if(pItem)
308  {
309  mpDashItem.reset(static_cast<XLineDashItem*>(pItem->Clone()));
310  }
311  }
312  else
313  {
314  mpDashItem.reset();
315  }
316 
317  SelectLineStyle();
318 }
319 
320 void LinePropertyPanelBase::updateLineTransparence(bool bDisabled, bool bSetOrDefault,
321  const SfxPoolItem* pState)
322 {
323  if(bDisabled)
324  {
327  }
328  else
329  {
332  }
333 
334  if(bSetOrDefault)
335  {
336  if (const XLineTransparenceItem* pItem = dynamic_cast<const XLineTransparenceItem*>(pState))
337  {
338  mnTrans = pItem->GetValue();
340  return;
341  }
342  }
343 
344  mpMFTransparent->SetValue(0);//add
345  mpMFTransparent->SetText(OUString());
346 }
347 
348 void LinePropertyPanelBase::updateLineWidth(bool bDisabled, bool bSetOrDefault,
349  const SfxPoolItem* pState)
350 {
351  if(bDisabled)
352  {
353  mpTBWidth->Disable();
354  mpFTWidth->Disable();
355  }
356  else
357  {
358  mpTBWidth->Enable();
359  mpFTWidth->Enable();
360  }
361 
362  if(bSetOrDefault)
363  {
364  if (const XLineWidthItem* pItem = dynamic_cast<const XLineWidthItem*>(pState))
365  {
366  mnWidthCoreValue = pItem->GetValue();
367  mbWidthValuable = true;
368  SetWidthIcon();
369  return;
370  }
371  }
372 
373  mbWidthValuable = false;
374  SetWidthIcon();
375 }
376 
377 void LinePropertyPanelBase::updateLineStart(bool bDisabled, bool bSetOrDefault,
378  const SfxPoolItem* pItem)
379 {
380  if(bDisabled)
381  {
382  mpLBStart->Disable();
383  }
384  else
385  {
386  if (mbArrowSupported)
387  mpLBStart->Enable();
388  }
389 
390  if(bSetOrDefault && pItem)
391  {
392  mpStartItem.reset(static_cast<XLineStartItem*>(pItem->Clone()));
393  SelectEndStyle(true);
394  return;
395  }
396 
397  mpStartItem.reset();
398  SelectEndStyle(true);
399 }
400 
401 void LinePropertyPanelBase::updateLineEnd(bool bDisabled, bool bSetOrDefault,
402  const SfxPoolItem* pItem)
403 {
404  if(bDisabled)
405  {
406  mpLBEnd->Disable();
407  }
408  else
409  {
410  if (mbArrowSupported)
411  mpLBEnd->Enable();
412  }
413 
414  if(bSetOrDefault && pItem)
415  {
416  mpEndItem.reset(static_cast<XLineEndItem*>(pItem->Clone()));
417  SelectEndStyle(false);
418  return;
419  }
420 
421  mpEndItem.reset();
422  SelectEndStyle(false);
423 }
424 
425 void LinePropertyPanelBase::updateLineJoint(bool bDisabled, bool bSetOrDefault,
426  const SfxPoolItem* pState)
427 {
428  if(bDisabled)
429  {
432  }
433  else
434  {
437  }
438 
439  if(bSetOrDefault)
440  {
441  if (const XLineJointItem* pItem = dynamic_cast<const XLineJointItem*>(pState))
442  {
443  sal_Int32 nEntryPos(0);
444 
445  switch(pItem->GetValue())
446  {
447  case drawing::LineJoint_ROUND:
448  {
449  nEntryPos = 1;
450  break;
451  }
452  case drawing::LineJoint_NONE:
453  {
454  nEntryPos = 2;
455  break;
456  }
457  case drawing::LineJoint_MIDDLE:
458  case drawing::LineJoint_MITER:
459  {
460  nEntryPos = 3;
461  break;
462  }
463  case drawing::LineJoint_BEVEL:
464  {
465  nEntryPos = 4;
466  break;
467  }
468 
469  default:
470  break;
471  }
472 
473  if(nEntryPos)
474  {
475  mpLBEdgeStyle->SelectEntryPos(nEntryPos - 1);
476  return;
477  }
478  }
479  }
480 
482 }
483 
484 void LinePropertyPanelBase::updateLineCap(bool bDisabled, bool bSetOrDefault,
485  const SfxPoolItem* pState)
486 {
487  if(bDisabled)
488  {
491  }
492  else
493  {
494  mpLBCapStyle->Enable();
495  mpLBCapStyle->Enable();
496  }
497 
498  if(bSetOrDefault)
499  {
500  if (const XLineCapItem* pItem = dynamic_cast<const XLineCapItem*>(pState))
501  {
502  sal_Int32 nEntryPos(0);
503 
504  switch(pItem->GetValue())
505  {
506  case drawing::LineCap_BUTT:
507  {
508  nEntryPos = 1;
509  break;
510  }
511  case drawing::LineCap_ROUND:
512  {
513  nEntryPos = 2;
514  break;
515  }
516  case drawing::LineCap_SQUARE:
517  {
518  nEntryPos = 3;
519  break;
520  }
521 
522  default:
523  break;
524  }
525 
526  if(nEntryPos)
527  {
528  mpLBCapStyle->SelectEntryPos(nEntryPos - 1);
529  return;
530  }
531  }
532  }
533 
535 }
536 
537 IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeLineStyleHdl, ListBox&, void)
538 {
539  const sal_Int32 nPos(mpLBStyle->GetSelectedEntryPos());
540 
541  if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBStyle->IsValueChangedFromSaved())
542  {
543  if(0 == nPos)
544  {
545  // drawing::LineStyle_NONE
546  const XLineStyleItem aItem(drawing::LineStyle_NONE);
547 
548  setLineStyle(aItem);
549  }
550  else if(1 == nPos)
551  {
552  // drawing::LineStyle_SOLID
553  const XLineStyleItem aItem(drawing::LineStyle_SOLID);
554 
555  setLineStyle(aItem);
556  }
557  else if (mxLineStyleList.is() && mxLineStyleList->Count() > static_cast<long>(nPos - 2))
558  {
559  // drawing::LineStyle_DASH
560  const XLineStyleItem aItemA(drawing::LineStyle_DASH);
561  const XDashEntry* pDashEntry = mxLineStyleList->GetDash(nPos - 2);
562  OSL_ENSURE(pDashEntry, "OOps, got empty XDash from XDashList (!)");
563  const XLineDashItem aItemB(
564  pDashEntry ? pDashEntry->GetName() : OUString(),
565  pDashEntry ? pDashEntry->GetDash() : XDash());
566 
567  setLineStyle(aItemA);
568  setLineDash(aItemB);
569  }
570  }
571 
572  ActivateControls();
573 }
574 
576 {
577  sal_Int32 nPos = mpLBStart->GetSelectedEntryPos();
578  if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBStart->IsValueChangedFromSaved() )
579  {
580  std::unique_ptr<XLineStartItem> pItem;
581  if( nPos == 0 )
582  pItem.reset(new XLineStartItem());
583  else if( mxLineEndList.is() && mxLineEndList->Count() > static_cast<long>( nPos - 1 ) )
584  pItem.reset(new XLineStartItem( mpLBStart->GetSelectedEntry(),mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ));
585  setLineStartStyle(pItem.get());
586  }
587 }
588 
590 {
591  sal_Int32 nPos = mpLBEnd->GetSelectedEntryPos();
592  if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBEnd->IsValueChangedFromSaved() )
593  {
594  std::unique_ptr<XLineEndItem> pItem;
595  if( nPos == 0 )
596  pItem.reset(new XLineEndItem());
597  else if( mxLineEndList.is() && mxLineEndList->Count() > static_cast<long>( nPos - 1 ) )
598  pItem.reset(new XLineEndItem( mpLBEnd->GetSelectedEntry(), mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ));
599  setLineEndStyle(pItem.get());
600  }
601 }
602 
603 IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEdgeStyleHdl, ListBox&, void)
604 {
605  const sal_Int32 nPos(mpLBEdgeStyle->GetSelectedEntryPos());
606 
607  if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBEdgeStyle->IsValueChangedFromSaved())
608  {
609  std::unique_ptr<XLineJointItem> pItem;
610 
611  switch(nPos)
612  {
613  case 0: // rounded
614  {
615  pItem.reset(new XLineJointItem(drawing::LineJoint_ROUND));
616  break;
617  }
618  case 1: // none
619  {
620  pItem.reset(new XLineJointItem(drawing::LineJoint_NONE));
621  break;
622  }
623  case 2: // mitered
624  {
625  pItem.reset(new XLineJointItem(drawing::LineJoint_MITER));
626  break;
627  }
628  case 3: // beveled
629  {
630  pItem.reset(new XLineJointItem(drawing::LineJoint_BEVEL));
631  break;
632  }
633  }
634 
635  setLineJoint(pItem.get());
636  }
637 }
638 
639 IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeCapStyleHdl, ListBox&, void)
640 {
641  const sal_Int32 nPos(mpLBCapStyle->GetSelectedEntryPos());
642 
643  if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBCapStyle->IsValueChangedFromSaved())
644  {
645  std::unique_ptr<XLineCapItem> pItem;
646 
647  switch(nPos)
648  {
649  case 0: // flat
650  {
651  pItem.reset(new XLineCapItem(drawing::LineCap_BUTT));
652  break;
653  }
654  case 1: // round
655  {
656  pItem.reset(new XLineCapItem(drawing::LineCap_ROUND));
657  break;
658  }
659  case 2: // square
660  {
661  pItem.reset(new XLineCapItem(drawing::LineCap_SQUARE));
662  break;
663  }
664  }
665 
666  setLineCap(pItem.get());
667  }
668 }
669 
670 IMPL_LINK(LinePropertyPanelBase, ToolboxWidthSelectHdl,ToolBox*, pToolBox, void)
671 {
672  if (pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SELECTWIDTH)
673  {
674  mxLineWidthPopup->SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit);
675  mxLineWidthPopup->StartPopupMode(pToolBox, FloatWinPopupFlags::GrabFocus);
676  }
677 }
678 
679 IMPL_LINK_NOARG( LinePropertyPanelBase, ChangeTransparentHdl, Edit&, void )
680 {
681  sal_uInt16 nVal = static_cast<sal_uInt16>(mpMFTransparent->GetValue());
682  XLineTransparenceItem aItem( nVal );
683 
684  setLineTransparency(aItem);
685 }
686 
688 {
689  const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH);
690  if (n == 0)
691  mpTBWidth->SetItemImage( nIdWidth, maIMGNone);
692  else
693  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[n-1]);
694 }
695 
697 {
698  if(!mbWidthValuable)
699  {
700  const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH);
701  mpTBWidth->SetItemImage(nIdWidth, maIMGNone);
702  return;
703  }
704 
705  long nVal = LogicToLogic(mnWidthCoreValue * 10, meMapUnit, MapUnit::MapPoint);
706  const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH);
707 
708  if(nVal <= 6)
709  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[0]);
710  else if (nVal <= 9)
711  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[1]);
712  else if (nVal <= 12)
713  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[2]);
714  else if (nVal <= 19)
715  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[3]);
716  else if (nVal <= 26)
717  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[4]);
718  else if (nVal <= 37)
719  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[5]);
720  else if (nVal <= 52)
721  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[6]);
722  else
723  mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[7]);
724 
725 }
726 
728 {
729  mnWidthCoreValue = nWidth;
730  mbWidthValuable = true;
731 }
732 
734 {
736  if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) )
737  {
738  mpLBStart->Enable();
739  mxLineEndList = pSh->GetItem( SID_LINEEND_LIST )->GetLineEndList();
740 
741  if (mxLineEndList.is())
742  {
743  BitmapEx aZeroBitmap;
744 
745  if (mxLineStyleList.is())
746  aZeroBitmap = mxLineStyleList->GetBitmapForUISolidLine();
747 
748  FillLineEndListBox(*mpLBStart, *mpLBEnd, *mxLineEndList, aZeroBitmap);
749  }
750 
753  }
754  else
755  {
756  mpLBStart->Disable();
757  mpLBEnd->Disable();
758  }
759 }
760 
762 {
764  if ( pSh && pSh->GetItem( SID_DASH_LIST ) )
765  {
766  mpLBStyle->Enable();
767  mxLineStyleList = pSh->GetItem( SID_DASH_LIST )->GetDashList();
768 
769  if (mxLineStyleList.is())
770  {
771  FillLineStyleListBox(*mpLBStyle, *mxLineStyleList);
772  }
773 
775  }
776  else
777  {
778  mpLBStyle->Disable();
779  }
780 }
781 
783 {
784  if (!mpStyleItem || !mpDashItem)
785  {
787  mpLBStyle->Disable();
788  return;
789  }
790 
791  const drawing::LineStyle eXLS(mpStyleItem->GetValue());
792  bool bSelected(false);
793 
794  switch(eXLS)
795  {
796  case drawing::LineStyle_NONE:
797  break;
798  case drawing::LineStyle_SOLID:
800  bSelected = true;
801  break;
802  default:
803  if(mxLineStyleList.is())
804  {
805  const XDash& rDash = mpDashItem->GetDashValue();
806  for(long a(0);!bSelected && a < mxLineStyleList->Count(); a++)
807  {
808  const XDashEntry* pEntry = mxLineStyleList->GetDash(a);
809  const XDash& rEntry = pEntry->GetDash();
810  if(rDash == rEntry)
811  {
812  mpLBStyle->SelectEntryPos(a + 2);
813  bSelected = true;
814  }
815  }
816  }
817  break;
818  }
819 
820  if(!bSelected)
822 
824 }
825 
827 {
828  bool bSelected(false);
829 
830  if(bStart)
831  {
832  if (!mpStartItem)
833  {
835  mpLBStart->Disable();
836  return;
837  }
838 
839  if (mxLineEndList.is())
840  {
841  const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue();
842  for(long a(0);!bSelected && a < mxLineEndList->Count(); a++)
843  {
844  const XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
845  const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
846  if(rItemPolygon == rEntryPolygon)
847  {
848  mpLBStart->SelectEntryPos(a + 1);
849  bSelected = true;
850  }
851  }
852  }
853 
854  if(!bSelected)
855  {
857  }
858  }
859  else
860  {
861  if (!mpEndItem)
862  {
864  mpLBEnd->Disable();
865  return;
866  }
867 
868  if (mxLineEndList.is())
869  {
870  const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
871  for(long a(0);!bSelected && a < mxLineEndList->Count(); a++)
872  {
873  const XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
874  const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
875  if(rItemPolygon == rEntryPolygon)
876  {
877  mpLBEnd->SelectEntryPos(a + 1);
878  bSelected = true;
879  }
880  }
881  }
882 
883  if(!bSelected)
884  {
885  mpLBEnd->SelectEntryPos( 0 );
886  }
887  }
888 }
889 
891 {
892  const sal_Int32 nPos(mpLBStyle->GetSelectedEntryPos());
893  bool bLineStyle( nPos != 0 );
894 
895  mpGridLineProps->Enable( bLineStyle );
896  mpBoxArrowProps->Enable( bLineStyle );
897  mpLBStart->Enable( bLineStyle && mbArrowSupported );
898  mpLBEnd->Enable( bLineStyle && mbArrowSupported );
899 }
900 
902 {
903  meMapUnit = eMapUnit;
904 }
905 
907 {
908  mbArrowSupported = false;
910 }
911 
912 }} // end of namespace svx::sidebar
913 
914 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Size GetSizePixel() const
Image GetEntryImage(sal_Int32 nPos) const
BitmapEx const & GetBitmapForUISolidLine() const
Definition: xtabdash.cxx:188
void updateLineWidth(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
std::unique_ptr< XLineStyleItem > mpStyleItem
This class is the base for the Widget Layout-based sidebar panels.
Definition: PanelLayout.hxx:24
sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
ToolBoxItemBits GetItemBits(sal_uInt16 nItemId) const
virtual void DataChanged(const DataChangedEvent &rEvent) override
static SfxObjectShell * Current()
void Clear()
IMPL_LINK(AreaPropertyPanelBase, ClickTrGrHdl_Impl, ToolBox *, pToolBox, void)
void updateLineStyle(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
#define LISTBOX_ENTRY_NOTFOUND
Definition: xdash.hxx:31
virtual void SetModifyHdl(const Link< Edit &, void > &rLink)
void SetDropdownClickHdl(const Link< ToolBox *, void > &rLink)
void Enable(bool bEnable=true, bool bChild=true)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
int nCount
const XDash & GetDash() const
Definition: xtable.hxx:80
void updateLineTransparence(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
std::unique_ptr< XLineStartItem > mpStartItem
const OUString & GetName() const
void updateLineStart(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
bool IsEmpty() const
XLineEndEntry * GetLineEnd(long nIndex) const
Definition: xtablend.cxx:48
uno_Any a
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
int i
void SetUpdateMode(bool bUpdate)
void SetItemBits(sal_uInt16 nItemId, ToolBoxItemBits nBits)
void SetNoSelection()
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
std::unique_ptr< XLineEndItem > mpEndItem
void SetSelectHdl(const Link< ListBox &, void > &rLink)
void SetSelectHdl(const Link< ToolBox *, void > &rLink)
IMPL_LINK_NOARG(GalleryControl, SplitHdl, Splitter *, void)
void Disable(bool bChild=true)
void updateLineDash(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
OUString const & GetStringForUiNoLine() const
Definition: xtabdash.cxx:208
virtual void dispose() override
Definition: PanelLayout.cxx:45
const basegfx::B2DPolyPolygon & GetLineEnd() const
Definition: xtable.hxx:65
StockImage
OUString const & GetStringForUiSolidLine() const
Definition: xtabdash.cxx:198
void updateLineCap(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
void updateLineJoint(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
const char UNO_SELECTWIDTH[]
void SetItemImage(sal_uInt16 nItemId, const Image &rImage)
void updateLineEnd(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
std::unique_ptr< XLineDashItem > mpDashItem
virtual void SetValue(sal_Int64 nNewValue, FieldUnit eInUnit)
long Count() const
Definition: xtable.cxx:124
sal_uInt16 GetItemId(ImplToolItems::size_type nPos) const
MapUnit
void AdaptDropDownLineCountToMaximum()
VclPtr< sfx2::sidebar::SidebarToolBox > mpTBColor
virtual void SetText(const OUString &rStr) override
const Size & GetSizePixel() const
bool Crop(const tools::Rectangle &rRectPixel)
XDashEntry * GetDash(long nIndex) const
Definition: xtabdash.cxx:56
sal_uInt16 nPos