android: Update app-specific/MIME type icons
[LibreOffice.git] / cui / source / tabpages / border.cxx
blob549ab533410ada31679613f4e06d080d9b290637
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <sfx2/objsh.hxx>
23 #include <svx/strings.hrc>
24 #include <svx/svxids.hrc>
26 #include <strings.hrc>
27 #include <bitmaps.hlst>
29 #include <editeng/boxitem.hxx>
30 #include <editeng/lineitem.hxx>
31 #include <border.hxx>
32 #include <svx/dlgutil.hxx>
33 #include <dialmgr.hxx>
34 #include <sfx2/htmlmode.hxx>
35 #include <vcl/fieldvalues.hxx>
36 #include <vcl/settings.hxx>
37 #include <vcl/svapp.hxx>
38 #include <svx/dialmgr.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>
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;
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
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 )
69 // static ----------------------------------------------------------------
71 const WhichRangesContainer SvxBorderTabPage::pRanges(
72 svl::Items<
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>);
79 namespace
81 int lcl_twipsToPt(sal_Int64 nTwips)
83 return vcl::ConvertDoubleValue(nTwips, 0, FieldUnit::TWIP, MapUnit::MapPoint) * 100;
87 const std::vector<int> SvxBorderTabPage::m_aLineWidths = {
88 lcl_twipsToPt(SvxBorderLineWidth::Hairline),
89 lcl_twipsToPt(SvxBorderLineWidth::VeryThin),
90 lcl_twipsToPt(SvxBorderLineWidth::Thin),
91 lcl_twipsToPt(SvxBorderLineWidth::Medium),
92 lcl_twipsToPt(SvxBorderLineWidth::Thick),
93 lcl_twipsToPt(SvxBorderLineWidth::ExtraThick),
97 static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField)
99 auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP));
100 rField.set_digits(1);
101 rField.set_min(rField.normalize(nMin), FieldUnit::TWIP);
104 // returns in pt
105 static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle)
107 switch (aStyle)
109 case SvxBorderLineStyle::NONE:
110 return 0;
112 case SvxBorderLineStyle::SOLID:
113 case SvxBorderLineStyle::DOTTED:
114 case SvxBorderLineStyle::DASHED:
115 case SvxBorderLineStyle::FINE_DASHED:
116 case SvxBorderLineStyle::DASH_DOT:
117 case SvxBorderLineStyle::DASH_DOT_DOT:
118 return 15;
120 // Double lines
121 case SvxBorderLineStyle::DOUBLE: return 15;
122 case SvxBorderLineStyle::DOUBLE_THIN: return 15;
123 case SvxBorderLineStyle::THINTHICK_SMALLGAP: return 20;
124 case SvxBorderLineStyle::THINTHICK_MEDIUMGAP: return 15;
125 case SvxBorderLineStyle::THINTHICK_LARGEGAP: return 15;
126 case SvxBorderLineStyle::THICKTHIN_SMALLGAP: return 20;
127 case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP: return 15;
128 case SvxBorderLineStyle::THICKTHIN_LARGEGAP: return 15;
130 case SvxBorderLineStyle::EMBOSSED: return 15;
131 case SvxBorderLineStyle::ENGRAVED: return 15;
133 case SvxBorderLineStyle::OUTSET: return 10;
134 case SvxBorderLineStyle::INSET: return 10;
136 default:
137 return 15;
141 // number of preset images to show
142 const sal_uInt16 BORDER_PRESET_COUNT = 5;
144 // number of shadow images to show
145 const sal_uInt16 BORDER_SHADOW_COUNT = 5;
147 ShadowControlsWrapper::ShadowControlsWrapper(ValueSet& rVsPos, weld::MetricSpinButton& rMfSize, ColorListBox& rLbColor)
148 : mrVsPos(rVsPos)
149 , mrMfSize(rMfSize)
150 , mrLbColor(rLbColor)
154 SvxShadowItem ShadowControlsWrapper::GetControlValue(const SvxShadowItem& rItem) const
156 SvxShadowItem aItem(rItem);
157 if (!mrVsPos.IsNoSelection())
159 switch (mrVsPos.GetSelectedItemId())
161 case 1:
162 aItem.SetLocation(SvxShadowLocation::NONE);
163 break;
164 case 2:
165 aItem.SetLocation(SvxShadowLocation::BottomRight);
166 break;
167 case 3:
168 aItem.SetLocation(SvxShadowLocation::TopRight);
169 break;
170 case 4:
171 aItem.SetLocation(SvxShadowLocation::BottomLeft);
172 break;
173 case 5:
174 aItem.SetLocation(SvxShadowLocation::TopLeft);
175 break;
176 default:
177 aItem.SetLocation(SvxShadowLocation::NONE);
178 break;
181 // Default value was saved; so don't change the aItem's width if the control
182 // has not changed its value, to avoid round-trip errors (like twip->cm->twip)
183 // E.g., initial 100 twip will become 0.18 cm, which will return as 102 twip
184 if (mrMfSize.get_value_changed_from_saved())
185 aItem.SetWidth(mrMfSize.denormalize(mrMfSize.get_value(FieldUnit::TWIP)));
186 if (!mrLbColor.IsNoSelection())
187 aItem.SetColor(mrLbColor.GetSelectEntryColor());
188 return aItem;
191 void ShadowControlsWrapper::SetControlValue(const SvxShadowItem& rItem)
193 switch (rItem.GetLocation())
195 case SvxShadowLocation::NONE:
196 mrVsPos.SelectItem(1);
197 break;
198 case SvxShadowLocation::BottomRight:
199 mrVsPos.SelectItem(2);
200 break;
201 case SvxShadowLocation::TopRight:
202 mrVsPos.SelectItem(3);
203 break;
204 case SvxShadowLocation::BottomLeft:
205 mrVsPos.SelectItem(4);
206 break;
207 case SvxShadowLocation::TopLeft:
208 mrVsPos.SelectItem(5);
209 break;
210 default:
211 mrVsPos.SetNoSelection();
212 break;
214 mrVsPos.SaveValue();
215 mrMfSize.set_value(mrMfSize.normalize(rItem.GetWidth()), FieldUnit::TWIP);
216 mrMfSize.save_value();
217 mrLbColor.SelectEntry(rItem.GetColor());
218 mrLbColor.SaveValue();
221 bool ShadowControlsWrapper::get_value_changed_from_saved() const
223 return mrVsPos.IsValueChangedFromSaved() ||
224 mrMfSize.get_value_changed_from_saved() ||
225 mrLbColor.IsValueChangedFromSaved();
228 void ShadowControlsWrapper::SetControlDontKnow()
230 mrVsPos.SetNoSelection();
231 mrMfSize.set_text("");
232 mrLbColor.SetNoSelection();
235 MarginControlsWrapper::MarginControlsWrapper(weld::MetricSpinButton& rMfLeft, weld::MetricSpinButton& rMfRight,
236 weld::MetricSpinButton& rMfTop, weld::MetricSpinButton& rMfBottom)
237 : mrLeftWrp(rMfLeft)
238 , mrRightWrp(rMfRight)
239 , mrTopWrp(rMfTop)
240 , mrBottomWrp(rMfBottom)
244 SvxMarginItem MarginControlsWrapper::GetControlValue(const SvxMarginItem &rItem) const
246 SvxMarginItem aItem(rItem);
247 if (mrLeftWrp.get_sensitive())
248 aItem.SetLeftMargin(mrLeftWrp.denormalize(mrLeftWrp.get_value(FieldUnit::TWIP)));
249 if (mrRightWrp.get_sensitive())
250 aItem.SetRightMargin(mrRightWrp.denormalize(mrRightWrp.get_value(FieldUnit::TWIP)));
251 if (mrTopWrp.get_sensitive())
252 aItem.SetTopMargin(mrTopWrp.denormalize(mrTopWrp.get_value(FieldUnit::TWIP)));
253 if (mrBottomWrp.get_sensitive())
254 aItem.SetBottomMargin(mrBottomWrp.denormalize(mrBottomWrp.get_value(FieldUnit::TWIP)));
255 return aItem;
258 bool MarginControlsWrapper::get_value_changed_from_saved() const
260 return mrLeftWrp.get_value_changed_from_saved() ||
261 mrRightWrp.get_value_changed_from_saved() ||
262 mrTopWrp.get_value_changed_from_saved() ||
263 mrBottomWrp.get_value_changed_from_saved();
266 void MarginControlsWrapper::SetControlValue(const SvxMarginItem& rItem)
268 mrLeftWrp.set_value(mrLeftWrp.normalize(rItem.GetLeftMargin()), FieldUnit::TWIP);
269 mrRightWrp.set_value(mrRightWrp.normalize(rItem.GetRightMargin()), FieldUnit::TWIP);
270 mrTopWrp.set_value(mrTopWrp.normalize(rItem.GetTopMargin()), FieldUnit::TWIP);
271 mrBottomWrp.set_value(mrBottomWrp.normalize(rItem.GetBottomMargin()), FieldUnit::TWIP);
272 mrLeftWrp.save_value();
273 mrRightWrp.save_value();
274 mrTopWrp.save_value();
275 mrBottomWrp.save_value();
278 void MarginControlsWrapper::SetControlDontKnow()
280 const OUString sEmpty;
281 mrLeftWrp.set_text(sEmpty);
282 mrRightWrp.set_text(sEmpty);
283 mrTopWrp.set_text(sEmpty);
284 mrBottomWrp.set_text(sEmpty);
287 SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
288 : SfxTabPage(pPage, pController, "cui/ui/borderpage.ui", "BorderPage", &rCoreAttrs)
289 , nMinValue(0)
290 , nSWMode(SwBorderModes::NONE)
291 , mnBoxSlot(SID_ATTR_BORDER_OUTER)
292 , mnShadowSlot(SID_ATTR_BORDER_SHADOW)
293 , mbHorEnabled(false)
294 , mbVerEnabled(false)
295 , mbTLBREnabled(false)
296 , mbBLTREnabled(false)
297 , mbUseMarginItem(false)
298 , mbLeftModified(false)
299 , mbRightModified(false)
300 , mbTopModified(false)
301 , mbBottomModified(false)
302 , mbSync(true)
303 , mbRemoveAdjacentCellBorders(false)
304 , bIsCalcDoc(false)
305 , m_xWndPresets(new ValueSet(nullptr))
306 , m_xWndPresetsWin(new weld::CustomWeld(*m_xBuilder, "presets", *m_xWndPresets))
307 , m_xUserDefFT(m_xBuilder->weld_label("userdefft"))
308 , m_xFrameSelWin(new weld::CustomWeld(*m_xBuilder, "framesel", m_aFrameSel))
309 , m_xLbLineStyle(new SvtLineListBox(m_xBuilder->weld_menu_button("linestylelb")))
310 , m_xLbLineColor(new ColorListBox(m_xBuilder->weld_menu_button("linecolorlb"),
311 [this]{ return GetDialogController()->getDialog(); }))
312 , m_xLineWidthLB(m_xBuilder->weld_combo_box("linewidthlb"))
313 , m_xLineWidthMF(m_xBuilder->weld_metric_spin_button("linewidthmf", FieldUnit::POINT))
314 , m_xSpacingFrame(m_xBuilder->weld_container("spacing"))
315 , m_xLeftFT(m_xBuilder->weld_label("leftft"))
316 , m_xLeftMF(m_xBuilder->weld_metric_spin_button("leftmf", FieldUnit::MM))
317 , m_xRightFT(m_xBuilder->weld_label("rightft"))
318 , m_xRightMF(m_xBuilder->weld_metric_spin_button("rightmf", FieldUnit::MM))
319 , m_xTopFT(m_xBuilder->weld_label("topft"))
320 , m_xTopMF(m_xBuilder->weld_metric_spin_button("topmf", FieldUnit::MM))
321 , m_xBottomFT(m_xBuilder->weld_label("bottomft"))
322 , m_xBottomMF(m_xBuilder->weld_metric_spin_button("bottommf", FieldUnit::MM))
323 , m_xSynchronizeCB(m_xBuilder->weld_check_button("sync"))
324 , m_xShadowFrame(m_xBuilder->weld_container("shadow"))
325 , m_xWndShadows(new ValueSet(nullptr))
326 , m_xWndShadowsWin(new weld::CustomWeld(*m_xBuilder, "shadows", *m_xWndShadows))
327 , m_xFtShadowSize(m_xBuilder->weld_label("distanceft"))
328 , m_xEdShadowSize(m_xBuilder->weld_metric_spin_button("distancemf", FieldUnit::MM))
329 , m_xFtShadowColor(m_xBuilder->weld_label("shadowcolorft"))
330 , m_xLbShadowColor(new ColorListBox(m_xBuilder->weld_menu_button("shadowcolorlb"),
331 [this]{ return GetDialogController()->getDialog(); }))
332 , m_xPropertiesFrame(m_xBuilder->weld_container("properties"))
333 , m_xMergeWithNextCB(m_xBuilder->weld_check_button("mergewithnext"))
334 , m_xMergeAdjacentBordersCB(m_xBuilder->weld_check_button("mergeadjacent"))
335 , m_xRemoveAdjacentCellBordersCB(m_xBuilder->weld_check_button("rmadjcellborders"))
336 , m_xRemoveAdjacentCellBordersFT(m_xBuilder->weld_label("rmadjcellbordersft"))
338 static std::vector<OUString> aBorderImageIds;
340 if (aBorderImageIds.empty())
342 if (comphelper::LibreOfficeKit::isActive())
344 aBorderImageIds.insert(aBorderImageIds.end(), {
345 RID_SVXBMP_CELL_NONE_32,
346 RID_SVXBMP_CELL_ALL_32,
347 RID_SVXBMP_CELL_LR_32,
348 RID_SVXBMP_CELL_TB_32,
349 RID_SVXBMP_CELL_L_32,
350 RID_SVXBMP_CELL_DIAG_32
353 else
355 aBorderImageIds.insert(aBorderImageIds.end(), {
356 RID_SVXBMP_CELL_NONE,
357 RID_SVXBMP_CELL_ALL,
358 RID_SVXBMP_CELL_LR,
359 RID_SVXBMP_CELL_TB,
360 RID_SVXBMP_CELL_L,
361 RID_SVXBMP_CELL_DIAG
364 aBorderImageIds.insert(aBorderImageIds.end(), {
365 RID_SVXBMP_HOR_NONE,
366 RID_SVXBMP_HOR_OUTER,
367 RID_SVXBMP_HOR_HOR,
368 RID_SVXBMP_HOR_ALL,
369 RID_SVXBMP_HOR_OUTER2,
370 RID_SVXBMP_VER_NONE,
371 RID_SVXBMP_VER_OUTER,
372 RID_SVXBMP_VER_VER,
373 RID_SVXBMP_VER_ALL,
374 RID_SVXBMP_VER_OUTER2,
375 RID_SVXBMP_TABLE_NONE,
376 RID_SVXBMP_TABLE_OUTER,
377 RID_SVXBMP_TABLE_OUTERH,
378 RID_SVXBMP_TABLE_ALL,
379 RID_SVXBMP_TABLE_OUTER2
383 for (auto const & rImageId : aBorderImageIds)
384 m_aBorderImgVec.emplace_back(StockImage::Yes, rImageId);
386 static std::vector<OUString> aShadowImageIds;
387 if (aShadowImageIds.empty())
389 if (comphelper::LibreOfficeKit::isActive())
391 aShadowImageIds.insert(aShadowImageIds.end(), {
392 RID_SVXBMP_SHADOWNONE_32,
393 RID_SVXBMP_SHADOW_BOT_RIGHT_32,
394 RID_SVXBMP_SHADOW_TOP_RIGHT_32,
395 RID_SVXBMP_SHADOW_BOT_LEFT_32,
396 RID_SVXBMP_SHADOW_TOP_LEFT_32
399 else
401 aShadowImageIds.insert(aShadowImageIds.end(), {
402 RID_SVXBMP_SHADOWNONE,
403 RID_SVXBMP_SHADOW_BOT_RIGHT,
404 RID_SVXBMP_SHADOW_TOP_RIGHT,
405 RID_SVXBMP_SHADOW_BOT_LEFT,
406 RID_SVXBMP_SHADOW_TOP_LEFT
411 for (auto const & rImageId : aShadowImageIds)
412 m_aShadowImgVec.emplace_back(StockImage::Yes, rImageId);
414 assert(m_aShadowImgVec.size() == BORDER_SHADOW_COUNT);
416 // this page needs ExchangeSupport
417 SetExchangeSupport();
419 /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
420 -> Remember this state in mbUseMarginItem, because other special handling
421 is needed across various functions... */
422 mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN)) != SfxItemState::UNKNOWN;
424 if (const SfxIntegerListItem* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_STYLES))
426 std::vector<sal_Int32> aUsedStyles = p->GetList();
427 for (int aUsedStyle : aUsedStyles)
428 maUsedBorderStyles.insert(static_cast<SvxBorderLineStyle>(aUsedStyle));
431 if (const SfxInt64Item* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_DEFAULT_WIDTH))
433 // The caller specifies default line width. Honor it.
434 SetLineWidth(p->GetValue());
437 // set metric
438 FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
440 if( mbUseMarginItem )
442 // copied from SvxAlignmentTabPage
443 switch ( eFUnit )
445 // #103396# the default value (1pt) can't be accurately represented in
446 // inches or pica with two decimals, so point is used instead.
447 case FieldUnit::PICA:
448 case FieldUnit::INCH:
449 case FieldUnit::FOOT:
450 case FieldUnit::MILE:
451 eFUnit = FieldUnit::POINT;
452 break;
454 case FieldUnit::CM:
455 case FieldUnit::M:
456 case FieldUnit::KM:
457 eFUnit = FieldUnit::MM;
458 break;
459 default: ;//prevent warning
462 else
464 switch ( eFUnit )
466 case FieldUnit::M:
467 case FieldUnit::KM:
468 eFUnit = FieldUnit::MM;
469 break;
470 default: ; //prevent warning
474 SetFieldUnit(*m_xEdShadowSize, eFUnit);
476 sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, false );
477 bool bIsDontCare = true;
479 if ( rCoreAttrs.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
481 // paragraph or table
482 const SvxBoxInfoItem* pBoxInfo =
483 static_cast<const SvxBoxInfoItem*>(&( rCoreAttrs.Get( nWhich ) ));
485 mbHorEnabled = pBoxInfo->IsHorEnabled();
486 mbVerEnabled = pBoxInfo->IsVerEnabled();
487 mbTLBREnabled = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_BORDER_DIAG_TLBR)) != SfxItemState::UNKNOWN;
488 mbBLTREnabled = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_BORDER_DIAG_BLTR)) != SfxItemState::UNKNOWN;
490 if(pBoxInfo->IsDist())
492 SetFieldUnit(*m_xLeftMF, eFUnit);
493 SetFieldUnit(*m_xRightMF, eFUnit);
494 SetFieldUnit(*m_xTopMF, eFUnit);
495 SetFieldUnit(*m_xBottomMF, eFUnit);
496 m_xSynchronizeCB->connect_toggled(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
497 m_xLeftMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
498 m_xRightMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
499 m_xTopMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
500 m_xBottomMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
502 else
504 m_xSpacingFrame->hide();
506 bIsDontCare = !pBoxInfo->IsValid( SvxBoxInfoItemValidFlags::DISABLE );
508 if(!mbUseMarginItem && eFUnit == FieldUnit::MM && MapUnit::MapTwip == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
510 //#i91548# changing the number of decimal digits changes the minimum values, too
511 lcl_SetDecimalDigitsTo1(*m_xLeftMF);
512 lcl_SetDecimalDigitsTo1(*m_xRightMF);
513 lcl_SetDecimalDigitsTo1(*m_xTopMF);
514 lcl_SetDecimalDigitsTo1(*m_xBottomMF);
515 lcl_SetDecimalDigitsTo1(*m_xEdShadowSize);
518 FrameSelFlags nFlags = FrameSelFlags::Outer;
519 if( mbHorEnabled )
520 nFlags |= FrameSelFlags::InnerHorizontal;
521 if( mbVerEnabled )
522 nFlags |= FrameSelFlags::InnerVertical;
523 if( mbTLBREnabled )
524 nFlags |= FrameSelFlags::DiagonalTLBR;
525 if( mbBLTREnabled )
526 nFlags |= FrameSelFlags::DiagonalBLTR;
527 if( bIsDontCare )
528 nFlags |= FrameSelFlags::DontCare;
529 m_aFrameSel.Initialize( nFlags );
531 m_aFrameSel.SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
532 m_xLbLineStyle->SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
533 m_xLbLineColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
534 m_xLineWidthLB->connect_changed(LINK(this, SvxBorderTabPage, ModifyWidthLBHdl_Impl));
535 m_xLineWidthMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyWidthMFHdl_Impl));
536 m_xWndPresets->SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
537 m_xWndShadows->SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
539 FillValueSets();
540 FillLineListBox_Impl();
542 // Reapply line width: probably one of predefined values should be selected
543 SetLineWidth(m_xLineWidthMF->get_value(FieldUnit::NONE));
545 // connections
546 const SfxPoolItem* pItem = nullptr;
547 if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG), &pItem))
549 const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem);
550 auto it = pGrabBag->GetGrabBag().find("DialogUseCharAttr");
551 if (it != pGrabBag->GetGrabBag().end())
553 bool bDialogUseCharAttr = false;
554 it->second >>= bDialogUseCharAttr;
555 if (bDialogUseCharAttr)
557 mnShadowSlot = SID_ATTR_CHAR_SHADOW;
558 mnBoxSlot = SID_ATTR_CHAR_BOX;
563 bool bSupportsShadow = !SfxItemPool::IsSlot(GetWhich(mnShadowSlot));
564 if( bSupportsShadow )
565 m_xShadowControls.reset(new ShadowControlsWrapper(*m_xWndShadows, *m_xEdShadowSize, *m_xLbShadowColor));
566 else
567 HideShadowControls();
569 if (mbUseMarginItem)
570 m_xMarginControls.reset(new MarginControlsWrapper(*m_xLeftMF, *m_xRightMF, *m_xTopMF, *m_xBottomMF));
572 // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
573 m_xMergeWithNextCB->hide();
574 // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
575 m_xMergeAdjacentBordersCB->hide();
577 if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
579 Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
580 if ( xSI.is() )
581 bIsCalcDoc = xSI->supportsService("com.sun.star.sheet.SpreadsheetDocument");
583 if( bIsCalcDoc )
585 m_xRemoveAdjacentCellBordersCB->connect_toggled(LINK(this, SvxBorderTabPage, RemoveAdjacentCellBorderHdl_Impl));
586 m_xRemoveAdjacentCellBordersCB->show();
587 m_xRemoveAdjacentCellBordersCB->set_sensitive(false);
589 else
591 m_xRemoveAdjacentCellBordersCB->hide();
592 m_xRemoveAdjacentCellBordersFT->hide();
596 SvxBorderTabPage::~SvxBorderTabPage()
598 m_xLbShadowColor.reset();
599 m_xWndShadowsWin.reset();
600 m_xWndShadows.reset();
601 m_xLbLineColor.reset();
602 m_xLbLineStyle.reset();
603 m_xFrameSelWin.reset();
604 m_xWndPresetsWin.reset();
605 m_xWndPresets.reset();
608 std::unique_ptr<SfxTabPage> SvxBorderTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
609 const SfxItemSet* rAttrSet )
611 return std::make_unique<SvxBorderTabPage>(pPage, pController, *rAttrSet);
614 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
616 if( m_aFrameSel.IsBorderEnabled( eBorder ) )
618 if( bValid )
619 m_aFrameSel.ShowBorder( eBorder, pCoreLine );
620 else
621 m_aFrameSel.SetBorderDontCare( eBorder );
625 bool SvxBorderTabPage::IsBorderLineStyleAllowed( SvxBorderLineStyle nStyle ) const
627 if (maUsedBorderStyles.empty())
628 // All border styles are allowed.
629 return true;
631 return maUsedBorderStyles.count(nStyle) > 0;
634 void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
636 SfxItemPool* pPool = rSet->GetPool();
638 if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::TLBR))
640 sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_TLBR);
641 if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId)))
642 m_aFrameSel.ShowBorder(svx::FrameBorderType::TLBR, pLineItem->GetLine());
643 else
644 m_aFrameSel.SetBorderDontCare(svx::FrameBorderType::TLBR);
647 if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::BLTR))
649 sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_BLTR);
650 if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId)))
651 m_aFrameSel.ShowBorder(svx::FrameBorderType::BLTR, pLineItem->GetLine());
652 else
653 m_aFrameSel.SetBorderDontCare(svx::FrameBorderType::BLTR);
656 if (m_xShadowControls)
658 sal_uInt16 nShadowId = pPool->GetWhich(mnShadowSlot);
659 const SfxPoolItem* pItem = rSet->GetItem(nShadowId);
660 if (pItem)
661 m_xShadowControls->SetControlValue(*static_cast<const SvxShadowItem*>(pItem));
662 else
663 m_xShadowControls->SetControlDontKnow();
666 if (m_xMarginControls)
668 sal_uInt16 nAlignMarginId = pPool->GetWhich(SID_ATTR_ALIGN_MARGIN);
669 const SfxPoolItem* pItem = rSet->GetItem(nAlignMarginId);
670 if (pItem)
671 m_xMarginControls->SetControlValue(*static_cast<const SvxMarginItem*>(pItem));
672 else
673 m_xMarginControls->SetControlDontKnow();
676 sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
677 const SfxBoolItem *pMergeAdjacentBorders = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeAdjacentBordersId));
678 if (!pMergeAdjacentBorders)
679 m_xMergeAdjacentBordersCB->set_state(TRISTATE_INDET);
680 else
681 m_xMergeAdjacentBordersCB->set_active(pMergeAdjacentBorders->GetValue());
682 m_xMergeAdjacentBordersCB->save_state();
684 sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
685 const SfxBoolItem *pMergeWithNext = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeWithNextId));
686 if (!pMergeWithNext)
687 m_xMergeWithNextCB->set_state(TRISTATE_INDET);
688 else
689 m_xMergeWithNextCB->set_active(pMergeWithNext->GetValue());
690 m_xMergeWithNextCB->save_state();
692 const SvxBoxItem* pBoxItem;
693 const SvxBoxInfoItem* pBoxInfoItem;
694 sal_uInt16 nWhichBox = GetWhich(mnBoxSlot);
695 MapUnit eCoreUnit;
697 pBoxItem = static_cast<const SvxBoxItem*>(GetItem( *rSet, mnBoxSlot ));
699 pBoxInfoItem = GetItem( *rSet, SID_ATTR_BORDER_INNER, false );
701 eCoreUnit = pPool->GetMetric( nWhichBox );
703 if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
705 ResetFrameLine_Impl( svx::FrameBorderType::Left, pBoxItem->GetLeft(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::LEFT ) );
706 ResetFrameLine_Impl( svx::FrameBorderType::Right, pBoxItem->GetRight(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::RIGHT ) );
707 ResetFrameLine_Impl( svx::FrameBorderType::Top, pBoxItem->GetTop(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::TOP ) );
708 ResetFrameLine_Impl( svx::FrameBorderType::Bottom, pBoxItem->GetBottom(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::BOTTOM ) );
709 ResetFrameLine_Impl( svx::FrameBorderType::Vertical, pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::VERT ) );
710 ResetFrameLine_Impl( svx::FrameBorderType::Horizontal, pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::HORI ) );
713 // distance inside
715 if( !mbUseMarginItem )
717 if (m_xLeftMF->get_visible())
719 SetMetricValue(*m_xLeftMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
720 SetMetricValue(*m_xRightMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
721 SetMetricValue(*m_xTopMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
722 SetMetricValue(*m_xBottomMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
724 nMinValue = m_xLeftMF->get_value(FieldUnit::NONE);
726 if ( pBoxInfoItem->IsDist() )
728 if( rSet->GetItemState( nWhichBox ) >= SfxItemState::DEFAULT )
730 bool bIsAnyBorderVisible = m_aFrameSel.IsAnyBorderVisible();
731 if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
733 m_xLeftMF->set_min(0, FieldUnit::NONE);
734 m_xRightMF->set_min(0, FieldUnit::NONE);
735 m_xTopMF->set_min(0, FieldUnit::NONE);
736 m_xBottomMF->set_min(0, FieldUnit::NONE);
738 tools::Long nLeftDist = pBoxItem->GetDistance( SvxBoxItemLine::LEFT);
739 SetMetricValue(*m_xLeftMF, nLeftDist, eCoreUnit);
740 tools::Long nRightDist = pBoxItem->GetDistance( SvxBoxItemLine::RIGHT);
741 SetMetricValue(*m_xRightMF, nRightDist, eCoreUnit);
742 tools::Long nTopDist = pBoxItem->GetDistance( SvxBoxItemLine::TOP);
743 SetMetricValue( *m_xTopMF, nTopDist, eCoreUnit );
744 tools::Long nBottomDist = pBoxItem->GetDistance( SvxBoxItemLine::BOTTOM);
745 SetMetricValue( *m_xBottomMF, nBottomDist, eCoreUnit );
747 // if the distance is set with no active border line
748 // or it is null with an active border line
749 // no automatic changes should be made
750 const tools::Long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
751 bool bDiffDist = (nDefDist != nLeftDist ||
752 nDefDist != nRightDist ||
753 nDefDist != nTopDist ||
754 nDefDist != nBottomDist);
755 if ((pBoxItem->GetSmallestDistance() || bIsAnyBorderVisible) && bDiffDist )
757 mbLeftModified = true;
758 mbRightModified = true;
759 mbTopModified = true;
760 mbBottomModified = true;
763 else
765 // #106224# different margins -> do not fill the edits
766 m_xLeftMF->set_text( OUString() );
767 m_xRightMF->set_text( OUString() );
768 m_xTopMF->set_text( OUString() );
769 m_xBottomMF->set_text( OUString() );
772 m_xLeftMF->save_value();
773 m_xRightMF->save_value();
774 m_xTopMF->save_value();
775 m_xBottomMF->save_value();
779 else
781 // avoid ResetFrameLine-calls:
782 m_aFrameSel.HideAllBorders();
785 if( !m_aFrameSel.IsAnyBorderVisible() )
786 m_aFrameSel.DeselectAllBorders();
788 // depict line (color) in controllers if unambiguous:
791 // Do all visible lines show the same line widths?
792 tools::Long nWidth;
793 SvxBorderLineStyle nStyle;
794 bool bWidthEq = m_aFrameSel.GetVisibleWidth( nWidth, nStyle );
795 if( bWidthEq )
797 // Determine the width first as some styles can be missing depending on it
798 sal_Int64 nWidthPt = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
799 sal_Int64( nWidth ), m_xLineWidthMF->get_digits(),
800 MapUnit::MapTwip, FieldUnit::POINT ));
801 SetLineWidth(nWidthPt);
802 m_xLbLineStyle->SetWidth(nWidth);
804 // then set the style
805 m_xLbLineStyle->SelectEntry( nStyle );
807 else
808 m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
810 // Do all visible lines show the same line color?
811 Color aColor;
812 bool bColorEq = m_aFrameSel.GetVisibleColor( aColor );
813 if( !bColorEq )
814 aColor = COL_BLACK;
816 m_xLbLineColor->SelectEntry(aColor);
817 auto nTextColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
818 m_xLbLineStyle->SetColor(nTextColor);
820 // Select all visible lines, if they are all equal.
821 if( bWidthEq && bColorEq )
822 m_aFrameSel.SelectAllVisibleBorders();
824 // set the current style and color (caches style in control even if nothing is selected)
825 SelStyleHdl_Impl(*m_xLbLineStyle);
826 SelColHdl_Impl(*m_xLbLineColor);
829 bool bEnable = m_xWndShadows->GetSelectedItemId() > 1 ;
830 m_xFtShadowSize->set_sensitive(bEnable);
831 m_xEdShadowSize->set_sensitive(bEnable);
832 m_xFtShadowColor->set_sensitive(bEnable);
833 m_xLbShadowColor->set_sensitive(bEnable);
835 m_xWndPresets->SetNoSelection();
837 // - no line - should not be selected
839 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
841 m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
842 SelStyleHdl_Impl(*m_xLbLineStyle);
845 const SfxUInt16Item* pHtmlModeItem = rSet->GetItemIfSet(SID_HTML_MODE, false);
846 if(!pHtmlModeItem)
848 if (SfxObjectShell* pShell = SfxObjectShell::Current())
849 pHtmlModeItem = pShell->GetItem(SID_HTML_MODE);
851 if(pHtmlModeItem)
853 sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue();
854 if(nHtmlMode & HTMLMODE_ON)
856 // there are no shadows in Html-mode and only complete borders
857 m_xShadowFrame->set_sensitive(false);
859 if( !(nSWMode & SwBorderModes::TABLE) )
861 m_xUserDefFT->set_sensitive(false);
862 m_xFrameSelWin->set_sensitive(false);
863 m_xWndPresets->RemoveItem(3);
864 m_xWndPresets->RemoveItem(4);
865 m_xWndPresets->RemoveItem(5);
870 LinesChanged_Impl( nullptr );
871 if (m_xLeftMF->get_value(FieldUnit::NONE) == m_xRightMF->get_value(FieldUnit::NONE) &&
872 m_xTopMF->get_value(FieldUnit::NONE) == m_xBottomMF->get_value(FieldUnit::NONE) &&
873 m_xTopMF->get_value(FieldUnit::NONE) == m_xLeftMF->get_value(FieldUnit::NONE))
875 mbSync = true;
877 else
878 mbSync = false;
879 m_xSynchronizeCB->set_active(mbSync);
881 mbRemoveAdjacentCellBorders = false;
882 m_xRemoveAdjacentCellBordersCB->set_active(false);
883 m_xRemoveAdjacentCellBordersCB->set_sensitive(false);
886 void SvxBorderTabPage::ChangesApplied()
888 m_xLeftMF->save_value();
889 m_xRightMF->save_value();
890 m_xTopMF->save_value();
891 m_xBottomMF->save_value();
892 m_xMergeWithNextCB->save_state();
893 m_xMergeAdjacentBordersCB->save_state();
896 DeactivateRC SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
898 if ( _pSet )
899 FillItemSet( _pSet );
901 return DeactivateRC::LeavePage;
904 bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
906 bool bAttrsChanged = false;
908 SfxItemPool* pPool = rCoreAttrs->GetPool();
910 if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::TLBR) &&
911 m_aFrameSel.GetFrameBorderState(svx::FrameBorderType::TLBR) != svx::FrameBorderState::DontCare)
913 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR))
915 SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
916 aLineItem.SetLine(m_aFrameSel.GetFrameBorderStyle(svx::FrameBorderType::TLBR));
917 rCoreAttrs->Put(aLineItem);
918 bAttrsChanged = true;
922 if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::BLTR) &&
923 m_aFrameSel.GetFrameBorderState(svx::FrameBorderType::BLTR) != svx::FrameBorderState::DontCare)
925 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR))
927 SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
928 aLineItem.SetLine(m_aFrameSel.GetFrameBorderStyle(svx::FrameBorderType::BLTR));
929 rCoreAttrs->Put(aLineItem);
930 bAttrsChanged = true;
934 if (m_xShadowControls && m_xShadowControls->get_value_changed_from_saved())
936 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, mnShadowSlot))
938 const SvxShadowItem& rOldShadowItem = *static_cast<const SvxShadowItem*>(pOldItem);
939 rCoreAttrs->Put(m_xShadowControls->GetControlValue(rOldShadowItem));
940 bAttrsChanged = true;
944 if (m_xMarginControls && m_xMarginControls->get_value_changed_from_saved())
946 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_ALIGN_MARGIN))
948 const SvxMarginItem& rOldMarginItem = *static_cast<const SvxMarginItem*>(pOldItem);
949 rCoreAttrs->Put(m_xMarginControls->GetControlValue(rOldMarginItem));
950 bAttrsChanged = true;
954 if (m_xMergeAdjacentBordersCB->get_state_changed_from_saved())
956 auto nState = m_xMergeAdjacentBordersCB->get_state();
957 if (nState == TRISTATE_INDET)
959 sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
960 rCoreAttrs->ClearItem(nMergeAdjacentBordersId);
962 else
964 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_SW_COLLAPSING_BORDERS))
966 std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
967 xNewItem->SetValue(static_cast<bool>(nState));
968 rCoreAttrs->Put(std::move(xNewItem));
971 bAttrsChanged = true;
974 if (m_xMergeWithNextCB->get_state_changed_from_saved())
976 auto nState = m_xMergeWithNextCB->get_state();
977 if (nState == TRISTATE_INDET)
979 sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
980 rCoreAttrs->ClearItem(nMergeWithNextId);
982 else
984 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_CONNECT))
986 std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
987 xNewItem->SetValue(static_cast<bool>(nState));
988 rCoreAttrs->Put(std::move(xNewItem));
991 bAttrsChanged = true;
994 bool bPut = true;
995 sal_uInt16 nBoxWhich = GetWhich( mnBoxSlot );
996 sal_uInt16 nBoxInfoWhich = pPool->GetWhich( SID_ATTR_BORDER_INNER, false );
997 const SfxItemSet& rOldSet = GetItemSet();
998 SvxBoxItem aBoxItem ( nBoxWhich );
999 SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich );
1000 const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( *rCoreAttrs, mnBoxSlot ));
1002 MapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
1005 // outer border:
1007 std::pair<svx::FrameBorderType,SvxBoxItemLine> eTypes1[] = {
1008 { svx::FrameBorderType::Top,SvxBoxItemLine::TOP },
1009 { svx::FrameBorderType::Bottom,SvxBoxItemLine::BOTTOM },
1010 { svx::FrameBorderType::Left,SvxBoxItemLine::LEFT },
1011 { svx::FrameBorderType::Right,SvxBoxItemLine::RIGHT },
1014 for (std::pair<svx::FrameBorderType,SvxBoxItemLine> const & i : eTypes1)
1015 aBoxItem.SetLine( m_aFrameSel.GetFrameBorderStyle( i.first ), i.second );
1018 aBoxItem.SetRemoveAdjacentCellBorder( mbRemoveAdjacentCellBorders );
1019 // border hor/ver and TableFlag
1021 std::pair<svx::FrameBorderType,SvxBoxInfoItemLine> eTypes2[] = {
1022 { svx::FrameBorderType::Horizontal,SvxBoxInfoItemLine::HORI },
1023 { svx::FrameBorderType::Vertical,SvxBoxInfoItemLine::VERT }
1025 for (std::pair<svx::FrameBorderType,SvxBoxInfoItemLine> const & j : eTypes2)
1026 aBoxInfoItem.SetLine( m_aFrameSel.GetFrameBorderStyle( j.first ), j.second );
1028 aBoxInfoItem.EnableHor( mbHorEnabled );
1029 aBoxInfoItem.EnableVer( mbVerEnabled );
1032 // inner distance
1034 if (m_xLeftMF->get_visible())
1036 // #i40405# enable distance controls for next dialog call
1037 aBoxInfoItem.SetDist( true );
1039 if( !mbUseMarginItem )
1041 // #106224# all edits empty: do nothing
1042 if( !m_xLeftMF->get_text().isEmpty() || !m_xRightMF->get_text().isEmpty() ||
1043 !m_xTopMF->get_text().isEmpty() || !m_xBottomMF->get_text().isEmpty() )
1045 const SvxBoxInfoItem* pOldBoxInfoItem = GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_INNER );
1046 if (
1047 !pOldBoxItem ||
1048 m_xLeftMF->get_value_changed_from_saved() ||
1049 m_xRightMF->get_value_changed_from_saved() ||
1050 m_xTopMF->get_value_changed_from_saved() ||
1051 m_xBottomMF->get_value_changed_from_saved() ||
1052 nMinValue == m_xLeftMF->get_value(FieldUnit::NONE) ||
1053 nMinValue == m_xRightMF->get_value(FieldUnit::NONE) ||
1054 nMinValue == m_xTopMF->get_value(FieldUnit::NONE) ||
1055 nMinValue == m_xBottomMF->get_value(FieldUnit::NONE) ||
1056 (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::DISTANCE))
1059 aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xLeftMF, eCoreUnit )), SvxBoxItemLine::LEFT );
1060 aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xRightMF, eCoreUnit )), SvxBoxItemLine::RIGHT );
1061 aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xTopMF, eCoreUnit )), SvxBoxItemLine::TOP );
1062 aBoxItem.SetDistance( static_cast<sal_uInt16>(GetCoreValue(*m_xBottomMF, eCoreUnit )), SvxBoxItemLine::BOTTOM);
1064 else
1066 aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::LEFT ), SvxBoxItemLine::LEFT);
1067 aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT);
1068 aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::TOP ), SvxBoxItemLine::TOP);
1069 aBoxItem.SetDistance(pOldBoxItem->GetDistance(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM);
1071 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
1077 // note Don't Care Status in the Info-Item:
1079 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::TOP, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Top ) != svx::FrameBorderState::DontCare );
1080 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Bottom ) != svx::FrameBorderState::DontCare );
1081 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::LEFT, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Left ) != svx::FrameBorderState::DontCare );
1082 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::RIGHT, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Right ) != svx::FrameBorderState::DontCare );
1083 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::HORI, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Horizontal ) != svx::FrameBorderState::DontCare );
1084 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::VERT, m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Vertical ) != svx::FrameBorderState::DontCare );
1087 // Put or Clear of the border?
1089 bPut = true;
1091 if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxWhich, false ))
1093 bPut = aBoxItem != static_cast<const SvxBoxItem&>(rOldSet.Get(nBoxWhich));
1095 if( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, false ) )
1097 const SvxBoxInfoItem& rOldBoxInfo = static_cast<const SvxBoxInfoItem&>(
1098 rOldSet.Get(nBoxInfoWhich));
1100 aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
1101 aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
1102 bPut |= (aBoxInfoItem != rOldBoxInfo );
1105 if ( bPut )
1107 if ( !pOldBoxItem || *pOldBoxItem != aBoxItem )
1109 rCoreAttrs->Put( aBoxItem );
1110 bAttrsChanged = true;
1112 const SfxPoolItem* pOld = GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_INNER, false );
1114 if ( !pOld || *static_cast<const SvxBoxInfoItem*>(pOld) != aBoxInfoItem )
1116 rCoreAttrs->Put( aBoxInfoItem );
1117 bAttrsChanged = true;
1120 else
1122 rCoreAttrs->ClearItem( nBoxWhich );
1123 rCoreAttrs->ClearItem( nBoxInfoWhich );
1126 return bAttrsChanged;
1129 void SvxBorderTabPage::HideShadowControls()
1131 m_xShadowFrame->hide();
1134 #define IID_PRE_CELL_NONE 1
1135 #define IID_PRE_CELL_ALL 2
1136 #define IID_PRE_CELL_LR 3
1137 #define IID_PRE_CELL_TB 4
1138 #define IID_PRE_CELL_L 5
1139 #define IID_PRE_CELL_DIAG 6
1140 #define IID_PRE_HOR_NONE 7
1141 #define IID_PRE_HOR_OUTER 8
1142 #define IID_PRE_HOR_HOR 9
1143 #define IID_PRE_HOR_ALL 10
1144 #define IID_PRE_HOR_OUTER2 11
1145 #define IID_PRE_VER_NONE 12
1146 #define IID_PRE_VER_OUTER 13
1147 #define IID_PRE_VER_VER 14
1148 #define IID_PRE_VER_ALL 15
1149 #define IID_PRE_VER_OUTER2 16
1150 #define IID_PRE_TABLE_NONE 17
1151 #define IID_PRE_TABLE_OUTER 18
1152 #define IID_PRE_TABLE_OUTERH 19
1153 #define IID_PRE_TABLE_ALL 20
1154 #define IID_PRE_TABLE_OUTER2 21
1156 IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl, ValueSet*, void)
1158 const svx::FrameBorderState SHOW = svx::FrameBorderState::Show;
1159 const svx::FrameBorderState HIDE = svx::FrameBorderState::Hide;
1160 const svx::FrameBorderState DONT = svx::FrameBorderState::DontCare;
1162 static const svx::FrameBorderState ppeStates[][ svx::FRAMEBORDERTYPE_COUNT ] =
1163 { /* Left Right Top Bot Hor Ver TLBR BLTR */
1164 /* ---------------------+--------------------------------------------------- */
1165 /* IID_PRE_CELL_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1166 /* IID_PRE_CELL_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1167 /* IID_PRE_CELL_LR */ { SHOW, SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1168 /* IID_PRE_CELL_TB */ { HIDE, HIDE, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1169 /* IID_PRE_CELL_L */ { SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1170 /* IID_PRE_CELL_DIAG */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, SHOW, SHOW },
1171 /* IID_PRE_HOR_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1172 /* IID_PRE_HOR_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1173 /* IID_PRE_HOR_HOR */ { HIDE, HIDE, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
1174 /* IID_PRE_HOR_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
1175 /* IID_PRE_HOR_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, HIDE, HIDE, HIDE },
1176 /* IID_PRE_VER_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1177 /* IID_PRE_VER_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1178 /* IID_PRE_VER_VER */ { SHOW, SHOW, HIDE, HIDE, HIDE, SHOW, HIDE, HIDE },
1179 /* IID_PRE_VER_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, SHOW, HIDE, HIDE },
1180 /* IID_PRE_VER_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, HIDE, DONT, HIDE, HIDE },
1181 /* IID_PRE_TABLE_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
1182 /* IID_PRE_TABLE_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
1183 /* IID_PRE_TABLE_OUTERH */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
1184 /* IID_PRE_TABLE_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE },
1185 /* IID_PRE_TABLE_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, DONT, HIDE, HIDE }
1188 // first hide and deselect all frame borders
1189 m_aFrameSel.HideAllBorders();
1190 m_aFrameSel.DeselectAllBorders();
1192 // Using image ID to find correct line in table above.
1193 sal_uInt16 nLine = GetPresetImageId( m_xWndPresets->GetSelectedItemId() ) - 1;
1195 // Apply all styles from the table
1196 for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
1198 svx::FrameBorderType eBorder = svx::GetFrameBorderTypeFromIndex( nBorder );
1199 switch( ppeStates[ nLine ][ nBorder ] )
1201 case SHOW: m_aFrameSel.SelectBorder( eBorder ); break;
1202 case HIDE: /* nothing to do */ break;
1203 case DONT: m_aFrameSel.SetBorderDontCare( eBorder ); break;
1207 // Show all lines that have been selected above
1208 if( m_aFrameSel.IsAnyBorderSelected() )
1210 // any visible style, but "no-line" in line list box? -> use hair-line
1211 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
1212 m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
1214 // set current style to all previously selected lines
1215 SelStyleHdl_Impl(*m_xLbLineStyle);
1216 SelColHdl_Impl(*m_xLbLineColor);
1219 // Presets ValueSet does not show a selection (used as push buttons).
1220 m_xWndPresets->SetNoSelection();
1222 LinesChanged_Impl( nullptr );
1223 UpdateRemoveAdjCellBorderCB( nLine + 1 );
1226 IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl, ValueSet*, void)
1228 bool bEnable = m_xWndShadows->GetSelectedItemId() > 1;
1229 m_xFtShadowSize->set_sensitive(bEnable);
1230 m_xEdShadowSize->set_sensitive(bEnable);
1231 m_xFtShadowColor->set_sensitive(bEnable);
1232 m_xLbShadowColor->set_sensitive(bEnable);
1235 IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void)
1237 NamedColor aNamedColor = rColorBox.GetSelectedEntry();
1238 m_aFrameSel.SetColorToSelection(aNamedColor.m_aColor, aNamedColor.getComplexColor());
1241 IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void)
1243 sal_Int32 nPos = m_xLineWidthLB->get_active();
1244 sal_Int32 nRemovedType = 0;
1245 if (m_xLineWidthLB->get_values_changed_from_saved()) {
1246 nRemovedType = m_aLineWidths.size() - m_xLineWidthLB->get_count();
1249 SetLineWidth(m_aLineWidths[nPos + nRemovedType], nRemovedType);
1251 // Call the spinner handler to trigger all related modifications
1252 ModifyWidthMFHdl_Impl(*m_xLineWidthMF);
1255 IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void)
1257 sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
1259 // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt
1260 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
1261 m_xLineWidthMF->set_min(110, FieldUnit::NONE);
1262 else
1263 m_xLineWidthMF->set_min(5, FieldUnit::NONE);
1265 nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1266 nVal,
1267 m_xLineWidthMF->get_digits(),
1268 FieldUnit::POINT, MapUnit::MapTwip ));
1269 m_xLbLineStyle->SetWidth( nVal );
1271 m_aFrameSel.SetStyleToSelection( nVal,
1272 m_xLbLineStyle->GetSelectEntryStyle() );
1275 IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void)
1277 sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE);
1279 // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt
1280 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
1281 m_xLineWidthMF->set_min(110, FieldUnit::NONE);
1282 else
1283 m_xLineWidthMF->set_min(5, FieldUnit::NONE);
1285 nOldWidth = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1286 nOldWidth,
1287 m_xLineWidthMF->get_digits(),
1288 FieldUnit::POINT,
1289 MapUnit::MapTwip));
1291 const sal_Int64 nOldMinWidth = lcl_GetMinLineWidth(m_aFrameSel.getCurrentStyleLineStyle());
1292 const sal_Int64 nNewMinWidth = lcl_GetMinLineWidth(m_xLbLineStyle->GetSelectEntryStyle());
1294 // auto change line-width if it doesn't correspond to minimal value
1295 // let's change only in case when user has not changed the line-width into some custom value
1296 sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth) ? nNewMinWidth : nOldWidth;
1298 // if we had selected a predefined border width under SvxBorderLineWidth::Medium set the Medium as default
1299 // otherwise if we had a custom border width under 1.10pt then set the spinner to the maximum allowed value for double border styles
1300 bool bNewDoubleHairline = m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN && !m_xLineWidthMF->get_visible() &&
1301 (nOldWidth == SvxBorderLineWidth::Hairline || nOldWidth == SvxBorderLineWidth::VeryThin || nOldWidth == SvxBorderLineWidth::Thin);
1302 if (bNewDoubleHairline && nNewWidth < SvxBorderLineWidth::Medium)
1303 nNewWidth = SvxBorderLineWidth::Medium;
1305 // set value inside edit box
1306 if (nOldWidth != nNewWidth)
1308 const sal_Int64 nNewWidthPt = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1309 nNewWidth,
1310 m_xLineWidthMF->get_digits(),
1311 MapUnit::MapTwip,
1312 FieldUnit::POINT));
1313 SetLineWidth(nNewWidthPt);
1316 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
1318 for (size_t i = 0; i < 3; i++)
1320 m_xLineWidthLB->save_values_by_id(OUString::number(i));
1321 m_xLineWidthLB->remove_id(OUString::number(i));
1323 if (m_xLineWidthLB->get_active_id().isEmpty())
1324 m_xLineWidthLB->set_active_id("3");
1326 else
1328 if (m_xLineWidthLB->get_values_changed_from_saved())
1330 for (size_t i = 0; i < 3; i++)
1331 m_xLineWidthLB->append(i, OUString::number(i), m_xLineWidthLB->get_saved_values(i));
1332 m_xLineWidthLB->removeSavedValues();
1336 // set value inside style box
1337 m_aFrameSel.SetStyleToSelection( nNewWidth,
1338 m_xLbLineStyle->GetSelectEntryStyle() );
1342 // ValueSet handling
1343 sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
1345 // table with all sets of predefined border styles
1346 static const sal_uInt16 ppnImgIds[][ BORDER_PRESET_COUNT ] =
1348 // simple cell without diagonal frame borders
1349 { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_L },
1350 // simple cell with diagonal frame borders
1351 { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_DIAG },
1352 // with horizontal inner frame border
1353 { IID_PRE_HOR_NONE, IID_PRE_HOR_OUTER, IID_PRE_HOR_HOR, IID_PRE_HOR_ALL, IID_PRE_HOR_OUTER2 },
1354 // with vertical inner frame border
1355 { IID_PRE_VER_NONE, IID_PRE_VER_OUTER, IID_PRE_VER_VER, IID_PRE_VER_ALL, IID_PRE_VER_OUTER2 },
1356 // with horizontal and vertical inner frame borders
1357 { IID_PRE_TABLE_NONE, IID_PRE_TABLE_OUTER, IID_PRE_TABLE_OUTERH, IID_PRE_TABLE_ALL, IID_PRE_TABLE_OUTER2 }
1360 // find correct set of presets
1361 int nLine = 0;
1362 if( !mbHorEnabled && !mbVerEnabled )
1363 nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
1364 else if( mbHorEnabled && !mbVerEnabled )
1365 nLine = 2;
1366 else if( !mbHorEnabled && mbVerEnabled )
1367 nLine = 3;
1368 else
1369 nLine = 4;
1371 DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= BORDER_PRESET_COUNT),
1372 "SvxBorderTabPage::GetPresetImageId - wrong index" );
1373 return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
1376 TranslateId SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
1378 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
1379 static const TranslateId pnStrIds[] =
1381 RID_SVXSTR_TABLE_PRESET_NONE,
1382 RID_SVXSTR_PARA_PRESET_ALL,
1383 RID_SVXSTR_PARA_PRESET_LEFTRIGHT,
1384 RID_SVXSTR_PARA_PRESET_TOPBOTTOM,
1385 RID_SVXSTR_PARA_PRESET_ONLYLEFT,
1386 RID_SVXSTR_PARA_PRESET_DIAGONAL,
1388 RID_SVXSTR_TABLE_PRESET_NONE,
1389 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1390 RID_SVXSTR_HOR_PRESET_ONLYHOR,
1391 RID_SVXSTR_TABLE_PRESET_OUTERALL,
1392 RID_SVXSTR_TABLE_PRESET_OUTERINNER,
1394 RID_SVXSTR_TABLE_PRESET_NONE,
1395 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1396 RID_SVXSTR_VER_PRESET_ONLYVER,
1397 RID_SVXSTR_TABLE_PRESET_OUTERALL,
1398 RID_SVXSTR_TABLE_PRESET_OUTERINNER,
1400 RID_SVXSTR_TABLE_PRESET_NONE,
1401 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1402 RID_SVXSTR_TABLE_PRESET_OUTERHORI,
1403 RID_SVXSTR_TABLE_PRESET_OUTERALL,
1404 RID_SVXSTR_TABLE_PRESET_OUTERINNER
1406 return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
1409 void SvxBorderTabPage::FillPresetVS()
1411 // basic initialization of the ValueSet
1412 m_xWndPresets->SetStyle( m_xWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1413 m_xWndPresets->SetColCount( BORDER_PRESET_COUNT );
1415 // insert images and help texts
1416 for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_PRESET_COUNT; ++nVSIdx )
1418 m_xWndPresets->InsertItem( nVSIdx );
1419 m_xWndPresets->SetItemImage(nVSIdx, m_aBorderImgVec[GetPresetImageId(nVSIdx) - 1]);
1420 m_xWndPresets->SetItemText( nVSIdx, SvxResId( GetPresetStringId( nVSIdx ) ) );
1423 // show the control
1424 m_xWndPresets->SetNoSelection();
1425 m_xWndPresets->SetOptimalSize();
1426 m_xWndPresets->Show();
1429 void SvxBorderTabPage::FillShadowVS()
1431 // basic initialization of the ValueSet
1432 m_xWndShadows->SetStyle( m_xWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1433 m_xWndShadows->SetColCount( BORDER_SHADOW_COUNT );
1435 // string resource IDs for each image
1436 static const TranslateId pnStrIds[ BORDER_SHADOW_COUNT ] =
1437 { RID_CUISTR_SHADOW_STYLE_NONE, RID_CUISTR_SHADOW_STYLE_BOTTOMRIGHT, RID_CUISTR_SHADOW_STYLE_TOPRIGHT, RID_CUISTR_SHADOW_STYLE_BOTTOMLEFT, RID_CUISTR_SHADOW_STYLE_TOPLEFT };
1439 // insert images and help texts
1440 for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_SHADOW_COUNT; ++nVSIdx )
1442 m_xWndShadows->InsertItem( nVSIdx );
1443 m_xWndShadows->SetItemImage(nVSIdx, m_aShadowImgVec[nVSIdx-1]);
1444 m_xWndShadows->SetItemText( nVSIdx, CuiResId( pnStrIds[ nVSIdx - 1 ] ) );
1447 // show the control
1448 m_xWndShadows->SelectItem( 1 );
1449 m_xWndShadows->SetOptimalSize();
1450 m_xWndShadows->Show();
1454 void SvxBorderTabPage::FillValueSets()
1456 FillPresetVS();
1457 FillShadowVS();
1460 void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth, sal_Int32 nRemovedType )
1462 if ( nWidth >= 0 )
1463 m_xLineWidthMF->set_value( nWidth, FieldUnit::POINT );
1465 auto it = std::find_if( m_aLineWidths.begin(), m_aLineWidths.end(),
1466 [nWidth](const int val) -> bool { return val == nWidth; } );
1468 if ( it != m_aLineWidths.end() && *it >= 0 )
1470 // Select predefined value in combobox
1471 m_xLineWidthMF->hide();
1472 m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it) - nRemovedType);
1474 else
1476 // This is not one of predefined values. Show spinner
1477 m_xLineWidthLB->set_active(m_aLineWidths.size() - nRemovedType -1);
1478 m_xLineWidthMF->show();
1482 static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1484 return SvxBorderLine::threeDMediumColor( aMain );
1487 void SvxBorderTabPage::FillLineListBox_Impl()
1489 using namespace ::com::sun::star::table::BorderLineStyle;
1491 static struct {
1492 SvxBorderLineStyle mnStyle;
1493 SvtLineListBox::ColorFunc mpColor1Fn;
1494 SvtLineListBox::ColorFunc mpColor2Fn;
1495 SvtLineListBox::ColorDistFunc mpColorDistFn;
1496 } const aLines[] = {
1497 // Simple lines
1498 { SvxBorderLineStyle::SOLID, &sameColor, &sameColor, &sameDistColor },
1499 { SvxBorderLineStyle::DOTTED, &sameColor, &sameColor, &sameDistColor },
1500 { SvxBorderLineStyle::DASHED, &sameColor, &sameColor, &sameDistColor },
1501 { SvxBorderLineStyle::FINE_DASHED, &sameColor, &sameColor, &sameDistColor },
1502 { SvxBorderLineStyle::DASH_DOT, &sameColor, &sameColor, &sameDistColor },
1503 { SvxBorderLineStyle::DASH_DOT_DOT, &sameColor, &sameColor, &sameDistColor },
1505 // Double lines
1506 { SvxBorderLineStyle::DOUBLE, &sameColor, &sameColor, &sameDistColor },
1507 { SvxBorderLineStyle::DOUBLE_THIN, &sameColor, &sameColor, &sameDistColor },
1508 { SvxBorderLineStyle::THINTHICK_SMALLGAP, &sameColor, &sameColor, &sameDistColor },
1509 { SvxBorderLineStyle::THINTHICK_MEDIUMGAP, &sameColor, &sameColor, &sameDistColor },
1510 { SvxBorderLineStyle::THINTHICK_LARGEGAP, &sameColor, &sameColor, &sameDistColor },
1511 { SvxBorderLineStyle::THICKTHIN_SMALLGAP, &sameColor, &sameColor, &sameDistColor },
1512 { SvxBorderLineStyle::THICKTHIN_MEDIUMGAP, &sameColor, &sameColor, &sameDistColor },
1513 { SvxBorderLineStyle::THICKTHIN_LARGEGAP, &sameColor, &sameColor, &sameDistColor },
1515 { SvxBorderLineStyle::EMBOSSED, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor },
1516 { SvxBorderLineStyle::ENGRAVED, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor },
1518 { SvxBorderLineStyle::OUTSET, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor },
1519 { SvxBorderLineStyle::INSET, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor }
1522 m_xLbLineStyle->SetSourceUnit( FieldUnit::TWIP );
1524 for (size_t i = 0; i < std::size(aLines); ++i)
1526 if (!IsBorderLineStyleAllowed(aLines[i].mnStyle))
1527 continue;
1529 m_xLbLineStyle->InsertEntry(
1530 SvxBorderLine::getWidthImpl(aLines[i].mnStyle),
1531 aLines[i].mnStyle,
1532 lcl_GetMinLineWidth(aLines[i].mnStyle),
1533 aLines[i].mpColor1Fn,
1534 aLines[i].mpColor2Fn,
1535 aLines[i].mpColorDistFn);
1538 sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
1539 nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue(nVal, m_xLineWidthMF->get_digits(),
1540 m_xLineWidthMF->get_unit(), MapUnit::MapTwip));
1541 m_xLbLineStyle->SetWidth( nVal );
1545 IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl, LinkParamNone*, void)
1547 if (!mbUseMarginItem && m_xLeftMF->get_visible())
1549 bool bLineSet = m_aFrameSel.IsAnyBorderVisible();
1550 bool bSpaceModified = mbLeftModified ||
1551 mbRightModified ||
1552 mbTopModified ||
1553 mbBottomModified;
1555 if(bLineSet)
1557 if(!bSpaceModified)
1559 m_xLeftMF->set_value(nMinValue, FieldUnit::NONE);
1560 m_xRightMF->set_value(nMinValue, FieldUnit::NONE);
1561 m_xTopMF->set_value(nMinValue, FieldUnit::NONE);
1562 m_xBottomMF->set_value(nMinValue, FieldUnit::NONE);
1565 else
1567 m_xLeftMF->set_min(0, FieldUnit::NONE);
1568 m_xRightMF->set_min(0, FieldUnit::NONE);
1569 m_xTopMF->set_min(0, FieldUnit::NONE);
1570 m_xBottomMF->set_min(0, FieldUnit::NONE);
1572 // for tables everything is allowed
1573 SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::TOP|SvxBoxInfoItemValidFlags::BOTTOM|SvxBoxInfoItemValidFlags::LEFT|SvxBoxInfoItemValidFlags::RIGHT;
1575 m_xLeftFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::LEFT) );
1576 m_xRightFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::RIGHT) );
1577 m_xTopFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::TOP) );
1578 m_xBottomFT->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::BOTTOM) );
1579 m_xLeftMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::LEFT) );
1580 m_xRightMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::RIGHT) );
1581 m_xTopMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::TOP) );
1582 m_xBottomMF->set_sensitive( bool(nValid & SvxBoxInfoItemValidFlags::BOTTOM) );
1583 m_xSynchronizeCB->set_sensitive(m_xRightMF->get_sensitive() || m_xTopMF->get_sensitive() ||
1584 m_xBottomMF->get_sensitive() || m_xLeftMF->get_sensitive());
1586 UpdateRemoveAdjCellBorderCB( SAL_MAX_UINT16 );
1590 IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, weld::MetricSpinButton&, rField, void)
1592 if (&rField == m_xLeftMF.get())
1593 mbLeftModified = true;
1594 else if (&rField == m_xRightMF.get())
1595 mbRightModified = true;
1596 else if (&rField == m_xTopMF.get())
1597 mbTopModified = true;
1598 else if (&rField == m_xBottomMF.get())
1599 mbBottomModified = true;
1601 if (mbSync)
1603 const auto nVal = rField.get_value(FieldUnit::NONE);
1604 if (&rField != m_xLeftMF.get())
1605 m_xLeftMF->set_value(nVal, FieldUnit::NONE);
1606 if (&rField != m_xRightMF.get())
1607 m_xRightMF->set_value(nVal, FieldUnit::NONE);
1608 if (&rField != m_xTopMF.get())
1609 m_xTopMF->set_value(nVal, FieldUnit::NONE);
1610 if (&rField != m_xBottomMF.get())
1611 m_xBottomMF->set_value(nVal, FieldUnit::NONE);
1615 IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, weld::Toggleable&, rBox, void)
1617 mbSync = rBox.get_active();
1620 IMPL_LINK( SvxBorderTabPage, RemoveAdjacentCellBorderHdl_Impl, weld::Toggleable&, rBox, void)
1622 mbRemoveAdjacentCellBorders = rBox.get_active();
1625 void SvxBorderTabPage::UpdateRemoveAdjCellBorderCB( sal_uInt16 nPreset )
1627 if( !bIsCalcDoc )
1628 return;
1629 const SfxItemSet& rOldSet = GetItemSet();
1630 const SvxBoxInfoItem* pOldBoxInfoItem = GetOldItem( rOldSet, SID_ATTR_BORDER_INNER );
1631 const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( rOldSet, mnBoxSlot ));
1632 if( !pOldBoxInfoItem || !pOldBoxItem )
1633 return;
1634 std::pair<svx::FrameBorderType, SvxBoxInfoItemValidFlags> eTypes1[] = {
1635 { svx::FrameBorderType::Top,SvxBoxInfoItemValidFlags::TOP },
1636 { svx::FrameBorderType::Bottom,SvxBoxInfoItemValidFlags::BOTTOM },
1637 { svx::FrameBorderType::Left,SvxBoxInfoItemValidFlags::LEFT },
1638 { svx::FrameBorderType::Right,SvxBoxInfoItemValidFlags::RIGHT },
1640 SvxBoxItemLine const eTypes2[] = {
1641 SvxBoxItemLine::TOP,
1642 SvxBoxItemLine::BOTTOM,
1643 SvxBoxItemLine::LEFT,
1644 SvxBoxItemLine::RIGHT,
1647 // Check if current selection involves deletion of at least one border
1648 bool bBorderDeletionReq = false;
1649 for ( size_t i=0; i < std::size( eTypes1 ); ++i )
1651 if( pOldBoxItem->GetLine( eTypes2[i] ) || !( pOldBoxInfoItem->IsValid( eTypes1[i].second ) ) )
1653 if( m_aFrameSel.GetFrameBorderState( eTypes1[i].first ) == svx::FrameBorderState::Hide )
1655 bBorderDeletionReq = true;
1656 break;
1661 if( !bBorderDeletionReq && ( nPreset == IID_PRE_CELL_NONE || nPreset == IID_PRE_TABLE_NONE ) )
1662 bBorderDeletionReq = true;
1664 m_xRemoveAdjacentCellBordersCB->set_sensitive(bBorderDeletionReq);
1666 if( !bBorderDeletionReq )
1668 mbRemoveAdjacentCellBorders = false;
1669 m_xRemoveAdjacentCellBordersCB->set_active(false);
1673 void SvxBorderTabPage::PageCreated(const SfxAllItemSet& aSet)
1675 const SfxUInt16Item* pSWModeItem = aSet.GetItem<SfxUInt16Item>(SID_SWMODE_TYPE, false);
1676 const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
1677 if (pSWModeItem)
1679 nSWMode = static_cast<SwBorderModes>(pSWModeItem->GetValue());
1680 // #i43593#
1681 // show checkbox <m_xMergeWithNextCB> for format.paragraph
1682 if ( nSWMode == SwBorderModes::PARA )
1684 m_xMergeWithNextCB->show();
1685 m_xPropertiesFrame->show();
1687 // show checkbox <m_xMergeAdjacentBordersCB> for format.paragraph
1688 else if ( nSWMode == SwBorderModes::TABLE )
1690 m_xMergeAdjacentBordersCB->show();
1691 m_xPropertiesFrame->show();
1694 if (pFlagItem)
1695 if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1696 HideShadowControls();
1699 void SvxBorderTabPage::SetTableMode()
1701 nSWMode = SwBorderModes::TABLE;
1704 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */