LibreOffice Module cui (master)  1
border.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 <sal/config.h>
21 
22 #include <string_view>
23 
24 #include <sfx2/objsh.hxx>
25 #include <svx/strings.hrc>
26 #include <svx/svxids.hrc>
27 
28 #include <strings.hrc>
29 #include <bitmaps.hlst>
30 
31 #include <editeng/boxitem.hxx>
32 #include <editeng/lineitem.hxx>
33 #include <border.hxx>
34 #include <svx/dlgutil.hxx>
35 #include <dialmgr.hxx>
36 #include <sfx2/htmlmode.hxx>
37 #include <vcl/fieldvalues.hxx>
38 #include <vcl/settings.hxx>
39 #include <vcl/svapp.hxx>
40 #include <svx/flagsdef.hxx>
41 #include <svl/grabbagitem.hxx>
42 #include <svl/intitem.hxx>
43 #include <svl/ilstitem.hxx>
44 #include <svl/int64item.hxx>
45 #include <sal/macros.h>
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #include <comphelper/lok.hxx>
48 #include <svtools/unitconv.hxx>
49 
50 using namespace ::editeng;
51 using ::com::sun::star::uno::Reference;
52 using ::com::sun::star::lang::XServiceInfo;
53 using ::com::sun::star::uno::UNO_QUERY;
54 
55 
56 /*
57  * [Description:]
58  * TabPage for setting the border attributes.
59  * Needs
60  * a SvxShadowItem: shadow
61  * a SvxBoxItem: lines left, right, top, bottom,
62  * a SvxBoxInfo: lines vertical, horizontal, distance, flags
63  *
64  * Lines can have three conditions:
65  * 1. Show ( -> valid values )
66  * 2. Hide ( -> NULL-Pointer )
67  * 3. DontCare ( -> special Valid-Flags in the InfoItem )
68  */
69 
70 // static ----------------------------------------------------------------
71 
72 const sal_uInt16 SvxBorderTabPage::pRanges[] =
73 {
74  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
75  SID_ATTR_ALIGN_MARGIN, SID_ATTR_ALIGN_MARGIN,
76  SID_ATTR_BORDER_CONNECT, SID_ATTR_BORDER_CONNECT,
77  SID_SW_COLLAPSING_BORDERS, SID_SW_COLLAPSING_BORDERS,
78  SID_ATTR_BORDER_DIAG_TLBR, SID_ATTR_BORDER_DIAG_BLTR,
79  0
80 };
81 
83 {
84  auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP));
85  rField.set_digits(1);
86  rField.set_min(rField.normalize(nMin), FieldUnit::TWIP);
87 }
88 
89 // returns in pt
90 static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle)
91 {
92  switch (aStyle)
93  {
94  case SvxBorderLineStyle::NONE:
95  return 0;
96 
97  case SvxBorderLineStyle::SOLID:
98  case SvxBorderLineStyle::DOTTED:
99  case SvxBorderLineStyle::DASHED:
100  case SvxBorderLineStyle::FINE_DASHED:
101  case SvxBorderLineStyle::DASH_DOT:
102  case SvxBorderLineStyle::DASH_DOT_DOT:
103  return 15;
104 
105  // Double lines
106  case SvxBorderLineStyle::DOUBLE: return 22;
107  case SvxBorderLineStyle::DOUBLE_THIN: return 22;
108  case SvxBorderLineStyle::THINTHICK_SMALLGAP: return 20;
109  case SvxBorderLineStyle::THINTHICK_MEDIUMGAP: return 15;
110  case SvxBorderLineStyle::THINTHICK_LARGEGAP: return 15;
111  case SvxBorderLineStyle::THICKTHIN_SMALLGAP: return 20;
112  case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP: return 15;
113  case SvxBorderLineStyle::THICKTHIN_LARGEGAP: return 15;
114 
115  case SvxBorderLineStyle::EMBOSSED: return 15;
116  case SvxBorderLineStyle::ENGRAVED: return 15;
117 
118  case SvxBorderLineStyle::OUTSET: return 10;
119  case SvxBorderLineStyle::INSET: return 10;
120 
121  default:
122  return 15;
123  }
124 }
125 
126 // number of preset images to show
127 const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5;
128 
129 // number of shadow images to show
130 const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5;
131 
133  : mrVsPos(rVsPos)
134  , mrMfSize(rMfSize)
135  , mrLbColor(rLbColor)
136 {
137 }
138 
140 {
141  SvxShadowItem aItem(rItem);
142  if (!mrVsPos.IsNoSelection())
143  {
144  switch (mrVsPos.GetSelectedItemId())
145  {
146  case 1:
147  aItem.SetLocation(SvxShadowLocation::NONE);
148  break;
149  case 2:
150  aItem.SetLocation(SvxShadowLocation::BottomRight);
151  break;
152  case 3:
153  aItem.SetLocation(SvxShadowLocation::TopRight);
154  break;
155  case 4:
156  aItem.SetLocation(SvxShadowLocation::BottomLeft);
157  break;
158  case 5:
159  aItem.SetLocation(SvxShadowLocation::TopLeft);
160  break;
161  default:
162  aItem.SetLocation(SvxShadowLocation::NONE);
163  break;
164  }
165  }
166  // Default value was saved; so don't change the aItem's width if the control
167  // has not changed its value, to avoid round-trip errors (like twip->cm->twip)
168  // E.g., initial 100 twip will become 0.18 cm, which will return as 102 twip
170  aItem.SetWidth(mrMfSize.denormalize(mrMfSize.get_value(FieldUnit::TWIP)));
171  if (!mrLbColor.IsNoSelection())
173  return aItem;
174 }
175 
177 {
178  switch (rItem.GetLocation())
179  {
180  case SvxShadowLocation::NONE:
181  mrVsPos.SelectItem(1);
182  break;
183  case SvxShadowLocation::BottomRight:
184  mrVsPos.SelectItem(2);
185  break;
186  case SvxShadowLocation::TopRight:
187  mrVsPos.SelectItem(3);
188  break;
189  case SvxShadowLocation::BottomLeft:
190  mrVsPos.SelectItem(4);
191  break;
192  case SvxShadowLocation::TopLeft:
193  mrVsPos.SelectItem(5);
194  break;
195  default:
197  break;
198  }
199  mrVsPos.SaveValue();
200  mrMfSize.set_value(mrMfSize.normalize(rItem.GetWidth()), FieldUnit::TWIP);
202  mrLbColor.SelectEntry(rItem.GetColor());
204 }
205 
207 {
208  return mrVsPos.IsValueChangedFromSaved() ||
211 }
212 
214 {
216  mrMfSize.set_text("");
218 }
219 
222  : mrLeftWrp(rMfLeft)
223  , mrRightWrp(rMfRight)
224  , mrTopWrp(rMfTop)
225  , mrBottomWrp(rMfBottom)
226 {
227 }
228 
230 {
231  SvxMarginItem aItem(rItem);
232  if (mrLeftWrp.get_sensitive())
233  aItem.SetLeftMargin(mrLeftWrp.denormalize(mrLeftWrp.get_value(FieldUnit::TWIP)));
235  aItem.SetRightMargin(mrRightWrp.denormalize(mrRightWrp.get_value(FieldUnit::TWIP)));
236  if (mrTopWrp.get_sensitive())
237  aItem.SetTopMargin(mrTopWrp.denormalize(mrTopWrp.get_value(FieldUnit::TWIP)));
240  return aItem;
241 }
242 
244 {
249 }
250 
252 {
253  mrLeftWrp.set_value(mrLeftWrp.normalize(rItem.GetLeftMargin()), FieldUnit::TWIP);
254  mrRightWrp.set_value(mrRightWrp.normalize(rItem.GetRightMargin()), FieldUnit::TWIP);
255  mrTopWrp.set_value(mrTopWrp.normalize(rItem.GetTopMargin()), FieldUnit::TWIP);
256  mrBottomWrp.set_value(mrBottomWrp.normalize(rItem.GetBottomMargin()), FieldUnit::TWIP);
261 }
262 
264 {
265  const OUString sEmpty;
266  mrLeftWrp.set_text(sEmpty);
267  mrRightWrp.set_text(sEmpty);
268  mrTopWrp.set_text(sEmpty);
269  mrBottomWrp.set_text(sEmpty);
270 }
271 
273  : SfxTabPage(pPage, pController, "cui/ui/borderpage.ui", "BorderPage", &rCoreAttrs)
274  , nMinValue(0)
275  , nSWMode(SwBorderModes::NONE)
276  , mnBoxSlot(SID_ATTR_BORDER_OUTER)
277  , mnShadowSlot(SID_ATTR_BORDER_SHADOW)
278  , mbHorEnabled(false)
279  , mbVerEnabled(false)
280  , mbTLBREnabled(false)
281  , mbBLTREnabled(false)
282  , mbUseMarginItem(false)
283  , mbLeftModified(false)
284  , mbRightModified(false)
285  , mbTopModified(false)
286  , mbBottomModified(false)
287  , mbSync(true)
288  , mbRemoveAdjacentCellBorders(false)
289  , bIsCalcDoc(false)
290  , m_xWndPresets(new ValueSet(nullptr))
291  , m_xWndPresetsWin(new weld::CustomWeld(*m_xBuilder, "presets", *m_xWndPresets))
292  , m_xUserDefFT(m_xBuilder->weld_label("userdefft"))
293  , m_xFrameSelWin(new weld::CustomWeld(*m_xBuilder, "framesel", m_aFrameSel))
294  , m_xLbLineStyle(new SvtLineListBox(m_xBuilder->weld_menu_button("linestylelb")))
295  , m_xLbLineColor(new ColorListBox(m_xBuilder->weld_menu_button("linecolorlb"),
296  [this]{ return GetDialogController()->getDialog(); }))
297  , m_xLineWidthMF(m_xBuilder->weld_metric_spin_button("linewidthmf", FieldUnit::POINT))
298  , m_xSpacingFrame(m_xBuilder->weld_container("spacing"))
299  , m_xLeftFT(m_xBuilder->weld_label("leftft"))
300  , m_xLeftMF(m_xBuilder->weld_metric_spin_button("leftmf", FieldUnit::MM))
301  , m_xRightFT(m_xBuilder->weld_label("rightft"))
302  , m_xRightMF(m_xBuilder->weld_metric_spin_button("rightmf", FieldUnit::MM))
303  , m_xTopFT(m_xBuilder->weld_label("topft"))
304  , m_xTopMF(m_xBuilder->weld_metric_spin_button("topmf", FieldUnit::MM))
305  , m_xBottomFT(m_xBuilder->weld_label("bottomft"))
306  , m_xBottomMF(m_xBuilder->weld_metric_spin_button("bottommf", FieldUnit::MM))
307  , m_xSynchronizeCB(m_xBuilder->weld_check_button("sync"))
308  , m_xShadowFrame(m_xBuilder->weld_container("shadow"))
309  , m_xWndShadows(new ValueSet(nullptr))
310  , m_xWndShadowsWin(new weld::CustomWeld(*m_xBuilder, "shadows", *m_xWndShadows))
311  , m_xFtShadowSize(m_xBuilder->weld_label("distanceft"))
312  , m_xEdShadowSize(m_xBuilder->weld_metric_spin_button("distancemf", FieldUnit::MM))
313  , m_xFtShadowColor(m_xBuilder->weld_label("shadowcolorft"))
314  , m_xLbShadowColor(new ColorListBox(m_xBuilder->weld_menu_button("shadowcolorlb"),
315  [this]{ return GetDialogController()->getDialog(); }))
316  , m_xPropertiesFrame(m_xBuilder->weld_container("properties"))
317  , m_xMergeWithNextCB(m_xBuilder->weld_check_button("mergewithnext"))
318  , m_xMergeAdjacentBordersCB(m_xBuilder->weld_check_button("mergeadjacent"))
319  , m_xRemoveAdjacentCellBordersCB(m_xBuilder->weld_check_button("rmadjcellborders"))
320  , m_xRemoveAdjacentCellBordersFT(m_xBuilder->weld_label("rmadjcellbordersft"))
321 {
322  static std::vector<std::u16string_view> aBorderImageIds;
323 
324  if (aBorderImageIds.empty())
325  {
327  {
328  aBorderImageIds.insert(aBorderImageIds.end(), {
329  u"" RID_SVXBMP_CELL_NONE_32,
330  u"" RID_SVXBMP_CELL_ALL_32,
331  u"" RID_SVXBMP_CELL_LR_32,
332  u"" RID_SVXBMP_CELL_TB_32,
333  u"" RID_SVXBMP_CELL_L_32,
334  u"" RID_SVXBMP_CELL_DIAG_32
335  });
336  }
337  else
338  {
339  aBorderImageIds.insert(aBorderImageIds.end(), {
340  u"" RID_SVXBMP_CELL_NONE,
341  u"" RID_SVXBMP_CELL_ALL,
342  u"" RID_SVXBMP_CELL_LR,
343  u"" RID_SVXBMP_CELL_TB,
344  u"" RID_SVXBMP_CELL_L,
345  u"" RID_SVXBMP_CELL_DIAG
346  });
347  }
348  aBorderImageIds.insert(aBorderImageIds.end(), {
349  u"" RID_SVXBMP_HOR_NONE,
350  u"" RID_SVXBMP_HOR_OUTER,
351  u"" RID_SVXBMP_HOR_HOR,
352  u"" RID_SVXBMP_HOR_ALL,
353  u"" RID_SVXBMP_HOR_OUTER2,
354  u"" RID_SVXBMP_VER_NONE,
355  u"" RID_SVXBMP_VER_OUTER,
356  u"" RID_SVXBMP_VER_VER,
357  u"" RID_SVXBMP_VER_ALL,
358  u"" RID_SVXBMP_VER_OUTER2,
359  u"" RID_SVXBMP_TABLE_NONE,
360  u"" RID_SVXBMP_TABLE_OUTER,
361  u"" RID_SVXBMP_TABLE_OUTERH,
362  u"" RID_SVXBMP_TABLE_ALL,
363  u"" RID_SVXBMP_TABLE_OUTER2
364  });
365  }
366 
367  for (auto const & rImageId : aBorderImageIds)
368  m_aBorderImgVec.emplace_back(StockImage::Yes, OUString(rImageId));
369 
370  static std::vector<std::u16string_view> aShadowImageIds;
371  if (aShadowImageIds.empty())
372  {
374  {
375  aShadowImageIds.insert(aShadowImageIds.end(), {
376  u"" RID_SVXBMP_SHADOWNONE_32,
377  u"" RID_SVXBMP_SHADOW_BOT_RIGHT_32,
378  u"" RID_SVXBMP_SHADOW_TOP_RIGHT_32,
379  u"" RID_SVXBMP_SHADOW_BOT_LEFT_32,
380  u"" RID_SVXBMP_SHADOW_TOP_LEFT_32
381  });
382  }
383  else
384  {
385  aShadowImageIds.insert(aShadowImageIds.end(), {
386  u"" RID_SVXBMP_SHADOWNONE,
387  u"" RID_SVXBMP_SHADOW_BOT_RIGHT,
388  u"" RID_SVXBMP_SHADOW_TOP_RIGHT,
389  u"" RID_SVXBMP_SHADOW_BOT_LEFT,
390  u"" RID_SVXBMP_SHADOW_TOP_LEFT
391  });
392  }
393  }
394 
395  for (auto const & rImageId : aShadowImageIds)
396  m_aShadowImgVec.emplace_back(StockImage::Yes, OUString(rImageId));
397 
398  assert(m_aShadowImgVec.size() == SVX_BORDER_SHADOW_COUNT);
399 
400  // this page needs ExchangeSupport
401  SetExchangeSupport();
402 
403  /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
404  -> Remember this state in mbUseMarginItem, because other special handling
405  is needed across various functions... */
406  mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN)) != SfxItemState::UNKNOWN;
407 
408  const SfxPoolItem* pItem = nullptr;
409  if (rCoreAttrs.HasItem(SID_ATTR_BORDER_STYLES, &pItem))
410  {
411  const SfxIntegerListItem* p = static_cast<const SfxIntegerListItem*>(pItem);
412  std::vector<sal_Int32> aUsedStyles = p->GetList();
413  for (int aUsedStyle : aUsedStyles)
414  maUsedBorderStyles.insert(static_cast<SvxBorderLineStyle>(aUsedStyle));
415  }
416 
417  if (rCoreAttrs.HasItem(SID_ATTR_BORDER_DEFAULT_WIDTH, &pItem))
418  {
419  // The caller specifies default line width. Honor it.
420  const SfxInt64Item* p = static_cast<const SfxInt64Item*>(pItem);
421  m_xLineWidthMF->set_value(p->GetValue(), FieldUnit::POINT);
422  }
423 
424  // set metric
425  FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
426 
427  if( mbUseMarginItem )
428  {
429  // copied from SvxAlignmentTabPage
430  switch ( eFUnit )
431  {
432  // #103396# the default value (1pt) can't be accurately represented in
433  // inches or pica with two decimals, so point is used instead.
434  case FieldUnit::PICA:
435  case FieldUnit::INCH:
436  case FieldUnit::FOOT:
437  case FieldUnit::MILE:
438  eFUnit = FieldUnit::POINT;
439  break;
440 
441  case FieldUnit::CM:
442  case FieldUnit::M:
443  case FieldUnit::KM:
444  eFUnit = FieldUnit::MM;
445  break;
446  default: ;//prevent warning
447  }
448  }
449  else
450  {
451  switch ( eFUnit )
452  {
453  case FieldUnit::M:
454  case FieldUnit::KM:
455  eFUnit = FieldUnit::MM;
456  break;
457  default: ; //prevent warning
458  }
459  }
460 
461  SetFieldUnit(*m_xEdShadowSize, eFUnit);
462 
463  sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, false );
464  bool bIsDontCare = true;
465 
466  if ( rCoreAttrs.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
467  {
468  // paragraph or table
469  const SvxBoxInfoItem* pBoxInfo =
470  static_cast<const SvxBoxInfoItem*>(&( rCoreAttrs.Get( nWhich ) ));
471 
472  mbHorEnabled = pBoxInfo->IsHorEnabled();
473  mbVerEnabled = pBoxInfo->IsVerEnabled();
474  mbTLBREnabled = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_BORDER_DIAG_TLBR)) != SfxItemState::UNKNOWN;
475  mbBLTREnabled = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_BORDER_DIAG_BLTR)) != SfxItemState::UNKNOWN;
476 
477  if(pBoxInfo->IsDist())
478  {
479  SetFieldUnit(*m_xLeftMF, eFUnit);
480  SetFieldUnit(*m_xRightMF, eFUnit);
481  SetFieldUnit(*m_xTopMF, eFUnit);
482  SetFieldUnit(*m_xBottomMF, eFUnit);
483  m_xSynchronizeCB->connect_toggled(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
484  m_xLeftMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
485  m_xRightMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
486  m_xTopMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
487  m_xBottomMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
488  }
489  else
490  {
491  m_xSpacingFrame->hide();
492  }
493  bIsDontCare = !pBoxInfo->IsValid( SvxBoxInfoItemValidFlags::DISABLE );
494  }
495  if(!mbUseMarginItem && eFUnit == FieldUnit::MM && MapUnit::MapTwip == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
496  {
497  //#i91548# changing the number of decimal digits changes the minimum values, too
498  lcl_SetDecimalDigitsTo1(*m_xLeftMF);
499  lcl_SetDecimalDigitsTo1(*m_xRightMF);
500  lcl_SetDecimalDigitsTo1(*m_xTopMF);
501  lcl_SetDecimalDigitsTo1(*m_xBottomMF);
502  lcl_SetDecimalDigitsTo1(*m_xEdShadowSize);
503  }
504 
505  FrameSelFlags nFlags = FrameSelFlags::Outer;
506  if( mbHorEnabled )
507  nFlags |= FrameSelFlags::InnerHorizontal;
508  if( mbVerEnabled )
509  nFlags |= FrameSelFlags::InnerVertical;
510  if( mbTLBREnabled )
511  nFlags |= FrameSelFlags::DiagonalTLBR;
512  if( mbBLTREnabled )
513  nFlags |= FrameSelFlags::DiagonalBLTR;
514  if( bIsDontCare )
515  nFlags |= FrameSelFlags::DontCare;
516  m_aFrameSel.Initialize( nFlags );
517 
518  m_aFrameSel.SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
519  m_xLbLineStyle->SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
520  m_xLbLineColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
521  m_xLineWidthMF->connect_value_changed( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
522  m_xWndPresets->SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
523  m_xWndShadows->SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
524 
525  FillValueSets();
526  FillLineListBox_Impl();
527 
528  // connections
529  if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG), &pItem))
530  {
531  const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem);
532  auto it = pGrabBag->GetGrabBag().find("DialogUseCharAttr");
533  if (it != pGrabBag->GetGrabBag().end())
534  {
535  bool bDialogUseCharAttr = false;
536  it->second >>= bDialogUseCharAttr;
537  if (bDialogUseCharAttr)
538  {
539  mnShadowSlot = SID_ATTR_CHAR_SHADOW;
540  mnBoxSlot = SID_ATTR_CHAR_BOX;
541  }
542  }
543  }
544 
545  bool bSupportsShadow = !SfxItemPool::IsSlot(GetWhich(mnShadowSlot));
546  if( bSupportsShadow )
547  m_xShadowControls.reset(new ShadowControlsWrapper(*m_xWndShadows, *m_xEdShadowSize, *m_xLbShadowColor));
548  else
549  HideShadowControls();
550 
551  if (mbUseMarginItem)
552  m_xMarginControls.reset(new MarginControlsWrapper(*m_xLeftMF, *m_xRightMF, *m_xTopMF, *m_xBottomMF));
553 
554  // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
555  m_xMergeWithNextCB->hide();
556  // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
557  m_xMergeAdjacentBordersCB->hide();
558 
560  if (pDocSh)
561  {
562  Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
563  if ( xSI.is() )
564  bIsCalcDoc = xSI->supportsService("com.sun.star.sheet.SpreadsheetDocument");
565  }
566  if( bIsCalcDoc )
567  {
568  m_xRemoveAdjacentCellBordersCB->connect_toggled(LINK(this, SvxBorderTabPage, RemoveAdjacentCellBorderHdl_Impl));
569  m_xRemoveAdjacentCellBordersCB->show();
570  m_xRemoveAdjacentCellBordersCB->set_sensitive(false);
571  }
572  else
573  {
574  m_xRemoveAdjacentCellBordersCB->hide();
575  m_xRemoveAdjacentCellBordersFT->hide();
576  }
577 }
578 
580 {
581  m_xLbShadowColor.reset();
582  m_xWndShadowsWin.reset();
583  m_xWndShadows.reset();
584  m_xLbLineColor.reset();
585  m_xLbLineStyle.reset();
586  m_xFrameSelWin.reset();
587  m_xWndPresetsWin.reset();
588  m_xWndPresets.reset();
589 }
590 
591 std::unique_ptr<SfxTabPage> SvxBorderTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
592  const SfxItemSet* rAttrSet )
593 {
594  return std::make_unique<SvxBorderTabPage>(pPage, pController, *rAttrSet);
595 }
596 
597 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
598 {
599  if( m_aFrameSel.IsBorderEnabled( eBorder ) )
600  {
601  if( bValid )
602  m_aFrameSel.ShowBorder( eBorder, pCoreLine );
603  else
604  m_aFrameSel.SetBorderDontCare( eBorder );
605  }
606 }
607 
609 {
610  if (maUsedBorderStyles.empty())
611  // All border styles are allowed.
612  return true;
613 
614  return maUsedBorderStyles.count(nStyle) > 0;
615 }
616 
618 {
619  SfxItemPool* pPool = rSet->GetPool();
620 
622  {
623  sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_TLBR);
624  if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId)))
625  m_aFrameSel.ShowBorder(svx::FrameBorderType::TLBR, pLineItem->GetLine());
626  else
628  }
629 
631  {
632  sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_BLTR);
633  if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId)))
634  m_aFrameSel.ShowBorder(svx::FrameBorderType::BLTR, pLineItem->GetLine());
635  else
637  }
638 
639  if (m_xShadowControls)
640  {
641  sal_uInt16 nShadowId = pPool->GetWhich(mnShadowSlot);
642  const SfxPoolItem* pItem = rSet->GetItem(nShadowId);
643  if (pItem)
644  m_xShadowControls->SetControlValue(*static_cast<const SvxShadowItem*>(pItem));
645  else
646  m_xShadowControls->SetControlDontKnow();
647  }
648 
649  if (m_xMarginControls)
650  {
651  sal_uInt16 nAlignMarginId = pPool->GetWhich(SID_ATTR_ALIGN_MARGIN);
652  const SfxPoolItem* pItem = rSet->GetItem(nAlignMarginId);
653  if (pItem)
654  m_xMarginControls->SetControlValue(*static_cast<const SvxMarginItem*>(pItem));
655  else
656  m_xMarginControls->SetControlDontKnow();
657  }
658 
659  sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
660  const SfxBoolItem *pMergeAdjacentBorders = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeAdjacentBordersId));
661  if (!pMergeAdjacentBorders)
663  else
664  m_xMergeAdjacentBordersCB->set_active(pMergeAdjacentBorders->GetValue());
665  m_xMergeAdjacentBordersCB->save_state();
666 
667  sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
668  const SfxBoolItem *pMergeWithNext = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeWithNextId));
669  if (!pMergeWithNext)
671  else
672  m_xMergeWithNextCB->set_active(pMergeWithNext->GetValue());
673  m_xMergeWithNextCB->save_state();
674 
675  const SvxBoxItem* pBoxItem;
676  const SvxBoxInfoItem* pBoxInfoItem;
677  sal_uInt16 nWhichBox = GetWhich(mnBoxSlot);
678  MapUnit eCoreUnit;
679 
680  pBoxItem = static_cast<const SvxBoxItem*>(GetItem( *rSet, mnBoxSlot ));
681 
682  pBoxInfoItem = GetItem( *rSet, SID_ATTR_BORDER_INNER, false );
683 
684  eCoreUnit = pPool->GetMetric( nWhichBox );
685 
686  if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
687  {
688  ResetFrameLine_Impl( svx::FrameBorderType::Left, pBoxItem->GetLeft(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::LEFT ) );
689  ResetFrameLine_Impl( svx::FrameBorderType::Right, pBoxItem->GetRight(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::RIGHT ) );
690  ResetFrameLine_Impl( svx::FrameBorderType::Top, pBoxItem->GetTop(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::TOP ) );
691  ResetFrameLine_Impl( svx::FrameBorderType::Bottom, pBoxItem->GetBottom(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::BOTTOM ) );
692  ResetFrameLine_Impl( svx::FrameBorderType::Vertical, pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::VERT ) );
693  ResetFrameLine_Impl( svx::FrameBorderType::Horizontal, pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::HORI ) );
694 
695 
696  // distance inside
697 
698  if( !mbUseMarginItem )
699  {
700  if (m_xLeftMF->get_visible())
701  {
702  SetMetricValue(*m_xLeftMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
703  SetMetricValue(*m_xRightMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
704  SetMetricValue(*m_xTopMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
705  SetMetricValue(*m_xBottomMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
706 
707  nMinValue = m_xLeftMF->get_value(FieldUnit::NONE);
708 
709  if ( pBoxInfoItem->IsDist() )
710  {
711  if( rSet->GetItemState( nWhichBox ) >= SfxItemState::DEFAULT )
712  {
713  bool bIsAnyBorderVisible = m_aFrameSel.IsAnyBorderVisible();
714  if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
715  {
716  m_xLeftMF->set_min(0, FieldUnit::NONE);
717  m_xRightMF->set_min(0, FieldUnit::NONE);
718  m_xTopMF->set_min(0, FieldUnit::NONE);
719  m_xBottomMF->set_min(0, FieldUnit::NONE);
720  }
721  tools::Long nLeftDist = pBoxItem->GetDistance( SvxBoxItemLine::LEFT);
722  SetMetricValue(*m_xLeftMF, nLeftDist, eCoreUnit);
723  tools::Long nRightDist = pBoxItem->GetDistance( SvxBoxItemLine::RIGHT);
724  SetMetricValue(*m_xRightMF, nRightDist, eCoreUnit);
725  tools::Long nTopDist = pBoxItem->GetDistance( SvxBoxItemLine::TOP);
726  SetMetricValue( *m_xTopMF, nTopDist, eCoreUnit );
727  tools::Long nBottomDist = pBoxItem->GetDistance( SvxBoxItemLine::BOTTOM);
728  SetMetricValue( *m_xBottomMF, nBottomDist, eCoreUnit );
729 
730  // if the distance is set with no active border line
731  // or it is null with an active border line
732  // no automatic changes should be made
733  const tools::Long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
734  bool bDiffDist = (nDefDist != nLeftDist ||
735  nDefDist != nRightDist ||
736  nDefDist != nTopDist ||
737  nDefDist != nBottomDist);
738  if ((pBoxItem->GetSmallestDistance() || bIsAnyBorderVisible) && bDiffDist )
739  {
740  mbLeftModified = true;
741  mbRightModified = true;
742  mbTopModified = true;
743  mbBottomModified = true;
744  }
745  }
746  else
747  {
748  // #106224# different margins -> do not fill the edits
749  m_xLeftMF->set_text( OUString() );
750  m_xRightMF->set_text( OUString() );
751  m_xTopMF->set_text( OUString() );
752  m_xBottomMF->set_text( OUString() );
753  }
754  }
755  m_xLeftMF->save_value();
756  m_xRightMF->save_value();
757  m_xTopMF->save_value();
758  m_xBottomMF->save_value();
759  }
760  }
761  }
762  else
763  {
764  // avoid ResetFrameLine-calls:
766  }
767 
770 
771  // depict line (color) in controllers if unambiguous:
772 
773  {
774  // Do all visible lines show the same line widths?
775  tools::Long nWidth;
776  SvxBorderLineStyle nStyle;
777  bool bWidthEq = m_aFrameSel.GetVisibleWidth( nWidth, nStyle );
778  if( bWidthEq )
779  {
780  // Determine the width first as some styles can be missing depending on it
781  sal_Int64 nWidthPt = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
782  sal_Int64( nWidth ), m_xLineWidthMF->get_digits(),
783  MapUnit::MapTwip, FieldUnit::POINT ));
784  m_xLineWidthMF->set_value(nWidthPt, FieldUnit::POINT);
785  m_xLbLineStyle->SetWidth(nWidth);
786 
787  // then set the style
788  m_xLbLineStyle->SelectEntry( nStyle );
789  }
790  else
791  m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
792 
793  // Do all visible lines show the same line color?
794  Color aColor;
795  bool bColorEq = m_aFrameSel.GetVisibleColor( aColor );
796  if( !bColorEq )
797  aColor = COL_BLACK;
798 
799  m_xLbLineColor->SelectEntry(aColor);
801  m_xLbLineStyle->SetColor(nTextColor);
802 
803  // Select all visible lines, if they are all equal.
804  if( bWidthEq && bColorEq )
806 
807  // set the current style and color (caches style in control even if nothing is selected)
808  SelStyleHdl_Impl(*m_xLbLineStyle);
809  SelColHdl_Impl(*m_xLbLineColor);
810  }
811 
812  bool bEnable = m_xWndShadows->GetSelectedItemId() > 1 ;
813  m_xFtShadowSize->set_sensitive(bEnable);
814  m_xEdShadowSize->set_sensitive(bEnable);
815  m_xFtShadowColor->set_sensitive(bEnable);
816  m_xLbShadowColor->set_sensitive(bEnable);
817 
818  m_xWndPresets->SetNoSelection();
819 
820  // - no line - should not be selected
821 
822  if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
823  {
824  m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
825  SelStyleHdl_Impl(*m_xLbLineStyle);
826  }
827 
828  const SfxPoolItem* pItem;
829  SfxObjectShell* pShell;
830  if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem) ||
831  ( nullptr != (pShell = SfxObjectShell::Current()) &&
832  nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
833  {
834  sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
835  if(nHtmlMode & HTMLMODE_ON)
836  {
837  // there are no shadows in Html-mode and only complete borders
838  m_xShadowFrame->set_sensitive(false);
839 
840  if( !(nSWMode & SwBorderModes::TABLE) )
841  {
842  m_xUserDefFT->set_sensitive(false);
843  m_xFrameSelWin->set_sensitive(false);
844  m_xWndPresets->RemoveItem(3);
845  m_xWndPresets->RemoveItem(4);
846  m_xWndPresets->RemoveItem(5);
847  }
848  }
849  }
850 
851  LinesChanged_Impl( nullptr );
852  if (m_xLeftMF->get_value(FieldUnit::NONE) == m_xRightMF->get_value(FieldUnit::NONE) &&
853  m_xTopMF->get_value(FieldUnit::NONE) == m_xBottomMF->get_value(FieldUnit::NONE) &&
854  m_xTopMF->get_value(FieldUnit::NONE) == m_xLeftMF->get_value(FieldUnit::NONE))
855  {
856  mbSync = true;
857  }
858  else
859  mbSync = false;
860  m_xSynchronizeCB->set_active(mbSync);
861 
863  m_xRemoveAdjacentCellBordersCB->set_active(false);
864  m_xRemoveAdjacentCellBordersCB->set_sensitive(false);
865 }
866 
868 {
869  m_xLeftMF->save_value();
870  m_xRightMF->save_value();
871  m_xTopMF->save_value();
872  m_xBottomMF->save_value();
873  m_xMergeWithNextCB->save_state();
874  m_xMergeAdjacentBordersCB->save_state();
875 }
876 
878 {
879  if ( _pSet )
880  FillItemSet( _pSet );
881 
882  return DeactivateRC::LeavePage;
883 }
884 
886 {
887  bool bAttrsChanged = false;
888 
889  SfxItemPool* pPool = rCoreAttrs->GetPool();
890 
893  {
894  if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR))
895  {
896  SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
898  rCoreAttrs->Put(aLineItem);
899  bAttrsChanged = true;
900  }
901  }
902 
905  {
906  if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR))
907  {
908  SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
910  rCoreAttrs->Put(aLineItem);
911  bAttrsChanged = true;
912  }
913  }
914 
915  if (m_xShadowControls && m_xShadowControls->get_value_changed_from_saved())
916  {
917  if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, mnShadowSlot))
918  {
919  const SvxShadowItem& rOldShadowItem = *static_cast<const SvxShadowItem*>(pOldItem);
920  rCoreAttrs->Put(m_xShadowControls->GetControlValue(rOldShadowItem));
921  bAttrsChanged = true;
922  }
923  }
924 
925  if (m_xMarginControls && m_xMarginControls->get_value_changed_from_saved())
926  {
927  if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_ALIGN_MARGIN))
928  {
929  const SvxMarginItem& rOldMarginItem = *static_cast<const SvxMarginItem*>(pOldItem);
930  rCoreAttrs->Put(m_xMarginControls->GetControlValue(rOldMarginItem));
931  bAttrsChanged = true;
932  }
933  }
934 
935  if (m_xMergeAdjacentBordersCB->get_state_changed_from_saved())
936  {
937  auto nState = m_xMergeAdjacentBordersCB->get_state();
938  if (nState == TRISTATE_INDET)
939  {
940  sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
941  rCoreAttrs->ClearItem(nMergeAdjacentBordersId);
942  }
943  else
944  {
945  if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_SW_COLLAPSING_BORDERS))
946  {
947  std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
948  xNewItem->SetValue(static_cast<bool>(nState));
949  rCoreAttrs->Put(std::move(xNewItem));
950  }
951  }
952  bAttrsChanged = true;
953  }
954 
955  if (m_xMergeWithNextCB->get_state_changed_from_saved())
956  {
957  auto nState = m_xMergeWithNextCB->get_state();
958  if (nState == TRISTATE_INDET)
959  {
960  sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
961  rCoreAttrs->ClearItem(nMergeWithNextId);
962  }
963  else
964  {
965  if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_CONNECT))
966  {
967  std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
968  xNewItem->SetValue(static_cast<bool>(nState));
969  rCoreAttrs->Put(std::move(xNewItem));
970  }
971  }
972  bAttrsChanged = true;
973  }
974 
975  bool bPut = true;
976  sal_uInt16 nBoxWhich = GetWhich( mnBoxSlot );
977  sal_uInt16 nBoxInfoWhich = pPool->GetWhich( SID_ATTR_BORDER_INNER, false );
978  const SfxItemSet& rOldSet = GetItemSet();
979  SvxBoxItem aBoxItem ( nBoxWhich );
980  SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich );
981  const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( *rCoreAttrs, mnBoxSlot ));
982 
983  MapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
984 
985 
986  // outer border:
987 
988  std::pair<svx::FrameBorderType,SvxBoxItemLine> eTypes1[] = {
989  { svx::FrameBorderType::Top,SvxBoxItemLine::TOP },
990  { svx::FrameBorderType::Bottom,SvxBoxItemLine::BOTTOM },
991  { svx::FrameBorderType::Left,SvxBoxItemLine::LEFT },
992  { svx::FrameBorderType::Right,SvxBoxItemLine::RIGHT },
993  };
994 
995  for (std::pair<svx::FrameBorderType,SvxBoxItemLine> const & i : eTypes1)
996  aBoxItem.SetLine( m_aFrameSel.GetFrameBorderStyle( i.first ), i.second );
997 
998 
1000  // border hor/ver and TableFlag
1001 
1002  std::pair<svx::FrameBorderType,SvxBoxInfoItemLine> eTypes2[] = {
1003  { svx::FrameBorderType::Horizontal,SvxBoxInfoItemLine::HORI },
1004  { svx::FrameBorderType::Vertical,SvxBoxInfoItemLine::VERT }
1005  };
1006  for (std::pair<svx::FrameBorderType,SvxBoxInfoItemLine> const & j : eTypes2)
1007  aBoxInfoItem.SetLine( m_aFrameSel.GetFrameBorderStyle( j.first ), j.second );
1008 
1009  aBoxInfoItem.EnableHor( mbHorEnabled );
1010  aBoxInfoItem.EnableVer( mbVerEnabled );
1011 
1012 
1013  // inner distance
1014 
1015  if (m_xLeftMF->get_visible())
1016  {
1017  // #i40405# enable distance controls for next dialog call
1018  aBoxInfoItem.SetDist( true );
1019 
1020  if( !mbUseMarginItem )
1021  {
1022  // #106224# all edits empty: do nothing
1023  if( !m_xLeftMF->get_text().isEmpty() || !m_xRightMF->get_text().isEmpty() ||
1024  !m_xTopMF->get_text().isEmpty() || !m_xBottomMF->get_text().isEmpty() )
1025  {
1026  const SvxBoxInfoItem* pOldBoxInfoItem = GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_INNER );
1027  if (
1028  !pOldBoxItem ||
1029  m_xLeftMF->get_value_changed_from_saved() ||
1030  m_xRightMF->get_value_changed_from_saved() ||
1031  m_xTopMF->get_value_changed_from_saved() ||
1032  m_xBottomMF->get_value_changed_from_saved() ||
1033  nMinValue == m_xLeftMF->get_value(FieldUnit::NONE) ||
1034  nMinValue == m_xRightMF->get_value(FieldUnit::NONE) ||
1035  nMinValue == m_xTopMF->get_value(FieldUnit::NONE) ||
1036  nMinValue == m_xBottomMF->get_value(FieldUnit::NONE) ||
1037  (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::DISTANCE))
1038  )
1039  {
1040  aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xLeftMF, eCoreUnit )), SvxBoxItemLine::LEFT );
1041  aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xRightMF, eCoreUnit )), SvxBoxItemLine::RIGHT );
1042  aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xTopMF, eCoreUnit )), SvxBoxItemLine::TOP );
1043  aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xBottomMF, eCoreUnit )), SvxBoxItemLine::BOTTOM);
1044  }
1045  else
1046  {
1047  aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::LEFT ), SvxBoxItemLine::LEFT);
1048  aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT);
1049  aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::TOP ), SvxBoxItemLine::TOP);
1050  aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM);
1051  }
1052  aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
1053  }
1054  }
1055  }
1056 
1057 
1058  // note Don't Care Status in the Info-Item:
1059 
1060  aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::TOP, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Top ) != svx::FrameBorderState::DontCare );
1061  aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Bottom ) != svx::FrameBorderState::DontCare );
1062  aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::LEFT, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Left ) != svx::FrameBorderState::DontCare );
1063  aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::RIGHT, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Right ) != svx::FrameBorderState::DontCare );
1065  aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::VERT, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Vertical ) != svx::FrameBorderState::DontCare );
1066 
1067 
1068  // Put or Clear of the border?
1069 
1070  bPut = true;
1071 
1072  if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxWhich, false ))
1073  {
1074  bPut = aBoxItem != static_cast<const SvxBoxItem&>(rOldSet.Get(nBoxWhich));
1075  }
1076  if( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, false ) )
1077  {
1078  const SvxBoxInfoItem& rOldBoxInfo = static_cast<const SvxBoxInfoItem&>(
1079  rOldSet.Get(nBoxInfoWhich));
1080 
1081  aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
1082  aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
1083  bPut |= (aBoxInfoItem != rOldBoxInfo );
1084  }
1085 
1086  if ( bPut )
1087  {
1088  if ( !pOldBoxItem || *pOldBoxItem != aBoxItem )
1089  {
1090  rCoreAttrs->Put( aBoxItem );
1091  bAttrsChanged = true;
1092  }
1093  const SfxPoolItem* pOld = GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_INNER, false );
1094 
1095  if ( !pOld || *static_cast<const SvxBoxInfoItem*>(pOld) != aBoxInfoItem )
1096  {
1097  rCoreAttrs->Put( aBoxInfoItem );
1098  bAttrsChanged = true;
1099  }
1100  }
1101  else
1102  {
1103  rCoreAttrs->ClearItem( nBoxWhich );
1104  rCoreAttrs->ClearItem( nBoxInfoWhich );
1105  }
1106 
1107  return bAttrsChanged;
1108 }
1109 
1111 {
1112  m_xShadowFrame->hide();
1113 }
1114 
1115 #define IID_PRE_CELL_NONE 1
1116 #define IID_PRE_CELL_ALL 2
1117 #define IID_PRE_CELL_LR 3
1118 #define IID_PRE_CELL_TB 4
1119 #define IID_PRE_CELL_L 5
1120 #define IID_PRE_CELL_DIAG 6
1121 #define IID_PRE_HOR_NONE 7
1122 #define IID_PRE_HOR_OUTER 8
1123 #define IID_PRE_HOR_HOR 9
1124 #define IID_PRE_HOR_ALL 10
1125 #define IID_PRE_HOR_OUTER2 11
1126 #define IID_PRE_VER_NONE 12
1127 #define IID_PRE_VER_OUTER 13
1128 #define IID_PRE_VER_VER 14
1129 #define IID_PRE_VER_ALL 15
1130 #define IID_PRE_VER_OUTER2 16
1131 #define IID_PRE_TABLE_NONE 17
1132 #define IID_PRE_TABLE_OUTER 18
1133 #define IID_PRE_TABLE_OUTERH 19
1134 #define IID_PRE_TABLE_ALL 20
1135 #define IID_PRE_TABLE_OUTER2 21
1136 
1138 {
1142 
1143  static const svx::FrameBorderState ppeStates[][ svx::FRAMEBORDERTYPE_COUNT ] =
1144  { /* Left Right Top Bot Hor Ver TLBR BLTR */
1145 /* ---------------------+--------------------------------------------------- */
1146 /* IID_PRE_CELL_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1147 /* IID_PRE_CELL_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1148 /* IID_PRE_CELL_LR */ { SHOW, SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1149 /* IID_PRE_CELL_TB */ { HIDE, HIDE, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1150 /* IID_PRE_CELL_L */ { SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1151 /* IID_PRE_CELL_DIAG */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, SHOW, SHOW },
1152 /* IID_PRE_HOR_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1153 /* IID_PRE_HOR_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1154 /* IID_PRE_HOR_HOR */ { HIDE, HIDE, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
1155 /* IID_PRE_HOR_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
1156 /* IID_PRE_HOR_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, HIDE, HIDE, HIDE },
1157 /* IID_PRE_VER_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1158 /* IID_PRE_VER_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1159 /* IID_PRE_VER_VER */ { SHOW, SHOW, HIDE, HIDE, HIDE, SHOW, HIDE, HIDE },
1160 /* IID_PRE_VER_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, SHOW, HIDE, HIDE },
1161 /* IID_PRE_VER_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, HIDE, DONT, HIDE, HIDE },
1162 /* IID_PRE_TABLE_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1163 /* IID_PRE_TABLE_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1164 /* IID_PRE_TABLE_OUTERH */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
1165 /* IID_PRE_TABLE_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE },
1166 /* IID_PRE_TABLE_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, DONT, HIDE, HIDE }
1167  };
1168 
1169  // first hide and deselect all frame borders
1170  m_aFrameSel.HideAllBorders();
1171  m_aFrameSel.DeselectAllBorders();
1172 
1173  // Using image ID to find correct line in table above.
1174  sal_uInt16 nLine = GetPresetImageId( m_xWndPresets->GetSelectedItemId() ) - 1;
1175 
1176  // Apply all styles from the table
1177  for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
1178  {
1180  switch( ppeStates[ nLine ][ nBorder ] )
1181  {
1182  case SHOW: m_aFrameSel.SelectBorder( eBorder ); break;
1183  case HIDE: /* nothing to do */ break;
1184  case DONT: m_aFrameSel.SetBorderDontCare( eBorder ); break;
1185  }
1186  }
1187 
1188  // Show all lines that have been selected above
1189  if( m_aFrameSel.IsAnyBorderSelected() )
1190  {
1191  // any visible style, but "no-line" in line list box? -> use hair-line
1192  if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
1193  m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
1194 
1195  // set current style to all previously selected lines
1196  SelStyleHdl_Impl(*m_xLbLineStyle);
1197  SelColHdl_Impl(*m_xLbLineColor);
1198  }
1199 
1200  // Presets ValueSet does not show a selection (used as push buttons).
1201  m_xWndPresets->SetNoSelection();
1202 
1203  LinesChanged_Impl( nullptr );
1204  UpdateRemoveAdjCellBorderCB( nLine + 1 );
1205 }
1206 
1208 {
1209  bool bEnable = m_xWndShadows->GetSelectedItemId() > 1;
1210  m_xFtShadowSize->set_sensitive(bEnable);
1211  m_xEdShadowSize->set_sensitive(bEnable);
1212  m_xFtShadowColor->set_sensitive(bEnable);
1213  m_xLbShadowColor->set_sensitive(bEnable);
1214 }
1215 
1216 IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void)
1217 {
1218  Color aColor = rColorBox.GetSelectEntryColor();
1219  m_aFrameSel.SetColorToSelection(aColor);
1220 }
1221 
1223 {
1224  sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
1225  nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1226  nVal,
1227  m_xLineWidthMF->get_digits(),
1228  FieldUnit::POINT, MapUnit::MapTwip ));
1229  m_xLbLineStyle->SetWidth( nVal );
1230 
1231  m_aFrameSel.SetStyleToSelection( nVal,
1232  m_xLbLineStyle->GetSelectEntryStyle() );
1233 }
1234 
1236 {
1237  sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE);
1238  nOldWidth = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1239  nOldWidth,
1240  m_xLineWidthMF->get_digits(),
1241  FieldUnit::POINT,
1242  MapUnit::MapTwip));
1243 
1244  const sal_Int64 nOldMinWidth = lcl_GetMinLineWidth(m_aFrameSel.getCurrentStyleLineStyle());
1245  const sal_Int64 nNewMinWidth = lcl_GetMinLineWidth(m_xLbLineStyle->GetSelectEntryStyle());
1246 
1247  // auto change line-width if it doesn't correspond to minimal value
1248  // let's change only in case when user has not changed the line-width into some custom value
1249  const sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth)? nNewMinWidth : nOldWidth;
1250 
1251  // set value inside edit box
1252  if (nOldWidth != nNewWidth)
1253  {
1254  const sal_Int64 nNewWidthPt = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1255  nNewWidth,
1256  m_xLineWidthMF->get_digits(),
1257  MapUnit::MapTwip,
1258  FieldUnit::POINT));
1259  m_xLineWidthMF->set_value(nNewWidthPt, FieldUnit::POINT);
1260  }
1261 
1262  // set value inside style box
1263  m_aFrameSel.SetStyleToSelection( nNewWidth,
1264  m_xLbLineStyle->GetSelectEntryStyle() );
1265 }
1266 
1267 
1268 // ValueSet handling
1269 sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
1270 {
1271  // table with all sets of predefined border styles
1272  static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] =
1273  {
1274  // simple cell without diagonal frame borders
1276  // simple cell with diagonal frame borders
1278  // with horizontal inner frame border
1280  // with vertical inner frame border
1282  // with horizontal and vertical inner frame borders
1284  };
1285 
1286  // find correct set of presets
1287  int nLine = 0;
1288  if( !mbHorEnabled && !mbVerEnabled )
1289  nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
1290  else if( mbHorEnabled && !mbVerEnabled )
1291  nLine = 2;
1292  else if( !mbHorEnabled && mbVerEnabled )
1293  nLine = 3;
1294  else
1295  nLine = 4;
1296 
1297  DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT),
1298  "SvxBorderTabPage::GetPresetImageId - wrong index" );
1299  return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
1300 }
1301 
1302 const char* SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
1303 {
1304  // string resource IDs for each image (in order of the IID_PRE_* image IDs)
1305  static const char* pnStrIds[] =
1306  {
1307  RID_SVXSTR_TABLE_PRESET_NONE,
1308  RID_SVXSTR_PARA_PRESET_ALL,
1309  RID_SVXSTR_PARA_PRESET_LEFTRIGHT,
1310  RID_SVXSTR_PARA_PRESET_TOPBOTTOM,
1311  RID_SVXSTR_PARA_PRESET_ONLYLEFT,
1312  RID_SVXSTR_PARA_PRESET_DIAGONAL,
1313 
1314  RID_SVXSTR_TABLE_PRESET_NONE,
1315  RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1316  RID_SVXSTR_HOR_PRESET_ONLYHOR,
1317  RID_SVXSTR_TABLE_PRESET_OUTERALL,
1318  RID_SVXSTR_TABLE_PRESET_OUTERINNER,
1319 
1320  RID_SVXSTR_TABLE_PRESET_NONE,
1321  RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1322  RID_SVXSTR_VER_PRESET_ONLYVER,
1323  RID_SVXSTR_TABLE_PRESET_OUTERALL,
1324  RID_SVXSTR_TABLE_PRESET_OUTERINNER,
1325 
1326  RID_SVXSTR_TABLE_PRESET_NONE,
1327  RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1328  RID_SVXSTR_TABLE_PRESET_OUTERHORI,
1329  RID_SVXSTR_TABLE_PRESET_OUTERALL,
1330  RID_SVXSTR_TABLE_PRESET_OUTERINNER
1331  };
1332  return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
1333 }
1334 
1336 {
1337  // basic initialization of the ValueSet
1338  m_xWndPresets->SetStyle( m_xWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1339  m_xWndPresets->SetColCount( SVX_BORDER_PRESET_COUNT );
1340 
1341  // insert images and help texts
1342  for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx )
1343  {
1344  m_xWndPresets->InsertItem( nVSIdx );
1345  m_xWndPresets->SetItemImage(nVSIdx, m_aBorderImgVec[GetPresetImageId(nVSIdx) - 1]);
1346  m_xWndPresets->SetItemText( nVSIdx, CuiResId( GetPresetStringId( nVSIdx ) ) );
1347  }
1348 
1349  // show the control
1350  m_xWndPresets->SetNoSelection();
1351  m_xWndPresets->SetOptimalSize();
1352  m_xWndPresets->Show();
1353 }
1354 
1356 {
1357  // basic initialization of the ValueSet
1358  m_xWndShadows->SetStyle( m_xWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1359  m_xWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT );
1360 
1361  // string resource IDs for each image
1362  static const char* pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
1363  { RID_SVXSTR_SHADOW_STYLE_NONE, RID_SVXSTR_SHADOW_STYLE_BOTTOMRIGHT, RID_SVXSTR_SHADOW_STYLE_TOPRIGHT, RID_SVXSTR_SHADOW_STYLE_BOTTOMLEFT, RID_SVXSTR_SHADOW_STYLE_TOPLEFT };
1364 
1365  // insert images and help texts
1366  for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx )
1367  {
1368  m_xWndShadows->InsertItem( nVSIdx );
1369  m_xWndShadows->SetItemImage(nVSIdx, m_aShadowImgVec[nVSIdx-1]);
1370  m_xWndShadows->SetItemText( nVSIdx, CuiResId( pnStrIds[ nVSIdx - 1 ] ) );
1371  }
1372 
1373  // show the control
1374  m_xWndShadows->SelectItem( 1 );
1375  m_xWndShadows->SetOptimalSize();
1376  m_xWndShadows->Show();
1377 }
1378 
1379 
1381 {
1382  FillPresetVS();
1383  FillShadowVS();
1384 }
1385 
1386 
1387 static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1388 {
1389  return SvxBorderLine::threeDMediumColor( aMain );
1390 }
1391 
1393 {
1394  using namespace ::com::sun::star::table::BorderLineStyle;
1395 
1396  static struct {
1397  SvxBorderLineStyle mnStyle;
1398  SvtLineListBox::ColorFunc mpColor1Fn;
1399  SvtLineListBox::ColorFunc mpColor2Fn;
1400  SvtLineListBox::ColorDistFunc mpColorDistFn;
1401  } const aLines[] = {
1402  // Simple lines
1403  { SvxBorderLineStyle::SOLID, &sameColor, &sameColor, &sameDistColor },
1404  { SvxBorderLineStyle::DOTTED, &sameColor, &sameColor, &sameDistColor },
1405  { SvxBorderLineStyle::DASHED, &sameColor, &sameColor, &sameDistColor },
1406  { SvxBorderLineStyle::FINE_DASHED, &sameColor, &sameColor, &sameDistColor },
1407  { SvxBorderLineStyle::DASH_DOT, &sameColor, &sameColor, &sameDistColor },
1408  { SvxBorderLineStyle::DASH_DOT_DOT, &sameColor, &sameColor, &sameDistColor },
1409 
1410  // Double lines
1411  { SvxBorderLineStyle::DOUBLE, &sameColor, &sameColor, &sameDistColor },
1412  { SvxBorderLineStyle::DOUBLE_THIN, &sameColor, &sameColor, &sameDistColor },
1413  { SvxBorderLineStyle::THINTHICK_SMALLGAP, &sameColor, &sameColor, &sameDistColor },
1414  { SvxBorderLineStyle::THINTHICK_MEDIUMGAP, &sameColor, &sameColor, &sameDistColor },
1415  { SvxBorderLineStyle::THINTHICK_LARGEGAP, &sameColor, &sameColor, &sameDistColor },
1416  { SvxBorderLineStyle::THICKTHIN_SMALLGAP, &sameColor, &sameColor, &sameDistColor },
1417  { SvxBorderLineStyle::THICKTHIN_MEDIUMGAP, &sameColor, &sameColor, &sameDistColor },
1418  { SvxBorderLineStyle::THICKTHIN_LARGEGAP, &sameColor, &sameColor, &sameDistColor },
1419 
1420  { SvxBorderLineStyle::EMBOSSED, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor },
1421  { SvxBorderLineStyle::ENGRAVED, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor },
1422 
1423  { SvxBorderLineStyle::OUTSET, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor },
1424  { SvxBorderLineStyle::INSET, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor }
1425  };
1426 
1427  m_xLbLineStyle->SetSourceUnit( FieldUnit::TWIP );
1428 
1429  for (size_t i = 0; i < SAL_N_ELEMENTS(aLines); ++i)
1430  {
1431  if (!IsBorderLineStyleAllowed(aLines[i].mnStyle))
1432  continue;
1433 
1434  m_xLbLineStyle->InsertEntry(
1435  SvxBorderLine::getWidthImpl(aLines[i].mnStyle),
1436  aLines[i].mnStyle,
1437  lcl_GetMinLineWidth(aLines[i].mnStyle),
1438  aLines[i].mpColor1Fn,
1439  aLines[i].mpColor2Fn,
1440  aLines[i].mpColorDistFn);
1441  }
1442 
1443  sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
1444  nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue(nVal, m_xLineWidthMF->get_digits(),
1445  m_xLineWidthMF->get_unit(), MapUnit::MapTwip));
1446  m_xLbLineStyle->SetWidth( nVal );
1447 }
1448 
1449 
1451 {
1452  if (!mbUseMarginItem && m_xLeftMF->get_visible())
1453  {
1454  bool bLineSet = m_aFrameSel.IsAnyBorderVisible();
1455  bool bSpaceModified = mbLeftModified ||
1456  mbRightModified ||
1457  mbTopModified ||
1458  mbBottomModified;
1459 
1460  if(bLineSet)
1461  {
1462  if(!bSpaceModified)
1463  {
1464  m_xLeftMF->set_value(nMinValue, FieldUnit::NONE);
1465  m_xRightMF->set_value(nMinValue, FieldUnit::NONE);
1466  m_xTopMF->set_value(nMinValue, FieldUnit::NONE);
1467  m_xBottomMF->set_value(nMinValue, FieldUnit::NONE);
1468  }
1469  }
1470  else
1471  {
1472  m_xLeftMF->set_min(0, FieldUnit::NONE);
1473  m_xRightMF->set_min(0, FieldUnit::NONE);
1474  m_xTopMF->set_min(0, FieldUnit::NONE);
1475  m_xBottomMF->set_min(0, FieldUnit::NONE);
1476  }
1477  // for tables everything is allowed
1478  SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::TOP|SvxBoxInfoItemValidFlags::BOTTOM|SvxBoxInfoItemValidFlags::LEFT|SvxBoxInfoItemValidFlags::RIGHT;
1479 
1480  m_xLeftFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::LEFT) );
1481  m_xRightFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::RIGHT) );
1482  m_xTopFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::TOP) );
1483  m_xBottomFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::BOTTOM) );
1484  m_xLeftMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::LEFT) );
1485  m_xRightMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::RIGHT) );
1486  m_xTopMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::TOP) );
1487  m_xBottomMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::BOTTOM) );
1488  m_xSynchronizeCB->set_sensitive(m_xRightMF->get_sensitive() || m_xTopMF->get_sensitive() ||
1489  m_xBottomMF->get_sensitive() || m_xLeftMF->get_sensitive());
1490  }
1491  UpdateRemoveAdjCellBorderCB( SAL_MAX_UINT16 );
1492 }
1493 
1494 
1495 IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, weld::MetricSpinButton&, rField, void)
1496 {
1497  if (&rField == m_xLeftMF.get())
1498  mbLeftModified = true;
1499  else if (&rField == m_xRightMF.get())
1500  mbRightModified = true;
1501  else if (&rField == m_xTopMF.get())
1502  mbTopModified = true;
1503  else if (&rField == m_xBottomMF.get())
1504  mbBottomModified = true;
1505 
1506  if (mbSync)
1507  {
1508  const auto nVal = rField.get_value(FieldUnit::NONE);
1509  if (&rField != m_xLeftMF.get())
1510  m_xLeftMF->set_value(nVal, FieldUnit::NONE);
1511  if (&rField != m_xRightMF.get())
1512  m_xRightMF->set_value(nVal, FieldUnit::NONE);
1513  if (&rField != m_xTopMF.get())
1514  m_xTopMF->set_value(nVal, FieldUnit::NONE);
1515  if (&rField != m_xBottomMF.get())
1516  m_xBottomMF->set_value(nVal, FieldUnit::NONE);
1517  }
1518 }
1519 
1520 IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, weld::Toggleable&, rBox, void)
1521 {
1522  mbSync = rBox.get_active();
1523 }
1524 
1525 IMPL_LINK( SvxBorderTabPage, RemoveAdjacentCellBorderHdl_Impl, weld::Toggleable&, rBox, void)
1526 {
1527  mbRemoveAdjacentCellBorders = rBox.get_active();
1528 }
1529 
1531 {
1532  if( !bIsCalcDoc )
1533  return;
1534  const SfxItemSet& rOldSet = GetItemSet();
1535  const SvxBoxInfoItem* pOldBoxInfoItem = GetOldItem( rOldSet, SID_ATTR_BORDER_INNER );
1536  const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( rOldSet, mnBoxSlot ));
1537  if( !pOldBoxInfoItem || !pOldBoxItem )
1538  return;
1539  std::pair<svx::FrameBorderType, SvxBoxInfoItemValidFlags> eTypes1[] = {
1540  { svx::FrameBorderType::Top,SvxBoxInfoItemValidFlags::TOP },
1541  { svx::FrameBorderType::Bottom,SvxBoxInfoItemValidFlags::BOTTOM },
1542  { svx::FrameBorderType::Left,SvxBoxInfoItemValidFlags::LEFT },
1543  { svx::FrameBorderType::Right,SvxBoxInfoItemValidFlags::RIGHT },
1544  };
1545  SvxBoxItemLine const eTypes2[] = {
1546  SvxBoxItemLine::TOP,
1547  SvxBoxItemLine::BOTTOM,
1548  SvxBoxItemLine::LEFT,
1549  SvxBoxItemLine::RIGHT,
1550  };
1551 
1552  // Check if current selection involves deletion of at least one border
1553  bool bBorderDeletionReq = false;
1554  for ( size_t i=0; i < SAL_N_ELEMENTS( eTypes1 ); ++i )
1555  {
1556  if( pOldBoxItem->GetLine( eTypes2[i] ) || !( pOldBoxInfoItem->IsValid( eTypes1[i].second ) ) )
1557  {
1558  if( m_aFrameSel.GetFrameBorderState( eTypes1[i].first ) == svx::FrameBorderState::Hide )
1559  {
1560  bBorderDeletionReq = true;
1561  break;
1562  }
1563  }
1564  }
1565 
1566  if( !bBorderDeletionReq && ( nPreset == IID_PRE_CELL_NONE || nPreset == IID_PRE_TABLE_NONE ) )
1567  bBorderDeletionReq = true;
1568 
1569  m_xRemoveAdjacentCellBordersCB->set_sensitive(bBorderDeletionReq);
1570 
1571  if( !bBorderDeletionReq )
1572  {
1574  m_xRemoveAdjacentCellBordersCB->set_active(false);
1575  }
1576 }
1577 
1579 {
1580  const SfxUInt16Item* pSWModeItem = aSet.GetItem<SfxUInt16Item>(SID_SWMODE_TYPE, false);
1581  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
1582  if (pSWModeItem)
1583  {
1584  nSWMode = static_cast<SwBorderModes>(pSWModeItem->GetValue());
1585  // #i43593#
1586  // show checkbox <m_xMergeWithNextCB> for format.paragraph
1587  if ( nSWMode == SwBorderModes::PARA )
1588  {
1589  m_xMergeWithNextCB->show();
1590  m_xPropertiesFrame->show();
1591  }
1592  // show checkbox <m_xMergeAdjacentBordersCB> for format.paragraph
1593  else if ( nSWMode == SwBorderModes::TABLE )
1594  {
1595  m_xMergeAdjacentBordersCB->show();
1596  m_xPropertiesFrame->show();
1597  }
1598  }
1599  if (pFlagItem)
1600  if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1602 }
1603 
1605 {
1606  nSWMode = SwBorderModes::TABLE;
1607 }
1608 
1609 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define IID_PRE_HOR_NONE
Definition: border.cxx:1121
sal_uInt16 mnShadowSlot
Definition: border.hxx:104
bool GetValue() const
virtual ~SvxBorderTabPage() override
Definition: border.cxx:579
#define IID_PRE_VER_VER
Definition: border.cxx:1128
bool mbHorEnabled
true = Inner horizontal border enabled.
Definition: border.hxx:106
std::unique_ptr< ValueSet > m_xWndShadows
Definition: border.hxx:144
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
std::unique_ptr< ShadowControlsWrapper > m_xShadowControls
Definition: border.hxx:157
FrameBorderType GetFrameBorderTypeFromIndex(size_t nIndex)
bool mbUseMarginItem
Definition: border.hxx:110
FieldUnit
static Color lcl_mediumColor(Color aMain, Color)
Definition: border.cxx:1387
static const sal_uInt16 pRanges[]
Definition: border.hxx:78
bool get_value_changed_from_saved() const
Definition: border.cxx:243
void SetLeftMargin(sal_Int16 nLeft)
void SetDefDist(sal_uInt16 nNew)
std::unique_ptr< weld::CheckButton > m_xMergeWithNextCB
Definition: border.hxx:152
bool mbLeftModified
Definition: border.hxx:111
bool IsNoSelection() const
weld::MetricSpinButton & mrRightWrp
Definition: border.hxx:71
std::string GetValue
tools::Long nMinValue
minimum distance
Definition: border.hxx:101
bool mbRemoveAdjacentCellBorders
Definition: border.hxx:116
void SetMinDist(bool bNew)
void set_digits(unsigned int digits)
#define IID_PRE_TABLE_OUTERH
Definition: border.cxx:1133
Color(* ColorFunc)(Color)
long Long
bool IsHorEnabled() const
void SetColor(const Color &rNew)
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const editeng::SvxBorderLine * GetVert() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
sal_uInt16 GetValue() const
virtual void ChangesApplied() override
Definition: border.cxx:867
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
#define IID_PRE_HOR_OUTER
Definition: border.cxx:1122
sal_uInt16 GetPresetImageId(sal_uInt16 nValueSetIdx) const
Definition: border.cxx:1269
ValueSet & mrVsPos
Definition: border.hxx:52
virtual void Reset(const SfxItemSet *) override
Definition: border.cxx:617
sal_uInt16 GetDefDist() const
bool mbBottomModified
Definition: border.hxx:114
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: border.cxx:591
std::unique_ptr< ColorListBox > m_xLbLineColor
Definition: border.hxx:129
sal_uInt16 GetSelectedItemId() const
static SfxObjectShell * Current()
sal_Int16 GetRightMargin() const
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: border.cxx:1578
void SetLine(const editeng::SvxBorderLine *pNew)
SvxBorderTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreAttrs)
Definition: border.cxx:272
const editeng::SvxBorderLine * GetRight() const
sal_uInt16 mnBoxSlot
Definition: border.hxx:103
std::vector< Image > m_aShadowImgVec
Definition: border.hxx:98
void ResetFrameLine_Impl(svx::FrameBorderType eBorder, const editeng::SvxBorderLine *pCurLine, bool bValid)
share for individual Frame-/Core-Line
Definition: border.cxx:597
std::unique_ptr< weld::Container > m_xShadowFrame
Definition: border.hxx:143
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl, ValueSet *, void)
Definition: border.cxx:1137
std::unique_ptr< weld::CheckButton > m_xSynchronizeCB
Definition: border.hxx:141
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
OUString CuiResId(std::string_view aKey)
Definition: cuiresmgr.cxx:23
NONE
int normalize(int nValue) const
std::unique_ptr< weld::CustomWeld > m_xWndShadowsWin
Definition: border.hxx:145
void SetControlDontKnow()
Definition: border.cxx:213
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
void SaveValue()
SvxBorderLineStyle
IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox &, rColorBox, void)
Definition: border.cxx:1216
bool IsNoSelection() const
void SetNoSelection()
SvxShadowLocation GetLocation() const
FrameBorderState
#define SAL_MAX_UINT16
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SvxBoxInfoItemValidFlags
std::unique_ptr< weld::CustomWeld > m_xFrameSelWin
Definition: border.hxx:126
#define WB_ITEMBORDER
const OUString sEmpty
bool get_value_changed_from_saved() const
Definition: border.cxx:206
std::unique_ptr< weld::Label > m_xFtShadowColor
Definition: border.hxx:148
bool mbBLTREnabled
true = Bottom-left to top-right border enabled.
Definition: border.hxx:109
enum SvxBorderLineStyle sal_Int16 typedef::std::vector< FontMetric > ImplFontList Color sameColor(Color rMain)
bool IsAnyBorderVisible() const
bool IsMinDist() const
std::unique_ptr< weld::Container > m_xPropertiesFrame
properties - "Merge with next paragraph" in Writer
Definition: border.hxx:151
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
void EnableHor(bool bEnable)
std::unique_ptr< weld::MetricSpinButton > m_xBottomMF
Definition: border.hxx:140
TRISTATE_INDET
std::unique_ptr< weld::MetricSpinButton > m_xRightMF
Definition: border.hxx:136
#define IID_PRE_TABLE_NONE
Definition: border.cxx:1131
static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle)
Definition: border.cxx:90
std::vector< Image > m_aBorderImgVec
Definition: border.hxx:99
const SfxItemSet & GetItemSet() const
#define SAL_N_ELEMENTS(arr)
void set_text(const OUString &rText)
void FillShadowVS()
Definition: border.cxx:1355
Color(* ColorDistFunc)(Color, Color)
std::unique_ptr< weld::CheckButton > m_xRemoveAdjacentCellBordersCB
Definition: border.hxx:155
#define IID_PRE_VER_NONE
Definition: border.cxx:1126
void SetTopMargin(sal_Int16 nTop)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: border.cxx:877
weld::MetricSpinButton & mrLeftWrp
Definition: border.hxx:70
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const editeng::SvxBorderLine * GetHori() const
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
void SelectEntry(const NamedColor &rColor)
void SetRemoveAdjacentCellBorder(bool bSet)
const Color & GetColor() const
std::set< SvxBorderLineStyle > maUsedBorderStyles
Definition: border.hxx:119
SwBorderModes nSWMode
table, textframe, paragraph
Definition: border.hxx:102
const editeng::SvxBorderLine * GetTop() const
#define IID_PRE_CELL_ALL
Definition: border.cxx:1116
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const editeng::SvxBorderLine * GetLeft() const
#define DBG_ASSERT(sCon, aError)
int i
weld::MetricSpinButton & mrBottomWrp
Definition: border.hxx:73
std::unique_ptr< weld::MetricSpinButton > m_xEdShadowSize
Definition: border.hxx:147
bool GetVisibleWidth(tools::Long &rnWidth, SvxBorderLineStyle &rnStyle) const
void SetRightMargin(sal_Int16 nRight)
bool IsBorderLineStyleAllowed(SvxBorderLineStyle nStyle) const
Definition: border.cxx:608
bool IsValueChangedFromSaved() const
std::unique_ptr< ColorListBox > m_xLbShadowColor
Definition: border.hxx:149
std::unique_ptr< weld::MetricSpinButton > m_xTopMF
Definition: border.hxx:138
Color sameDistColor(Color, Color rDefault)
bool mbVerEnabled
true = Inner vertical border enabled.
Definition: border.hxx:107
bool mbTopModified
Definition: border.hxx:113
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
bool IsBorderEnabled(FrameBorderType eBorder) const
HTMLMODE_ON
weld::MetricSpinButton & mrTopWrp
Definition: border.hxx:72
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
void FillValueSets()
Definition: border.cxx:1380
bool IsValueChangedFromSaved() const
#define IID_PRE_HOR_ALL
Definition: border.cxx:1124
float u
FrameBorderType
const char * GetPresetStringId(sal_uInt16 nValueSetIdx) const
Definition: border.cxx:1302
const std::map< OUString, css::uno::Any > & GetGrabBag() const
#define IID_PRE_CELL_TB
Definition: border.cxx:1118
virtual bool FillItemSet(SfxItemSet *rCoreAttrs) override
Definition: border.cxx:885
#define IID_PRE_HOR_OUTER2
Definition: border.cxx:1125
void set_value(int nValue, FieldUnit eValueUnit)
void SetControlValue(const SvxMarginItem &rItem)
Definition: border.cxx:251
void SetBottomMargin(sal_Int16 nBottom)
#define IID_PRE_VER_OUTER2
Definition: border.cxx:1130
void SetDistance(sal_uInt16 nNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetFrameBorderStyle(FrameBorderType eBorder) const
SvxShadowItem GetControlValue(const SvxShadowItem &rItem) const
Definition: border.cxx:139
bool get_sensitive() const
const sal_uInt16 SVX_BORDER_PRESET_COUNT
Definition: border.cxx:127
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
#define IID_PRE_VER_OUTER
Definition: border.cxx:1127
bool get_value_changed_from_saved() const
bool mbRightModified
Definition: border.hxx:112
SfxItemPool * GetPool() const
sal_Int16 GetBottomMargin() const
static bool IsSlot(sal_uInt16 nId)
void EnableVer(bool bEnable)
sal_Int64 GetValue() const
std::unique_ptr< weld::MetricSpinButton > m_xLeftMF
Definition: border.hxx:134
bool GetVisibleColor(Color &rColor) const
void SaveValue()
int get_min(FieldUnit eValueUnit) const
SvxMarginItem GetControlValue(const SvxMarginItem &rItem) const
Definition: border.cxx:229
bool IsValid(SvxBoxInfoItemValidFlags nValid) const
void SelectItem(sal_uInt16 nItemId)
tools::Long const nBorder
#define IID_PRE_TABLE_OUTER
Definition: border.cxx:1132
void SelectAllVisibleBorders()
FrameSelFlags
void ShowBorder(FrameBorderType eBorder, const editeng::SvxBorderLine *pStyle)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
#define IID_PRE_CELL_L
Definition: border.cxx:1119
std::unique_ptr< weld::Label > m_xFtShadowSize
Definition: border.hxx:146
MarginControlsWrapper(weld::MetricSpinButton &rMfLeft, weld::MetricSpinButton &rMfRight, weld::MetricSpinButton &rMfTop, weld::MetricSpinButton &rMfBottom)
Definition: border.cxx:220
svx::FrameSelector m_aFrameSel
Definition: border.hxx:122
std::unique_ptr< weld::CustomWeld > m_xWndPresetsWin
Definition: border.hxx:124
void SetTableMode()
Definition: border.cxx:1604
Color const & GetSelectEntryColor() const
std::unique_ptr< ValueSet > m_xWndPresets
Definition: border.hxx:123
std::unique_ptr< SvtLineListBox > m_xLbLineStyle
Definition: border.hxx:128
#define IID_PRE_CELL_NONE
Definition: border.cxx:1115
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
ShadowControlsWrapper(ValueSet &rVsPos, weld::MetricSpinButton &rMfSize, ColorListBox &rLbColor)
Definition: border.cxx:132
void SetNoSelection()
void SetWidth(sal_uInt16 nNew)
#define GetWhich(nSlot)
void SetLocation(SvxShadowLocation eNew)
#define SVX_HIDESHADOWCTL
bool mbTLBREnabled
true = Top-left to bottom-right border enabled.
Definition: border.hxx:108
SvxBoxItemLine
const int FRAMEBORDERTYPE_COUNT
sal_Int16 GetLeftMargin() const
void set_min(int min, FieldUnit eValueUnit)
void * p
ColorListBox & mrLbColor
Definition: border.hxx:54
#define IID_PRE_TABLE_OUTER2
Definition: border.cxx:1135
SfxOkDialogController * GetDialogController() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
std::unique_ptr< weld::Label > m_xUserDefFT
Definition: border.hxx:125
std::unique_ptr< weld::MetricSpinButton > m_xLineWidthMF
Definition: border.hxx:130
void HideShadowControls()
Definition: border.cxx:1110
void SetControlValue(const SvxShadowItem &rItem)
Definition: border.cxx:176
DeactivateRC
const sal_uInt16 SVX_BORDER_SHADOW_COUNT
Definition: border.cxx:130
SwBorderModes
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
void FillLineListBox_Impl()
Definition: border.cxx:1392
FrameBorderState GetFrameBorderState(FrameBorderType eBorder) const
int get_value(FieldUnit eDestUnit) const
#define WB_DOUBLEBORDER
MapUnit
double ConvertDoubleValue(double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
void FillPresetVS()
Definition: border.cxx:1335
#define IID_PRE_CELL_DIAG
Definition: border.cxx:1120
#define IID_PRE_CELL_LR
Definition: border.cxx:1117
#define IID_PRE_TABLE_ALL
Definition: border.cxx:1134
std::unique_ptr< MarginControlsWrapper > m_xMarginControls
Definition: border.hxx:158
void SetBorderDontCare(FrameBorderType eBorder)
#define IID_PRE_VER_ALL
Definition: border.cxx:1129
std::unique_ptr< weld::CheckButton > m_xMergeAdjacentBordersCB
Definition: border.hxx:154
sal_uInt16 GetSmallestDistance() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const std::vector< sal_Int32 > & GetList() const
void UpdateRemoveAdjCellBorderCB(sal_uInt16 nPreset)
Definition: border.cxx:1530
#define IID_PRE_HOR_HOR
Definition: border.cxx:1123
sal_Int32 nState
weld::MetricSpinButton & mrMfSize
Definition: border.hxx:53
const editeng::SvxBorderLine * GetBottom() const
bool IsDist() const
const Color & GetWindowTextColor() const
int denormalize(int nValue) const
void SetControlDontKnow()
Definition: border.cxx:263
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
void SetDist(bool bNew)
bool IsVerEnabled() const
sal_uInt16 GetWidth() const
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
sal_Int16 GetTopMargin() const
static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton &rField)
Definition: border.cxx:82