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