1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
;
57 * TabPage for setting the border attributes.
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(
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
>);
81 constexpr int twipsToPt100(sal_Int64 nTwips
)
83 return o3tl::convert(nTwips
* 100, o3tl::Length::twip
, o3tl::Length::pt
);
85 constexpr int s_LineWidths
[] = { twipsToPt100(SvxBorderLineWidth::Hairline
),
86 twipsToPt100(SvxBorderLineWidth::VeryThin
),
87 twipsToPt100(SvxBorderLineWidth::Thin
),
88 twipsToPt100(SvxBorderLineWidth::Medium
),
89 twipsToPt100(SvxBorderLineWidth::Thick
),
90 twipsToPt100(SvxBorderLineWidth::ExtraThick
),
94 static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton
& rField
)
96 auto nMin
= rField
.denormalize(rField
.get_min(FieldUnit::TWIP
));
98 rField
.set_min(rField
.normalize(nMin
), FieldUnit::TWIP
);
102 static sal_Int64
lcl_GetMinLineWidth(SvxBorderLineStyle aStyle
)
106 case SvxBorderLineStyle::NONE
:
109 case SvxBorderLineStyle::SOLID
:
110 case SvxBorderLineStyle::DOTTED
:
111 case SvxBorderLineStyle::DASHED
:
112 case SvxBorderLineStyle::FINE_DASHED
:
113 case SvxBorderLineStyle::DASH_DOT
:
114 case SvxBorderLineStyle::DASH_DOT_DOT
:
118 case SvxBorderLineStyle::DOUBLE
: return 15;
119 case SvxBorderLineStyle::DOUBLE_THIN
: return 15;
120 case SvxBorderLineStyle::THINTHICK_SMALLGAP
: return 20;
121 case SvxBorderLineStyle::THINTHICK_MEDIUMGAP
: return 15;
122 case SvxBorderLineStyle::THINTHICK_LARGEGAP
: return 15;
123 case SvxBorderLineStyle::THICKTHIN_SMALLGAP
: return 20;
124 case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP
: return 15;
125 case SvxBorderLineStyle::THICKTHIN_LARGEGAP
: return 15;
127 case SvxBorderLineStyle::EMBOSSED
: return 15;
128 case SvxBorderLineStyle::ENGRAVED
: return 15;
130 case SvxBorderLineStyle::OUTSET
: return 10;
131 case SvxBorderLineStyle::INSET
: return 10;
138 // number of preset images to show
139 const sal_uInt16 BORDER_PRESET_COUNT
= 5;
141 // number of shadow images to show
142 const sal_uInt16 BORDER_SHADOW_COUNT
= 5;
144 ShadowControlsWrapper::ShadowControlsWrapper(ValueSet
& rVsPos
, weld::MetricSpinButton
& rMfSize
, ColorListBox
& rLbColor
)
147 , mrLbColor(rLbColor
)
151 SvxShadowItem
ShadowControlsWrapper::GetControlValue(const SvxShadowItem
& rItem
) const
153 SvxShadowItem
aItem(rItem
);
154 if (!mrVsPos
.IsNoSelection())
156 switch (mrVsPos
.GetSelectedItemId())
159 aItem
.SetLocation(SvxShadowLocation::NONE
);
162 aItem
.SetLocation(SvxShadowLocation::BottomRight
);
165 aItem
.SetLocation(SvxShadowLocation::TopRight
);
168 aItem
.SetLocation(SvxShadowLocation::BottomLeft
);
171 aItem
.SetLocation(SvxShadowLocation::TopLeft
);
174 aItem
.SetLocation(SvxShadowLocation::NONE
);
178 // Default value was saved; so don't change the aItem's width if the control
179 // has not changed its value, to avoid round-trip errors (like twip->cm->twip)
180 // E.g., initial 100 twip will become 0.18 cm, which will return as 102 twip
181 if (mrMfSize
.get_value_changed_from_saved())
182 aItem
.SetWidth(mrMfSize
.denormalize(mrMfSize
.get_value(FieldUnit::TWIP
)));
183 if (!mrLbColor
.IsNoSelection())
184 aItem
.SetColor(mrLbColor
.GetSelectEntryColor());
188 void ShadowControlsWrapper::SetControlValue(const SvxShadowItem
& rItem
)
190 switch (rItem
.GetLocation())
192 case SvxShadowLocation::NONE
:
193 mrVsPos
.SelectItem(1);
195 case SvxShadowLocation::BottomRight
:
196 mrVsPos
.SelectItem(2);
198 case SvxShadowLocation::TopRight
:
199 mrVsPos
.SelectItem(3);
201 case SvxShadowLocation::BottomLeft
:
202 mrVsPos
.SelectItem(4);
204 case SvxShadowLocation::TopLeft
:
205 mrVsPos
.SelectItem(5);
208 mrVsPos
.SetNoSelection();
212 mrMfSize
.set_value(mrMfSize
.normalize(rItem
.GetWidth()), FieldUnit::TWIP
);
213 mrMfSize
.save_value();
214 mrLbColor
.SelectEntry(rItem
.GetColor());
215 mrLbColor
.SaveValue();
218 bool ShadowControlsWrapper::get_value_changed_from_saved() const
220 return mrVsPos
.IsValueChangedFromSaved() ||
221 mrMfSize
.get_value_changed_from_saved() ||
222 mrLbColor
.IsValueChangedFromSaved();
225 void ShadowControlsWrapper::SetControlDontKnow()
227 mrVsPos
.SetNoSelection();
228 mrMfSize
.set_text(u
""_ustr
);
229 mrLbColor
.SetNoSelection();
232 MarginControlsWrapper::MarginControlsWrapper(weld::MetricSpinButton
& rMfLeft
, weld::MetricSpinButton
& rMfRight
,
233 weld::MetricSpinButton
& rMfTop
, weld::MetricSpinButton
& rMfBottom
)
235 , mrRightWrp(rMfRight
)
237 , mrBottomWrp(rMfBottom
)
241 SvxMarginItem
MarginControlsWrapper::GetControlValue(const SvxMarginItem
&rItem
) const
243 SvxMarginItem
aItem(rItem
);
244 if (mrLeftWrp
.get_sensitive())
245 aItem
.SetLeftMargin(mrLeftWrp
.denormalize(mrLeftWrp
.get_value(FieldUnit::TWIP
)));
246 if (mrRightWrp
.get_sensitive())
247 aItem
.SetRightMargin(mrRightWrp
.denormalize(mrRightWrp
.get_value(FieldUnit::TWIP
)));
248 if (mrTopWrp
.get_sensitive())
249 aItem
.SetTopMargin(mrTopWrp
.denormalize(mrTopWrp
.get_value(FieldUnit::TWIP
)));
250 if (mrBottomWrp
.get_sensitive())
251 aItem
.SetBottomMargin(mrBottomWrp
.denormalize(mrBottomWrp
.get_value(FieldUnit::TWIP
)));
255 bool MarginControlsWrapper::get_value_changed_from_saved() const
257 return mrLeftWrp
.get_value_changed_from_saved() ||
258 mrRightWrp
.get_value_changed_from_saved() ||
259 mrTopWrp
.get_value_changed_from_saved() ||
260 mrBottomWrp
.get_value_changed_from_saved();
263 void MarginControlsWrapper::SetControlValue(const SvxMarginItem
& rItem
)
265 mrLeftWrp
.set_value(mrLeftWrp
.normalize(rItem
.GetLeftMargin()), FieldUnit::TWIP
);
266 mrRightWrp
.set_value(mrRightWrp
.normalize(rItem
.GetRightMargin()), FieldUnit::TWIP
);
267 mrTopWrp
.set_value(mrTopWrp
.normalize(rItem
.GetTopMargin()), FieldUnit::TWIP
);
268 mrBottomWrp
.set_value(mrBottomWrp
.normalize(rItem
.GetBottomMargin()), FieldUnit::TWIP
);
269 mrLeftWrp
.save_value();
270 mrRightWrp
.save_value();
271 mrTopWrp
.save_value();
272 mrBottomWrp
.save_value();
275 void MarginControlsWrapper::SetControlDontKnow()
277 const OUString sEmpty
;
278 mrLeftWrp
.set_text(sEmpty
);
279 mrRightWrp
.set_text(sEmpty
);
280 mrTopWrp
.set_text(sEmpty
);
281 mrBottomWrp
.set_text(sEmpty
);
284 SvxBorderTabPage::SvxBorderTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
285 : SfxTabPage(pPage
, pController
, u
"cui/ui/borderpage.ui"_ustr
, u
"BorderPage"_ustr
, &rCoreAttrs
)
287 , nSWMode(SwBorderModes::NONE
)
288 , mnBoxSlot(SID_ATTR_BORDER_OUTER
)
289 , mnShadowSlot(SID_ATTR_BORDER_SHADOW
)
290 , mbHorEnabled(false)
291 , mbVerEnabled(false)
292 , mbTLBREnabled(false)
293 , mbBLTREnabled(false)
294 , mbUseMarginItem(false)
295 , mbLeftModified(false)
296 , mbRightModified(false)
297 , mbTopModified(false)
298 , mbBottomModified(false)
300 , mbRemoveAdjacentCellBorders(false)
302 , m_xWndPresets(new ValueSet(nullptr))
303 , m_xWndPresetsWin(new weld::CustomWeld(*m_xBuilder
, u
"presets"_ustr
, *m_xWndPresets
))
304 , m_xUserDefFT(m_xBuilder
->weld_label(u
"userdefft"_ustr
))
305 , m_xFrameSelWin(new weld::CustomWeld(*m_xBuilder
, u
"framesel"_ustr
, m_aFrameSel
))
306 , m_xLbLineStyle(new SvtLineListBox(m_xBuilder
->weld_menu_button(u
"linestylelb"_ustr
)))
307 , m_xLbLineColor(new ColorListBox(m_xBuilder
->weld_menu_button(u
"linecolorlb"_ustr
),
308 [this]{ return GetDialogController()->getDialog(); }))
309 , m_xLineWidthLB(m_xBuilder
->weld_combo_box(u
"linewidthlb"_ustr
))
310 , m_xLineWidthMF(m_xBuilder
->weld_metric_spin_button(u
"linewidthmf"_ustr
, FieldUnit::POINT
))
311 , m_xSpacingFrame(m_xBuilder
->weld_container(u
"spacing"_ustr
))
312 , m_xLeftFT(m_xBuilder
->weld_label(u
"leftft"_ustr
))
313 , m_xLeftMF(m_xBuilder
->weld_metric_spin_button(u
"leftmf"_ustr
, FieldUnit::MM
))
314 , m_xRightFT(m_xBuilder
->weld_label(u
"rightft"_ustr
))
315 , m_xRightMF(m_xBuilder
->weld_metric_spin_button(u
"rightmf"_ustr
, FieldUnit::MM
))
316 , m_xTopFT(m_xBuilder
->weld_label(u
"topft"_ustr
))
317 , m_xTopMF(m_xBuilder
->weld_metric_spin_button(u
"topmf"_ustr
, FieldUnit::MM
))
318 , m_xBottomFT(m_xBuilder
->weld_label(u
"bottomft"_ustr
))
319 , m_xBottomMF(m_xBuilder
->weld_metric_spin_button(u
"bottommf"_ustr
, FieldUnit::MM
))
320 , m_xSynchronizeCB(m_xBuilder
->weld_check_button(u
"sync"_ustr
))
321 , m_xShadowFrame(m_xBuilder
->weld_container(u
"shadow"_ustr
))
322 , m_xWndShadows(new ValueSet(nullptr))
323 , m_xWndShadowsWin(new weld::CustomWeld(*m_xBuilder
, u
"shadows"_ustr
, *m_xWndShadows
))
324 , m_xFtShadowSize(m_xBuilder
->weld_label(u
"distanceft"_ustr
))
325 , m_xEdShadowSize(m_xBuilder
->weld_metric_spin_button(u
"distancemf"_ustr
, FieldUnit::MM
))
326 , m_xFtShadowColor(m_xBuilder
->weld_label(u
"shadowcolorft"_ustr
))
327 , m_xLbShadowColor(new ColorListBox(m_xBuilder
->weld_menu_button(u
"shadowcolorlb"_ustr
),
328 [this]{ return GetDialogController()->getDialog(); }))
329 , m_xPropertiesFrame(m_xBuilder
->weld_container(u
"properties"_ustr
))
330 , m_xMergeWithNextCB(m_xBuilder
->weld_check_button(u
"mergewithnext"_ustr
))
331 , m_xMergeAdjacentBordersCB(m_xBuilder
->weld_check_button(u
"mergeadjacent"_ustr
))
332 , m_xRemoveAdjacentCellBordersCB(m_xBuilder
->weld_check_button(u
"rmadjcellborders"_ustr
))
333 , m_xRemoveAdjacentCellBordersFT(m_xBuilder
->weld_label(u
"rmadjcellbordersft"_ustr
))
335 static std::vector
<OUString
> aBorderImageIds
;
337 if (aBorderImageIds
.empty())
339 if (comphelper::LibreOfficeKit::isActive())
341 aBorderImageIds
.insert(aBorderImageIds
.end(), {
342 RID_SVXBMP_CELL_NONE_32
,
343 RID_SVXBMP_CELL_ALL_32
,
344 RID_SVXBMP_CELL_LR_32
,
345 RID_SVXBMP_CELL_TB_32
,
346 RID_SVXBMP_CELL_L_32
,
347 RID_SVXBMP_CELL_DIAG_32
352 aBorderImageIds
.insert(aBorderImageIds
.end(), {
353 RID_SVXBMP_CELL_NONE
,
361 aBorderImageIds
.insert(aBorderImageIds
.end(), {
363 RID_SVXBMP_HOR_OUTER
,
366 RID_SVXBMP_HOR_OUTER2
,
368 RID_SVXBMP_VER_OUTER
,
371 RID_SVXBMP_VER_OUTER2
,
372 RID_SVXBMP_TABLE_NONE
,
373 RID_SVXBMP_TABLE_OUTER
,
374 RID_SVXBMP_TABLE_OUTERH
,
375 RID_SVXBMP_TABLE_ALL
,
376 RID_SVXBMP_TABLE_OUTER2
380 for (auto const & rImageId
: aBorderImageIds
)
381 m_aBorderImgVec
.emplace_back(StockImage::Yes
, rImageId
);
383 static std::vector
<OUString
> aShadowImageIds
;
384 if (aShadowImageIds
.empty())
386 if (comphelper::LibreOfficeKit::isActive())
388 aShadowImageIds
.insert(aShadowImageIds
.end(), {
389 RID_SVXBMP_SHADOWNONE_32
,
390 RID_SVXBMP_SHADOW_BOT_RIGHT_32
,
391 RID_SVXBMP_SHADOW_TOP_RIGHT_32
,
392 RID_SVXBMP_SHADOW_BOT_LEFT_32
,
393 RID_SVXBMP_SHADOW_TOP_LEFT_32
398 aShadowImageIds
.insert(aShadowImageIds
.end(), {
399 RID_SVXBMP_SHADOWNONE
,
400 RID_SVXBMP_SHADOW_BOT_RIGHT
,
401 RID_SVXBMP_SHADOW_TOP_RIGHT
,
402 RID_SVXBMP_SHADOW_BOT_LEFT
,
403 RID_SVXBMP_SHADOW_TOP_LEFT
408 for (auto const & rImageId
: aShadowImageIds
)
409 m_aShadowImgVec
.emplace_back(StockImage::Yes
, rImageId
);
411 assert(m_aShadowImgVec
.size() == BORDER_SHADOW_COUNT
);
413 // this page needs ExchangeSupport
414 SetExchangeSupport();
416 /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
417 -> Remember this state in mbUseMarginItem, because other special handling
418 is needed across various functions... */
419 mbUseMarginItem
= rCoreAttrs
.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN
)) != SfxItemState::UNKNOWN
;
421 if (const SfxIntegerListItem
* p
= rCoreAttrs
.GetItemIfSet(SID_ATTR_BORDER_STYLES
))
423 std::vector
<sal_Int32
> aUsedStyles
= p
->GetList();
424 for (int aUsedStyle
: aUsedStyles
)
425 maUsedBorderStyles
.insert(static_cast<SvxBorderLineStyle
>(aUsedStyle
));
428 if (const SfxInt64Item
* p
= rCoreAttrs
.GetItemIfSet(SID_ATTR_BORDER_DEFAULT_WIDTH
))
430 // The caller specifies default line width. Honor it.
431 SetLineWidth(p
->GetValue());
435 FieldUnit eFUnit
= GetModuleFieldUnit( rCoreAttrs
);
437 if( mbUseMarginItem
)
439 // copied from SvxAlignmentTabPage
442 // #103396# the default value (1pt) can't be accurately represented in
443 // inches or pica with two decimals, so point is used instead.
444 case FieldUnit::PICA
:
445 case FieldUnit::INCH
:
446 case FieldUnit::FOOT
:
447 case FieldUnit::MILE
:
448 eFUnit
= FieldUnit::POINT
;
454 eFUnit
= FieldUnit::MM
;
456 default: ;//prevent warning
465 eFUnit
= FieldUnit::MM
;
467 default: ; //prevent warning
471 SetFieldUnit(*m_xEdShadowSize
, eFUnit
);
473 sal_uInt16 nWhich
= GetWhich( SID_ATTR_BORDER_INNER
, false );
474 bool bIsDontCare
= true;
476 if ( rCoreAttrs
.GetItemState( nWhich
) >= SfxItemState::DEFAULT
)
478 // paragraph or table
479 const SvxBoxInfoItem
* pBoxInfo
=
480 static_cast<const SvxBoxInfoItem
*>(&( rCoreAttrs
.Get( nWhich
) ));
482 mbHorEnabled
= pBoxInfo
->IsHorEnabled();
483 mbVerEnabled
= pBoxInfo
->IsVerEnabled();
484 mbTLBREnabled
= rCoreAttrs
.GetItemState(GetWhich(SID_ATTR_BORDER_DIAG_TLBR
)) != SfxItemState::UNKNOWN
;
485 mbBLTREnabled
= rCoreAttrs
.GetItemState(GetWhich(SID_ATTR_BORDER_DIAG_BLTR
)) != SfxItemState::UNKNOWN
;
487 if(pBoxInfo
->IsDist())
489 SetFieldUnit(*m_xLeftMF
, eFUnit
);
490 SetFieldUnit(*m_xRightMF
, eFUnit
);
491 SetFieldUnit(*m_xTopMF
, eFUnit
);
492 SetFieldUnit(*m_xBottomMF
, eFUnit
);
493 m_xSynchronizeCB
->connect_toggled(LINK(this, SvxBorderTabPage
, SyncHdl_Impl
));
494 m_xLeftMF
->connect_value_changed(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
495 m_xRightMF
->connect_value_changed(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
496 m_xTopMF
->connect_value_changed(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
497 m_xBottomMF
->connect_value_changed(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
501 m_xSpacingFrame
->hide();
503 bIsDontCare
= !pBoxInfo
->IsValid( SvxBoxInfoItemValidFlags::DISABLE
);
505 if(!mbUseMarginItem
&& eFUnit
== FieldUnit::MM
&& MapUnit::MapTwip
== rCoreAttrs
.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER
) ))
507 //#i91548# changing the number of decimal digits changes the minimum values, too
508 lcl_SetDecimalDigitsTo1(*m_xLeftMF
);
509 lcl_SetDecimalDigitsTo1(*m_xRightMF
);
510 lcl_SetDecimalDigitsTo1(*m_xTopMF
);
511 lcl_SetDecimalDigitsTo1(*m_xBottomMF
);
512 lcl_SetDecimalDigitsTo1(*m_xEdShadowSize
);
515 FrameSelFlags nFlags
= FrameSelFlags::Outer
;
517 nFlags
|= FrameSelFlags::InnerHorizontal
;
519 nFlags
|= FrameSelFlags::InnerVertical
;
521 nFlags
|= FrameSelFlags::DiagonalTLBR
;
523 nFlags
|= FrameSelFlags::DiagonalBLTR
;
525 nFlags
|= FrameSelFlags::DontCare
;
526 m_aFrameSel
.Initialize( nFlags
);
528 m_aFrameSel
.SetSelectHdl(LINK(this, SvxBorderTabPage
, LinesChanged_Impl
));
529 m_xLbLineStyle
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelStyleHdl_Impl
) );
530 m_xLbLineColor
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelColHdl_Impl
) );
531 m_xLineWidthLB
->connect_changed(LINK(this, SvxBorderTabPage
, ModifyWidthLBHdl_Impl
));
532 m_xLineWidthMF
->connect_value_changed(LINK(this, SvxBorderTabPage
, ModifyWidthMFHdl_Impl
));
533 m_xWndPresets
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelPreHdl_Impl
) );
534 m_xWndShadows
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelSdwHdl_Impl
) );
537 FillLineListBox_Impl();
539 // Reapply line width: probably one of predefined values should be selected
540 SetLineWidth(m_xLineWidthMF
->get_value(FieldUnit::NONE
));
543 const SfxPoolItem
* pItem
= nullptr;
544 if (rCoreAttrs
.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG
), &pItem
))
546 const SfxGrabBagItem
* pGrabBag
= static_cast<const SfxGrabBagItem
*>(pItem
);
547 auto it
= pGrabBag
->GetGrabBag().find(u
"DialogUseCharAttr"_ustr
);
548 if (it
!= pGrabBag
->GetGrabBag().end())
550 bool bDialogUseCharAttr
= false;
551 it
->second
>>= bDialogUseCharAttr
;
552 if (bDialogUseCharAttr
)
554 mnShadowSlot
= SID_ATTR_CHAR_SHADOW
;
555 mnBoxSlot
= SID_ATTR_CHAR_BOX
;
560 bool bSupportsShadow
= !SfxItemPool::IsSlot(GetWhich(mnShadowSlot
));
561 if( bSupportsShadow
)
562 m_xShadowControls
.reset(new ShadowControlsWrapper(*m_xWndShadows
, *m_xEdShadowSize
, *m_xLbShadowColor
));
564 HideShadowControls();
567 m_xMarginControls
.reset(new MarginControlsWrapper(*m_xLeftMF
, *m_xRightMF
, *m_xTopMF
, *m_xBottomMF
));
569 // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
570 m_xMergeWithNextCB
->hide();
571 // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
572 m_xMergeAdjacentBordersCB
->hide();
574 if (SfxObjectShell
* pDocSh
= SfxObjectShell::Current())
576 Reference
< XServiceInfo
> xSI( pDocSh
->GetModel(), UNO_QUERY
);
578 bIsCalcDoc
= xSI
->supportsService(u
"com.sun.star.sheet.SpreadsheetDocument"_ustr
);
582 m_xRemoveAdjacentCellBordersCB
->connect_toggled(LINK(this, SvxBorderTabPage
, RemoveAdjacentCellBorderHdl_Impl
));
583 m_xRemoveAdjacentCellBordersCB
->show();
584 m_xRemoveAdjacentCellBordersCB
->set_sensitive(false);
588 m_xRemoveAdjacentCellBordersCB
->hide();
589 m_xRemoveAdjacentCellBordersFT
->hide();
593 SvxBorderTabPage::~SvxBorderTabPage()
595 m_xLbShadowColor
.reset();
596 m_xWndShadowsWin
.reset();
597 m_xWndShadows
.reset();
598 m_xLbLineColor
.reset();
599 m_xLbLineStyle
.reset();
600 m_xFrameSelWin
.reset();
601 m_xWndPresetsWin
.reset();
602 m_xWndPresets
.reset();
605 std::unique_ptr
<SfxTabPage
> SvxBorderTabPage::Create( weld::Container
* pPage
, weld::DialogController
* pController
,
606 const SfxItemSet
* rAttrSet
)
608 return std::make_unique
<SvxBorderTabPage
>(pPage
, pController
, *rAttrSet
);
611 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder
, const SvxBorderLine
* pCoreLine
, bool bValid
)
613 if( m_aFrameSel
.IsBorderEnabled( eBorder
) )
616 m_aFrameSel
.ShowBorder( eBorder
, pCoreLine
);
618 m_aFrameSel
.SetBorderDontCare( eBorder
);
622 bool SvxBorderTabPage::IsBorderLineStyleAllowed( SvxBorderLineStyle nStyle
) const
624 if (maUsedBorderStyles
.empty())
625 // All border styles are allowed.
628 return maUsedBorderStyles
.count(nStyle
) > 0;
631 void SvxBorderTabPage::Reset( const SfxItemSet
* rSet
)
633 SfxItemPool
* pPool
= rSet
->GetPool();
635 if (m_aFrameSel
.IsBorderEnabled(svx::FrameBorderType::TLBR
))
637 sal_uInt16 nBorderDiagId
= pPool
->GetWhichIDFromSlotID(SID_ATTR_BORDER_DIAG_TLBR
);
638 if (const SvxLineItem
* pLineItem
= static_cast<const SvxLineItem
*>(rSet
->GetItem(nBorderDiagId
)))
639 m_aFrameSel
.ShowBorder(svx::FrameBorderType::TLBR
, pLineItem
->GetLine());
641 m_aFrameSel
.SetBorderDontCare(svx::FrameBorderType::TLBR
);
644 if (m_aFrameSel
.IsBorderEnabled(svx::FrameBorderType::BLTR
))
646 sal_uInt16 nBorderDiagId
= pPool
->GetWhichIDFromSlotID(SID_ATTR_BORDER_DIAG_BLTR
);
647 if (const SvxLineItem
* pLineItem
= static_cast<const SvxLineItem
*>(rSet
->GetItem(nBorderDiagId
)))
648 m_aFrameSel
.ShowBorder(svx::FrameBorderType::BLTR
, pLineItem
->GetLine());
650 m_aFrameSel
.SetBorderDontCare(svx::FrameBorderType::BLTR
);
653 if (m_xShadowControls
)
655 sal_uInt16 nShadowId
= pPool
->GetWhichIDFromSlotID(mnShadowSlot
);
656 const SfxPoolItem
* pItem
= rSet
->GetItem(nShadowId
);
658 m_xShadowControls
->SetControlValue(*static_cast<const SvxShadowItem
*>(pItem
));
660 m_xShadowControls
->SetControlDontKnow();
663 if (m_xMarginControls
)
665 sal_uInt16 nAlignMarginId
= pPool
->GetWhichIDFromSlotID(SID_ATTR_ALIGN_MARGIN
);
666 const SfxPoolItem
* pItem
= rSet
->GetItem(nAlignMarginId
);
668 m_xMarginControls
->SetControlValue(*static_cast<const SvxMarginItem
*>(pItem
));
670 m_xMarginControls
->SetControlDontKnow();
673 sal_uInt16 nMergeAdjacentBordersId
= pPool
->GetWhichIDFromSlotID(SID_SW_COLLAPSING_BORDERS
);
674 const SfxBoolItem
*pMergeAdjacentBorders
= static_cast<const SfxBoolItem
*>(rSet
->GetItem(nMergeAdjacentBordersId
));
675 if (!pMergeAdjacentBorders
)
676 m_xMergeAdjacentBordersCB
->set_state(TRISTATE_INDET
);
678 m_xMergeAdjacentBordersCB
->set_active(pMergeAdjacentBorders
->GetValue());
679 m_xMergeAdjacentBordersCB
->save_state();
681 sal_uInt16 nMergeWithNextId
= pPool
->GetWhichIDFromSlotID(SID_ATTR_BORDER_CONNECT
);
682 const SfxBoolItem
*pMergeWithNext
= static_cast<const SfxBoolItem
*>(rSet
->GetItem(nMergeWithNextId
));
684 m_xMergeWithNextCB
->set_state(TRISTATE_INDET
);
686 m_xMergeWithNextCB
->set_active(pMergeWithNext
->GetValue());
687 m_xMergeWithNextCB
->save_state();
689 const SvxBoxItem
* pBoxItem
;
690 const SvxBoxInfoItem
* pBoxInfoItem
;
691 sal_uInt16 nWhichBox
= GetWhich(mnBoxSlot
);
694 pBoxItem
= static_cast<const SvxBoxItem
*>(GetItem( *rSet
, mnBoxSlot
));
696 pBoxInfoItem
= GetItem( *rSet
, SID_ATTR_BORDER_INNER
, false );
698 eCoreUnit
= pPool
->GetMetric( nWhichBox
);
700 if ( pBoxItem
&& pBoxInfoItem
) // -> Don't Care
702 ResetFrameLine_Impl( svx::FrameBorderType::Left
, pBoxItem
->GetLeft(), pBoxInfoItem
->IsValid( SvxBoxInfoItemValidFlags::LEFT
) );
703 ResetFrameLine_Impl( svx::FrameBorderType::Right
, pBoxItem
->GetRight(), pBoxInfoItem
->IsValid( SvxBoxInfoItemValidFlags::RIGHT
) );
704 ResetFrameLine_Impl( svx::FrameBorderType::Top
, pBoxItem
->GetTop(), pBoxInfoItem
->IsValid( SvxBoxInfoItemValidFlags::TOP
) );
705 ResetFrameLine_Impl( svx::FrameBorderType::Bottom
, pBoxItem
->GetBottom(), pBoxInfoItem
->IsValid( SvxBoxInfoItemValidFlags::BOTTOM
) );
706 ResetFrameLine_Impl( svx::FrameBorderType::Vertical
, pBoxInfoItem
->GetVert(), pBoxInfoItem
->IsValid( SvxBoxInfoItemValidFlags::VERT
) );
707 ResetFrameLine_Impl( svx::FrameBorderType::Horizontal
, pBoxInfoItem
->GetHori(), pBoxInfoItem
->IsValid( SvxBoxInfoItemValidFlags::HORI
) );
712 if( !mbUseMarginItem
)
714 if (m_xLeftMF
->get_visible())
716 SetMetricValue(*m_xLeftMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
717 SetMetricValue(*m_xRightMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
718 SetMetricValue(*m_xTopMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
719 SetMetricValue(*m_xBottomMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
721 nMinValue
= m_xLeftMF
->get_value(FieldUnit::NONE
);
723 if ( pBoxInfoItem
->IsDist() )
725 if( rSet
->GetItemState( nWhichBox
) >= SfxItemState::DEFAULT
)
727 bool bIsAnyBorderVisible
= m_aFrameSel
.IsAnyBorderVisible();
728 if( !bIsAnyBorderVisible
|| !pBoxInfoItem
->IsMinDist() )
730 m_xLeftMF
->set_min(0, FieldUnit::NONE
);
731 m_xRightMF
->set_min(0, FieldUnit::NONE
);
732 m_xTopMF
->set_min(0, FieldUnit::NONE
);
733 m_xBottomMF
->set_min(0, FieldUnit::NONE
);
735 tools::Long nLeftDist
= pBoxItem
->GetDistance( SvxBoxItemLine::LEFT
);
736 SetMetricValue(*m_xLeftMF
, nLeftDist
, eCoreUnit
);
737 tools::Long nRightDist
= pBoxItem
->GetDistance( SvxBoxItemLine::RIGHT
);
738 SetMetricValue(*m_xRightMF
, nRightDist
, eCoreUnit
);
739 tools::Long nTopDist
= pBoxItem
->GetDistance( SvxBoxItemLine::TOP
);
740 SetMetricValue( *m_xTopMF
, nTopDist
, eCoreUnit
);
741 tools::Long nBottomDist
= pBoxItem
->GetDistance( SvxBoxItemLine::BOTTOM
);
742 SetMetricValue( *m_xBottomMF
, nBottomDist
, eCoreUnit
);
744 // if the distance is set with no active border line
745 // or it is null with an active border line
746 // no automatic changes should be made
747 const tools::Long nDefDist
= bIsAnyBorderVisible
? pBoxInfoItem
->GetDefDist() : 0;
748 bool bDiffDist
= (nDefDist
!= nLeftDist
||
749 nDefDist
!= nRightDist
||
750 nDefDist
!= nTopDist
||
751 nDefDist
!= nBottomDist
);
752 if ((pBoxItem
->GetSmallestDistance() || bIsAnyBorderVisible
) && bDiffDist
)
754 mbLeftModified
= true;
755 mbRightModified
= true;
756 mbTopModified
= true;
757 mbBottomModified
= true;
762 // #106224# different margins -> do not fill the edits
763 m_xLeftMF
->set_text( OUString() );
764 m_xRightMF
->set_text( OUString() );
765 m_xTopMF
->set_text( OUString() );
766 m_xBottomMF
->set_text( OUString() );
769 m_xLeftMF
->save_value();
770 m_xRightMF
->save_value();
771 m_xTopMF
->save_value();
772 m_xBottomMF
->save_value();
778 // avoid ResetFrameLine-calls:
779 m_aFrameSel
.HideAllBorders();
782 if( !m_aFrameSel
.IsAnyBorderVisible() )
783 m_aFrameSel
.DeselectAllBorders();
785 // depict line (color) in controllers if unambiguous:
788 // Do all visible lines show the same line widths?
790 SvxBorderLineStyle nStyle
;
791 bool bWidthEq
= m_aFrameSel
.GetVisibleWidth( nWidth
, nStyle
);
794 // Determine the width first as some styles can be missing depending on it
795 sal_Int64 nWidthPt
= static_cast<sal_Int64
>(vcl::ConvertDoubleValue(
796 sal_Int64( nWidth
), m_xLineWidthMF
->get_digits(),
797 MapUnit::MapTwip
, FieldUnit::POINT
));
798 SetLineWidth(nWidthPt
);
799 m_xLbLineStyle
->SetWidth(nWidth
);
801 // then set the style
802 m_xLbLineStyle
->SelectEntry( nStyle
);
805 m_xLbLineStyle
->SelectEntry(SvxBorderLineStyle::SOLID
);
807 // Do all visible lines show the same line color?
809 bool bColorEq
= m_aFrameSel
.GetVisibleColor( aColor
);
813 m_xLbLineColor
->SelectEntry(aColor
);
814 auto nTextColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor();
815 m_xLbLineStyle
->SetColor(nTextColor
);
817 // Select all visible lines, if they are all equal.
818 if( bWidthEq
&& bColorEq
)
819 m_aFrameSel
.SelectAllVisibleBorders();
821 // set the current style and color (caches style in control even if nothing is selected)
822 SelStyleHdl_Impl(*m_xLbLineStyle
);
823 SelColHdl_Impl(*m_xLbLineColor
);
826 bool bEnable
= m_xWndShadows
->GetSelectedItemId() > 1 ;
827 m_xFtShadowSize
->set_sensitive(bEnable
);
828 m_xEdShadowSize
->set_sensitive(bEnable
);
829 m_xFtShadowColor
->set_sensitive(bEnable
);
830 m_xLbShadowColor
->set_sensitive(bEnable
);
832 m_xWndPresets
->SetNoSelection();
834 // - no line - should not be selected
836 if (m_xLbLineStyle
->GetSelectEntryStyle() == SvxBorderLineStyle::NONE
)
838 m_xLbLineStyle
->SelectEntry(SvxBorderLineStyle::SOLID
);
839 SelStyleHdl_Impl(*m_xLbLineStyle
);
842 const SfxUInt16Item
* pHtmlModeItem
= rSet
->GetItemIfSet(SID_HTML_MODE
, false);
845 if (SfxObjectShell
* pShell
= SfxObjectShell::Current())
846 pHtmlModeItem
= pShell
->GetItem(SID_HTML_MODE
);
850 sal_uInt16 nHtmlMode
= pHtmlModeItem
->GetValue();
851 if(nHtmlMode
& HTMLMODE_ON
)
853 // there are no shadows in Html-mode and only complete borders
854 m_xShadowFrame
->set_sensitive(false);
856 if( !(nSWMode
& SwBorderModes::TABLE
) )
858 m_xUserDefFT
->set_sensitive(false);
859 m_xFrameSelWin
->set_sensitive(false);
860 m_xWndPresets
->RemoveItem(3);
861 m_xWndPresets
->RemoveItem(4);
862 m_xWndPresets
->RemoveItem(5);
867 LinesChanged_Impl( nullptr );
868 if (m_xLeftMF
->get_value(FieldUnit::NONE
) == m_xRightMF
->get_value(FieldUnit::NONE
) &&
869 m_xTopMF
->get_value(FieldUnit::NONE
) == m_xBottomMF
->get_value(FieldUnit::NONE
) &&
870 m_xTopMF
->get_value(FieldUnit::NONE
) == m_xLeftMF
->get_value(FieldUnit::NONE
))
876 m_xSynchronizeCB
->set_active(mbSync
);
878 mbRemoveAdjacentCellBorders
= false;
879 m_xRemoveAdjacentCellBordersCB
->set_active(false);
880 m_xRemoveAdjacentCellBordersCB
->set_sensitive(false);
883 void SvxBorderTabPage::ChangesApplied()
885 m_xLeftMF
->save_value();
886 m_xRightMF
->save_value();
887 m_xTopMF
->save_value();
888 m_xBottomMF
->save_value();
889 m_xMergeWithNextCB
->save_state();
890 m_xMergeAdjacentBordersCB
->save_state();
893 DeactivateRC
SvxBorderTabPage::DeactivatePage( SfxItemSet
* _pSet
)
896 FillItemSet( _pSet
);
898 return DeactivateRC::LeavePage
;
901 bool SvxBorderTabPage::FillItemSet( SfxItemSet
* rCoreAttrs
)
903 bool bAttrsChanged
= false;
905 SfxItemPool
* pPool
= rCoreAttrs
->GetPool();
907 if (m_aFrameSel
.IsBorderEnabled(svx::FrameBorderType::TLBR
) &&
908 m_aFrameSel
.GetFrameBorderState(svx::FrameBorderType::TLBR
) != svx::FrameBorderState::DontCare
)
910 if (const SfxPoolItem
* pOldItem
= GetOldItem(*rCoreAttrs
, SID_ATTR_BORDER_DIAG_TLBR
))
912 SvxLineItem
aLineItem(*static_cast<const SvxLineItem
*>(pOldItem
));
913 aLineItem
.SetLine(m_aFrameSel
.GetFrameBorderStyle(svx::FrameBorderType::TLBR
));
914 rCoreAttrs
->Put(aLineItem
);
915 bAttrsChanged
= true;
919 if (m_aFrameSel
.IsBorderEnabled(svx::FrameBorderType::BLTR
) &&
920 m_aFrameSel
.GetFrameBorderState(svx::FrameBorderType::BLTR
) != svx::FrameBorderState::DontCare
)
922 if (const SfxPoolItem
* pOldItem
= GetOldItem(*rCoreAttrs
, SID_ATTR_BORDER_DIAG_BLTR
))
924 SvxLineItem
aLineItem(*static_cast<const SvxLineItem
*>(pOldItem
));
925 aLineItem
.SetLine(m_aFrameSel
.GetFrameBorderStyle(svx::FrameBorderType::BLTR
));
926 rCoreAttrs
->Put(aLineItem
);
927 bAttrsChanged
= true;
931 if (m_xShadowControls
&& m_xShadowControls
->get_value_changed_from_saved())
933 if (const SfxPoolItem
* pOldItem
= GetOldItem(*rCoreAttrs
, mnShadowSlot
))
935 const SvxShadowItem
& rOldShadowItem
= *static_cast<const SvxShadowItem
*>(pOldItem
);
936 rCoreAttrs
->Put(m_xShadowControls
->GetControlValue(rOldShadowItem
));
937 bAttrsChanged
= true;
941 if (m_xMarginControls
&& m_xMarginControls
->get_value_changed_from_saved())
943 if (const SfxPoolItem
* pOldItem
= GetOldItem(*rCoreAttrs
, SID_ATTR_ALIGN_MARGIN
))
945 const SvxMarginItem
& rOldMarginItem
= *static_cast<const SvxMarginItem
*>(pOldItem
);
946 rCoreAttrs
->Put(m_xMarginControls
->GetControlValue(rOldMarginItem
));
947 bAttrsChanged
= true;
951 if (m_xMergeAdjacentBordersCB
->get_state_changed_from_saved())
953 auto nState
= m_xMergeAdjacentBordersCB
->get_state();
954 if (nState
== TRISTATE_INDET
)
956 sal_uInt16 nMergeAdjacentBordersId
= pPool
->GetWhichIDFromSlotID(SID_SW_COLLAPSING_BORDERS
);
957 rCoreAttrs
->ClearItem(nMergeAdjacentBordersId
);
961 if (const SfxPoolItem
* pOldItem
= GetOldItem(*rCoreAttrs
, SID_SW_COLLAPSING_BORDERS
))
963 std::unique_ptr
<SfxBoolItem
> xNewItem(static_cast<SfxBoolItem
*>(pOldItem
->Clone()));
964 xNewItem
->SetValue(static_cast<bool>(nState
));
965 rCoreAttrs
->Put(std::move(xNewItem
));
968 bAttrsChanged
= true;
971 if (m_xMergeWithNextCB
->get_state_changed_from_saved())
973 auto nState
= m_xMergeWithNextCB
->get_state();
974 if (nState
== TRISTATE_INDET
)
976 sal_uInt16 nMergeWithNextId
= pPool
->GetWhichIDFromSlotID(SID_ATTR_BORDER_CONNECT
);
977 rCoreAttrs
->ClearItem(nMergeWithNextId
);
981 if (const SfxPoolItem
* pOldItem
= GetOldItem(*rCoreAttrs
, SID_ATTR_BORDER_CONNECT
))
983 std::unique_ptr
<SfxBoolItem
> xNewItem(static_cast<SfxBoolItem
*>(pOldItem
->Clone()));
984 xNewItem
->SetValue(static_cast<bool>(nState
));
985 rCoreAttrs
->Put(std::move(xNewItem
));
988 bAttrsChanged
= true;
992 sal_uInt16 nBoxWhich
= GetWhich( mnBoxSlot
);
993 sal_uInt16 nBoxInfoWhich
= pPool
->GetWhichIDFromSlotID( SID_ATTR_BORDER_INNER
, false );
994 const SfxItemSet
& rOldSet
= GetItemSet();
995 SvxBoxItem
aBoxItem ( nBoxWhich
);
996 SvxBoxInfoItem
aBoxInfoItem ( nBoxInfoWhich
);
997 const SvxBoxItem
* pOldBoxItem
= static_cast<const SvxBoxItem
*>(GetOldItem( *rCoreAttrs
, mnBoxSlot
));
999 MapUnit eCoreUnit
= rOldSet
.GetPool()->GetMetric( nBoxWhich
);
1004 std::pair
<svx::FrameBorderType
,SvxBoxItemLine
> eTypes1
[] = {
1005 { svx::FrameBorderType::Top
,SvxBoxItemLine::TOP
},
1006 { svx::FrameBorderType::Bottom
,SvxBoxItemLine::BOTTOM
},
1007 { svx::FrameBorderType::Left
,SvxBoxItemLine::LEFT
},
1008 { svx::FrameBorderType::Right
,SvxBoxItemLine::RIGHT
},
1011 for (std::pair
<svx::FrameBorderType
,SvxBoxItemLine
> const & i
: eTypes1
)
1012 aBoxItem
.SetLine( m_aFrameSel
.GetFrameBorderStyle( i
.first
), i
.second
);
1015 aBoxItem
.SetRemoveAdjacentCellBorder( mbRemoveAdjacentCellBorders
);
1016 // border hor/ver and TableFlag
1018 std::pair
<svx::FrameBorderType
,SvxBoxInfoItemLine
> eTypes2
[] = {
1019 { svx::FrameBorderType::Horizontal
,SvxBoxInfoItemLine::HORI
},
1020 { svx::FrameBorderType::Vertical
,SvxBoxInfoItemLine::VERT
}
1022 for (std::pair
<svx::FrameBorderType
,SvxBoxInfoItemLine
> const & j
: eTypes2
)
1023 aBoxInfoItem
.SetLine( m_aFrameSel
.GetFrameBorderStyle( j
.first
), j
.second
);
1025 aBoxInfoItem
.EnableHor( mbHorEnabled
);
1026 aBoxInfoItem
.EnableVer( mbVerEnabled
);
1031 if (m_xLeftMF
->get_visible())
1033 // #i40405# enable distance controls for next dialog call
1034 aBoxInfoItem
.SetDist( true );
1036 if( !mbUseMarginItem
)
1038 // #106224# all edits empty: do nothing
1039 if( !m_xLeftMF
->get_text().isEmpty() || !m_xRightMF
->get_text().isEmpty() ||
1040 !m_xTopMF
->get_text().isEmpty() || !m_xBottomMF
->get_text().isEmpty() )
1042 const SvxBoxInfoItem
* pOldBoxInfoItem
= GetOldItem( *rCoreAttrs
, SID_ATTR_BORDER_INNER
);
1045 m_xLeftMF
->get_value_changed_from_saved() ||
1046 m_xRightMF
->get_value_changed_from_saved() ||
1047 m_xTopMF
->get_value_changed_from_saved() ||
1048 m_xBottomMF
->get_value_changed_from_saved() ||
1049 nMinValue
== m_xLeftMF
->get_value(FieldUnit::NONE
) ||
1050 nMinValue
== m_xRightMF
->get_value(FieldUnit::NONE
) ||
1051 nMinValue
== m_xTopMF
->get_value(FieldUnit::NONE
) ||
1052 nMinValue
== m_xBottomMF
->get_value(FieldUnit::NONE
) ||
1053 (pOldBoxInfoItem
&& !pOldBoxInfoItem
->IsValid(SvxBoxInfoItemValidFlags::DISTANCE
))
1056 aBoxItem
.SetDistance( static_cast<sal_uInt16
>(GetCoreValue(*m_xLeftMF
, eCoreUnit
)), SvxBoxItemLine::LEFT
);
1057 aBoxItem
.SetDistance( static_cast<sal_uInt16
>(GetCoreValue(*m_xRightMF
, eCoreUnit
)), SvxBoxItemLine::RIGHT
);
1058 aBoxItem
.SetDistance( static_cast<sal_uInt16
>(GetCoreValue(*m_xTopMF
, eCoreUnit
)), SvxBoxItemLine::TOP
);
1059 aBoxItem
.SetDistance( static_cast<sal_uInt16
>(GetCoreValue(*m_xBottomMF
, eCoreUnit
)), SvxBoxItemLine::BOTTOM
);
1063 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(SvxBoxItemLine::LEFT
), SvxBoxItemLine::LEFT
);
1064 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(SvxBoxItemLine::RIGHT
), SvxBoxItemLine::RIGHT
);
1065 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(SvxBoxItemLine::TOP
), SvxBoxItemLine::TOP
);
1066 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(SvxBoxItemLine::BOTTOM
), SvxBoxItemLine::BOTTOM
);
1068 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::DISTANCE
);
1074 // note Don't Care Status in the Info-Item:
1076 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::TOP
, m_aFrameSel
.GetFrameBorderState( svx::FrameBorderType::Top
) != svx::FrameBorderState::DontCare
);
1077 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::BOTTOM
, m_aFrameSel
.GetFrameBorderState( svx::FrameBorderType::Bottom
) != svx::FrameBorderState::DontCare
);
1078 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::LEFT
, m_aFrameSel
.GetFrameBorderState( svx::FrameBorderType::Left
) != svx::FrameBorderState::DontCare
);
1079 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::RIGHT
, m_aFrameSel
.GetFrameBorderState( svx::FrameBorderType::Right
) != svx::FrameBorderState::DontCare
);
1080 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::HORI
, m_aFrameSel
.GetFrameBorderState( svx::FrameBorderType::Horizontal
) != svx::FrameBorderState::DontCare
);
1081 aBoxInfoItem
.SetValid( SvxBoxInfoItemValidFlags::VERT
, m_aFrameSel
.GetFrameBorderState( svx::FrameBorderType::Vertical
) != svx::FrameBorderState::DontCare
);
1084 // Put or Clear of the border?
1088 if ( SfxItemState::DEFAULT
== rOldSet
.GetItemState( nBoxWhich
, false ))
1090 bPut
= aBoxItem
!= static_cast<const SvxBoxItem
&>(rOldSet
.Get(nBoxWhich
));
1092 if( SfxItemState::DEFAULT
== rOldSet
.GetItemState( nBoxInfoWhich
, false ) )
1094 const SvxBoxInfoItem
& rOldBoxInfo
= static_cast<const SvxBoxInfoItem
&>(
1095 rOldSet
.Get(nBoxInfoWhich
));
1097 aBoxInfoItem
.SetMinDist( rOldBoxInfo
.IsMinDist() );
1098 aBoxInfoItem
.SetDefDist( rOldBoxInfo
.GetDefDist() );
1099 bPut
|= (aBoxInfoItem
!= rOldBoxInfo
);
1104 if ( !pOldBoxItem
|| *pOldBoxItem
!= aBoxItem
)
1106 rCoreAttrs
->Put( aBoxItem
);
1107 bAttrsChanged
= true;
1109 const SfxPoolItem
* pOld
= GetOldItem( *rCoreAttrs
, SID_ATTR_BORDER_INNER
, false );
1111 if ( !pOld
|| *static_cast<const SvxBoxInfoItem
*>(pOld
) != aBoxInfoItem
)
1113 rCoreAttrs
->Put( aBoxInfoItem
);
1114 bAttrsChanged
= true;
1119 rCoreAttrs
->ClearItem( nBoxWhich
);
1120 rCoreAttrs
->ClearItem( nBoxInfoWhich
);
1123 return bAttrsChanged
;
1126 void SvxBorderTabPage::HideShadowControls()
1128 m_xShadowFrame
->hide();
1131 #define IID_PRE_CELL_NONE 1
1132 #define IID_PRE_CELL_ALL 2
1133 #define IID_PRE_CELL_LR 3
1134 #define IID_PRE_CELL_TB 4
1135 #define IID_PRE_CELL_L 5
1136 #define IID_PRE_CELL_DIAG 6
1137 #define IID_PRE_HOR_NONE 7
1138 #define IID_PRE_HOR_OUTER 8
1139 #define IID_PRE_HOR_HOR 9
1140 #define IID_PRE_HOR_ALL 10
1141 #define IID_PRE_HOR_OUTER2 11
1142 #define IID_PRE_VER_NONE 12
1143 #define IID_PRE_VER_OUTER 13
1144 #define IID_PRE_VER_VER 14
1145 #define IID_PRE_VER_ALL 15
1146 #define IID_PRE_VER_OUTER2 16
1147 #define IID_PRE_TABLE_NONE 17
1148 #define IID_PRE_TABLE_OUTER 18
1149 #define IID_PRE_TABLE_OUTERH 19
1150 #define IID_PRE_TABLE_ALL 20
1151 #define IID_PRE_TABLE_OUTER2 21
1153 IMPL_LINK_NOARG(SvxBorderTabPage
, SelPreHdl_Impl
, ValueSet
*, void)
1155 const svx::FrameBorderState SHOW
= svx::FrameBorderState::Show
;
1156 const svx::FrameBorderState HIDE
= svx::FrameBorderState::Hide
;
1157 const svx::FrameBorderState DONT
= svx::FrameBorderState::DontCare
;
1159 static const svx::FrameBorderState ppeStates
[][ svx::FRAMEBORDERTYPE_COUNT
] =
1160 { /* Left Right Top Bot Hor Ver TLBR BLTR */
1161 /* ---------------------+--------------------------------------------------- */
1162 /* IID_PRE_CELL_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
1163 /* IID_PRE_CELL_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
1164 /* IID_PRE_CELL_LR */ { SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
1165 /* IID_PRE_CELL_TB */ { HIDE
, HIDE
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
1166 /* IID_PRE_CELL_L */ { SHOW
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
1167 /* IID_PRE_CELL_DIAG */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, SHOW
, SHOW
},
1168 /* IID_PRE_HOR_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
1169 /* IID_PRE_HOR_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
1170 /* IID_PRE_HOR_HOR */ { HIDE
, HIDE
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
1171 /* IID_PRE_HOR_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
1172 /* IID_PRE_HOR_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, DONT
, HIDE
, HIDE
, HIDE
},
1173 /* IID_PRE_VER_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
1174 /* IID_PRE_VER_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
1175 /* IID_PRE_VER_VER */ { SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, SHOW
, HIDE
, HIDE
},
1176 /* IID_PRE_VER_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, SHOW
, HIDE
, HIDE
},
1177 /* IID_PRE_VER_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, DONT
, HIDE
, HIDE
},
1178 /* IID_PRE_TABLE_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
1179 /* IID_PRE_TABLE_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
1180 /* IID_PRE_TABLE_OUTERH */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
1181 /* IID_PRE_TABLE_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
},
1182 /* IID_PRE_TABLE_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, DONT
, DONT
, HIDE
, HIDE
}
1185 // first hide and deselect all frame borders
1186 m_aFrameSel
.HideAllBorders();
1187 m_aFrameSel
.DeselectAllBorders();
1189 // Using image ID to find correct line in table above.
1190 sal_uInt16 nLine
= GetPresetImageId( m_xWndPresets
->GetSelectedItemId() ) - 1;
1192 // Apply all styles from the table
1193 for( int nBorder
= 0; nBorder
< svx::FRAMEBORDERTYPE_COUNT
; ++nBorder
)
1195 svx::FrameBorderType eBorder
= svx::GetFrameBorderTypeFromIndex( nBorder
);
1196 switch( ppeStates
[ nLine
][ nBorder
] )
1198 case SHOW
: m_aFrameSel
.SelectBorder( eBorder
); break;
1199 case HIDE
: /* nothing to do */ break;
1200 case DONT
: m_aFrameSel
.SetBorderDontCare( eBorder
); break;
1204 // Show all lines that have been selected above
1205 if( m_aFrameSel
.IsAnyBorderSelected() )
1207 // any visible style, but "no-line" in line list box? -> use hair-line
1208 if (m_xLbLineStyle
->GetSelectEntryStyle() == SvxBorderLineStyle::NONE
)
1209 m_xLbLineStyle
->SelectEntry(SvxBorderLineStyle::SOLID
);
1211 // set current style to all previously selected lines
1212 SelStyleHdl_Impl(*m_xLbLineStyle
);
1213 SelColHdl_Impl(*m_xLbLineColor
);
1216 // Presets ValueSet does not show a selection (used as push buttons).
1217 m_xWndPresets
->SetNoSelection();
1219 LinesChanged_Impl( nullptr );
1220 UpdateRemoveAdjCellBorderCB( nLine
+ 1 );
1223 IMPL_LINK_NOARG(SvxBorderTabPage
, SelSdwHdl_Impl
, ValueSet
*, void)
1225 bool bEnable
= m_xWndShadows
->GetSelectedItemId() > 1;
1226 m_xFtShadowSize
->set_sensitive(bEnable
);
1227 m_xEdShadowSize
->set_sensitive(bEnable
);
1228 m_xFtShadowColor
->set_sensitive(bEnable
);
1229 m_xLbShadowColor
->set_sensitive(bEnable
);
1232 IMPL_LINK(SvxBorderTabPage
, SelColHdl_Impl
, ColorListBox
&, rColorBox
, void)
1234 NamedColor aNamedColor
= rColorBox
.GetSelectedEntry();
1235 m_aFrameSel
.SetColorToSelection(aNamedColor
.m_aColor
, aNamedColor
.getComplexColor());
1238 IMPL_LINK_NOARG(SvxBorderTabPage
, ModifyWidthLBHdl_Impl
, weld::ComboBox
&, void)
1240 sal_Int32 nPos
= m_xLineWidthLB
->get_active();
1241 sal_Int32 nRemovedType
= 0;
1242 if (m_xLineWidthLB
->get_values_changed_from_saved()) {
1243 nRemovedType
= std::size(s_LineWidths
) - m_xLineWidthLB
->get_count();
1246 SetLineWidth(s_LineWidths
[nPos
+ nRemovedType
], nRemovedType
);
1248 // Call the spinner handler to trigger all related modifications
1249 ModifyWidthMFHdl_Impl(*m_xLineWidthMF
);
1252 IMPL_LINK_NOARG(SvxBorderTabPage
, ModifyWidthMFHdl_Impl
, weld::MetricSpinButton
&, void)
1254 sal_Int64 nVal
= m_xLineWidthMF
->get_value(FieldUnit::NONE
);
1256 // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt
1257 if (m_xLbLineStyle
->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN
)
1258 m_xLineWidthMF
->set_min(110, FieldUnit::NONE
);
1260 m_xLineWidthMF
->set_min(5, FieldUnit::NONE
);
1262 nVal
= static_cast<sal_Int64
>(vcl::ConvertDoubleValue(
1264 m_xLineWidthMF
->get_digits(),
1265 FieldUnit::POINT
, MapUnit::MapTwip
));
1266 m_xLbLineStyle
->SetWidth( nVal
);
1268 m_aFrameSel
.SetStyleToSelection( nVal
,
1269 m_xLbLineStyle
->GetSelectEntryStyle() );
1272 IMPL_LINK_NOARG(SvxBorderTabPage
, SelStyleHdl_Impl
, SvtLineListBox
&, void)
1274 sal_Int64 nOldWidth
= m_xLineWidthMF
->get_value(FieldUnit::NONE
);
1276 // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt
1277 if (m_xLbLineStyle
->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN
)
1278 m_xLineWidthMF
->set_min(110, FieldUnit::NONE
);
1280 m_xLineWidthMF
->set_min(5, FieldUnit::NONE
);
1282 nOldWidth
= static_cast<sal_Int64
>(vcl::ConvertDoubleValue(
1284 m_xLineWidthMF
->get_digits(),
1288 const sal_Int64 nOldMinWidth
= lcl_GetMinLineWidth(m_aFrameSel
.getCurrentStyleLineStyle());
1289 const sal_Int64 nNewMinWidth
= lcl_GetMinLineWidth(m_xLbLineStyle
->GetSelectEntryStyle());
1291 // auto change line-width if it doesn't correspond to minimal value
1292 // let's change only in case when user has not changed the line-width into some custom value
1293 sal_Int64 nNewWidth
= (nOldMinWidth
== nOldWidth
) ? nNewMinWidth
: nOldWidth
;
1295 // if we had selected a predefined border width under SvxBorderLineWidth::Medium set the Medium as default
1296 // otherwise if we had a custom border width under 1.10pt then set the spinner to the maximum allowed value for double border styles
1297 bool bNewDoubleHairline
= m_xLbLineStyle
->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN
&& !m_xLineWidthMF
->get_visible() &&
1298 (nOldWidth
== SvxBorderLineWidth::Hairline
|| nOldWidth
== SvxBorderLineWidth::VeryThin
|| nOldWidth
== SvxBorderLineWidth::Thin
);
1299 if (bNewDoubleHairline
&& nNewWidth
< SvxBorderLineWidth::Medium
)
1300 nNewWidth
= SvxBorderLineWidth::Medium
;
1302 // set value inside edit box
1303 if (nOldWidth
!= nNewWidth
)
1305 const sal_Int64 nNewWidthPt
= static_cast<sal_Int64
>(vcl::ConvertDoubleValue(
1307 m_xLineWidthMF
->get_digits(),
1310 SetLineWidth(nNewWidthPt
);
1313 if (m_xLbLineStyle
->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN
)
1315 for (size_t i
= 0; i
< 3; i
++)
1317 m_xLineWidthLB
->save_values_by_id(OUString::number(i
));
1318 m_xLineWidthLB
->remove_id(OUString::number(i
));
1320 if (m_xLineWidthLB
->get_active_id().isEmpty())
1321 m_xLineWidthLB
->set_active_id(u
"3"_ustr
);
1325 if (m_xLineWidthLB
->get_values_changed_from_saved())
1327 for (size_t i
= 0; i
< 3; i
++)
1328 m_xLineWidthLB
->append(i
, OUString::number(i
), m_xLineWidthLB
->get_saved_values(i
));
1329 m_xLineWidthLB
->removeSavedValues();
1333 // set value inside style box
1334 m_aFrameSel
.SetStyleToSelection( nNewWidth
,
1335 m_xLbLineStyle
->GetSelectEntryStyle() );
1339 // ValueSet handling
1340 sal_uInt16
SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx
) const
1342 // table with all sets of predefined border styles
1343 static const sal_uInt16 ppnImgIds
[][ BORDER_PRESET_COUNT
] =
1345 // simple cell without diagonal frame borders
1346 { IID_PRE_CELL_NONE
, IID_PRE_CELL_ALL
, IID_PRE_CELL_LR
, IID_PRE_CELL_TB
, IID_PRE_CELL_L
},
1347 // simple cell with diagonal frame borders
1348 { IID_PRE_CELL_NONE
, IID_PRE_CELL_ALL
, IID_PRE_CELL_LR
, IID_PRE_CELL_TB
, IID_PRE_CELL_DIAG
},
1349 // with horizontal inner frame border
1350 { IID_PRE_HOR_NONE
, IID_PRE_HOR_OUTER
, IID_PRE_HOR_HOR
, IID_PRE_HOR_ALL
, IID_PRE_HOR_OUTER2
},
1351 // with vertical inner frame border
1352 { IID_PRE_VER_NONE
, IID_PRE_VER_OUTER
, IID_PRE_VER_VER
, IID_PRE_VER_ALL
, IID_PRE_VER_OUTER2
},
1353 // with horizontal and vertical inner frame borders
1354 { IID_PRE_TABLE_NONE
, IID_PRE_TABLE_OUTER
, IID_PRE_TABLE_OUTERH
, IID_PRE_TABLE_ALL
, IID_PRE_TABLE_OUTER2
}
1357 // find correct set of presets
1359 if( !mbHorEnabled
&& !mbVerEnabled
)
1360 nLine
= (mbTLBREnabled
|| mbBLTREnabled
) ? 1 : 0;
1361 else if( mbHorEnabled
&& !mbVerEnabled
)
1363 else if( !mbHorEnabled
&& mbVerEnabled
)
1368 DBG_ASSERT( (1 <= nValueSetIdx
) && (nValueSetIdx
<= BORDER_PRESET_COUNT
),
1369 "SvxBorderTabPage::GetPresetImageId - wrong index" );
1370 return ppnImgIds
[ nLine
][ nValueSetIdx
- 1 ];
1373 TranslateId
SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx
) const
1375 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
1376 static const TranslateId pnStrIds
[] =
1378 RID_SVXSTR_TABLE_PRESET_NONE
,
1379 RID_SVXSTR_PARA_PRESET_ALL
,
1380 RID_SVXSTR_PARA_PRESET_ONLYLEFTRIGHT
,
1381 RID_SVXSTR_PARA_PRESET_ONLYTOPBOTTOM
,
1382 RID_SVXSTR_PARA_PRESET_ONLYLEFT
,
1383 RID_SVXSTR_PARA_PRESET_DIAGONAL
,
1385 RID_SVXSTR_TABLE_PRESET_NONE
,
1386 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
1387 RID_SVXSTR_HOR_PRESET_ONLYHOR
,
1388 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
1389 RID_SVXSTR_TABLE_PRESET_OUTERINNER
,
1391 RID_SVXSTR_TABLE_PRESET_NONE
,
1392 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
1393 RID_SVXSTR_VER_PRESET_ONLYVER
,
1394 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
1395 RID_SVXSTR_TABLE_PRESET_OUTERINNER
,
1397 RID_SVXSTR_TABLE_PRESET_NONE
,
1398 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
1399 RID_SVXSTR_TABLE_PRESET_OUTERHORI
,
1400 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
1401 RID_SVXSTR_TABLE_PRESET_OUTERINNER
1403 return pnStrIds
[ GetPresetImageId( nValueSetIdx
) - 1 ];
1406 void SvxBorderTabPage::FillPresetVS()
1408 // basic initialization of the ValueSet
1409 m_xWndPresets
->SetStyle( m_xWndPresets
->GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
1410 m_xWndPresets
->SetColCount( BORDER_PRESET_COUNT
);
1412 // insert images and help texts
1413 for( sal_uInt16 nVSIdx
= 1; nVSIdx
<= BORDER_PRESET_COUNT
; ++nVSIdx
)
1415 m_xWndPresets
->InsertItem( nVSIdx
);
1416 m_xWndPresets
->SetItemImage(nVSIdx
, m_aBorderImgVec
[GetPresetImageId(nVSIdx
) - 1]);
1417 m_xWndPresets
->SetItemText( nVSIdx
, SvxResId( GetPresetStringId( nVSIdx
) ) );
1421 m_xWndPresets
->SetNoSelection();
1422 m_xWndPresets
->SetOptimalSize();
1423 m_xWndPresets
->Show();
1426 void SvxBorderTabPage::FillShadowVS()
1428 // basic initialization of the ValueSet
1429 m_xWndShadows
->SetStyle( m_xWndShadows
->GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
1430 m_xWndShadows
->SetColCount( BORDER_SHADOW_COUNT
);
1432 // string resource IDs for each image
1433 static const TranslateId pnStrIds
[ BORDER_SHADOW_COUNT
] =
1434 { 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
};
1436 // insert images and help texts
1437 for( sal_uInt16 nVSIdx
= 1; nVSIdx
<= BORDER_SHADOW_COUNT
; ++nVSIdx
)
1439 m_xWndShadows
->InsertItem( nVSIdx
);
1440 m_xWndShadows
->SetItemImage(nVSIdx
, m_aShadowImgVec
[nVSIdx
-1]);
1441 m_xWndShadows
->SetItemText( nVSIdx
, CuiResId( pnStrIds
[ nVSIdx
- 1 ] ) );
1445 m_xWndShadows
->SelectItem( 1 );
1446 m_xWndShadows
->SetOptimalSize();
1447 m_xWndShadows
->Show();
1451 void SvxBorderTabPage::FillValueSets()
1457 void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth
, sal_Int32 nRemovedType
)
1460 m_xLineWidthMF
->set_value( nWidth
, FieldUnit::POINT
);
1462 auto it
= std::find( std::begin(s_LineWidths
), std::end(s_LineWidths
), nWidth
);
1464 if ( it
!= std::end(s_LineWidths
) && *it
>= 0 )
1466 // Select predefined value in combobox
1467 m_xLineWidthMF
->hide();
1468 m_xLineWidthLB
->set_active(std::distance(std::begin(s_LineWidths
), it
) - nRemovedType
);
1472 // This is not one of predefined values. Show spinner
1473 m_xLineWidthLB
->set_active(std::size(s_LineWidths
) - nRemovedType
-1);
1474 m_xLineWidthMF
->show();
1478 static Color
lcl_mediumColor( Color aMain
, Color
/*aDefault*/ )
1480 return SvxBorderLine::threeDMediumColor( aMain
);
1483 void SvxBorderTabPage::FillLineListBox_Impl()
1485 using namespace ::com::sun::star::table::BorderLineStyle
;
1488 SvxBorderLineStyle mnStyle
;
1489 SvtLineListBox::ColorFunc mpColor1Fn
;
1490 SvtLineListBox::ColorFunc mpColor2Fn
;
1491 SvtLineListBox::ColorDistFunc mpColorDistFn
;
1492 } const aLines
[] = {
1494 { SvxBorderLineStyle::SOLID
, &sameColor
, &sameColor
, &sameDistColor
},
1495 { SvxBorderLineStyle::DOTTED
, &sameColor
, &sameColor
, &sameDistColor
},
1496 { SvxBorderLineStyle::DASHED
, &sameColor
, &sameColor
, &sameDistColor
},
1497 { SvxBorderLineStyle::FINE_DASHED
, &sameColor
, &sameColor
, &sameDistColor
},
1498 { SvxBorderLineStyle::DASH_DOT
, &sameColor
, &sameColor
, &sameDistColor
},
1499 { SvxBorderLineStyle::DASH_DOT_DOT
, &sameColor
, &sameColor
, &sameDistColor
},
1502 { SvxBorderLineStyle::DOUBLE
, &sameColor
, &sameColor
, &sameDistColor
},
1503 { SvxBorderLineStyle::DOUBLE_THIN
, &sameColor
, &sameColor
, &sameDistColor
},
1504 { SvxBorderLineStyle::THINTHICK_SMALLGAP
, &sameColor
, &sameColor
, &sameDistColor
},
1505 { SvxBorderLineStyle::THINTHICK_MEDIUMGAP
, &sameColor
, &sameColor
, &sameDistColor
},
1506 { SvxBorderLineStyle::THINTHICK_LARGEGAP
, &sameColor
, &sameColor
, &sameDistColor
},
1507 { SvxBorderLineStyle::THICKTHIN_SMALLGAP
, &sameColor
, &sameColor
, &sameDistColor
},
1508 { SvxBorderLineStyle::THICKTHIN_MEDIUMGAP
, &sameColor
, &sameColor
, &sameDistColor
},
1509 { SvxBorderLineStyle::THICKTHIN_LARGEGAP
, &sameColor
, &sameColor
, &sameDistColor
},
1511 { SvxBorderLineStyle::EMBOSSED
, &SvxBorderLine::threeDLightColor
, &SvxBorderLine::threeDDarkColor
, &lcl_mediumColor
},
1512 { SvxBorderLineStyle::ENGRAVED
, &SvxBorderLine::threeDDarkColor
, &SvxBorderLine::threeDLightColor
, &lcl_mediumColor
},
1514 { SvxBorderLineStyle::OUTSET
, &SvxBorderLine::lightColor
, &SvxBorderLine::darkColor
, &sameDistColor
},
1515 { SvxBorderLineStyle::INSET
, &SvxBorderLine::darkColor
, &SvxBorderLine::lightColor
, &sameDistColor
}
1518 m_xLbLineStyle
->SetSourceUnit( FieldUnit::TWIP
);
1520 for (size_t i
= 0; i
< std::size(aLines
); ++i
)
1522 if (!IsBorderLineStyleAllowed(aLines
[i
].mnStyle
))
1525 m_xLbLineStyle
->InsertEntry(
1526 SvxBorderLine::getWidthImpl(aLines
[i
].mnStyle
),
1528 lcl_GetMinLineWidth(aLines
[i
].mnStyle
),
1529 aLines
[i
].mpColor1Fn
,
1530 aLines
[i
].mpColor2Fn
,
1531 aLines
[i
].mpColorDistFn
);
1534 sal_Int64 nVal
= m_xLineWidthMF
->get_value(FieldUnit::NONE
);
1535 nVal
= static_cast<sal_Int64
>(vcl::ConvertDoubleValue(nVal
, m_xLineWidthMF
->get_digits(),
1536 m_xLineWidthMF
->get_unit(), MapUnit::MapTwip
));
1537 m_xLbLineStyle
->SetWidth( nVal
);
1541 IMPL_LINK_NOARG(SvxBorderTabPage
, LinesChanged_Impl
, LinkParamNone
*, void)
1543 if (!mbUseMarginItem
&& m_xLeftMF
->get_visible())
1545 bool bLineSet
= m_aFrameSel
.IsAnyBorderVisible();
1546 bool bSpaceModified
= mbLeftModified
||
1555 m_xLeftMF
->set_value(nMinValue
, FieldUnit::NONE
);
1556 m_xRightMF
->set_value(nMinValue
, FieldUnit::NONE
);
1557 m_xTopMF
->set_value(nMinValue
, FieldUnit::NONE
);
1558 m_xBottomMF
->set_value(nMinValue
, FieldUnit::NONE
);
1563 m_xLeftMF
->set_min(0, FieldUnit::NONE
);
1564 m_xRightMF
->set_min(0, FieldUnit::NONE
);
1565 m_xTopMF
->set_min(0, FieldUnit::NONE
);
1566 m_xBottomMF
->set_min(0, FieldUnit::NONE
);
1568 // for tables everything is allowed
1569 SvxBoxInfoItemValidFlags nValid
= SvxBoxInfoItemValidFlags::TOP
|SvxBoxInfoItemValidFlags::BOTTOM
|SvxBoxInfoItemValidFlags::LEFT
|SvxBoxInfoItemValidFlags::RIGHT
;
1571 m_xLeftFT
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::LEFT
) );
1572 m_xRightFT
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::RIGHT
) );
1573 m_xTopFT
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::TOP
) );
1574 m_xBottomFT
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::BOTTOM
) );
1575 m_xLeftMF
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::LEFT
) );
1576 m_xRightMF
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::RIGHT
) );
1577 m_xTopMF
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::TOP
) );
1578 m_xBottomMF
->set_sensitive( bool(nValid
& SvxBoxInfoItemValidFlags::BOTTOM
) );
1579 m_xSynchronizeCB
->set_sensitive(m_xRightMF
->get_sensitive() || m_xTopMF
->get_sensitive() ||
1580 m_xBottomMF
->get_sensitive() || m_xLeftMF
->get_sensitive());
1582 UpdateRemoveAdjCellBorderCB( SAL_MAX_UINT16
);
1586 IMPL_LINK( SvxBorderTabPage
, ModifyDistanceHdl_Impl
, weld::MetricSpinButton
&, rField
, void)
1588 if (&rField
== m_xLeftMF
.get())
1589 mbLeftModified
= true;
1590 else if (&rField
== m_xRightMF
.get())
1591 mbRightModified
= true;
1592 else if (&rField
== m_xTopMF
.get())
1593 mbTopModified
= true;
1594 else if (&rField
== m_xBottomMF
.get())
1595 mbBottomModified
= true;
1599 const auto nVal
= rField
.get_value(FieldUnit::NONE
);
1600 if (&rField
!= m_xLeftMF
.get())
1601 m_xLeftMF
->set_value(nVal
, FieldUnit::NONE
);
1602 if (&rField
!= m_xRightMF
.get())
1603 m_xRightMF
->set_value(nVal
, FieldUnit::NONE
);
1604 if (&rField
!= m_xTopMF
.get())
1605 m_xTopMF
->set_value(nVal
, FieldUnit::NONE
);
1606 if (&rField
!= m_xBottomMF
.get())
1607 m_xBottomMF
->set_value(nVal
, FieldUnit::NONE
);
1611 IMPL_LINK( SvxBorderTabPage
, SyncHdl_Impl
, weld::Toggleable
&, rBox
, void)
1613 mbSync
= rBox
.get_active();
1616 IMPL_LINK( SvxBorderTabPage
, RemoveAdjacentCellBorderHdl_Impl
, weld::Toggleable
&, rBox
, void)
1618 mbRemoveAdjacentCellBorders
= rBox
.get_active();
1621 void SvxBorderTabPage::UpdateRemoveAdjCellBorderCB( sal_uInt16 nPreset
)
1625 const SfxItemSet
& rOldSet
= GetItemSet();
1626 const SvxBoxInfoItem
* pOldBoxInfoItem
= GetOldItem( rOldSet
, SID_ATTR_BORDER_INNER
);
1627 const SvxBoxItem
* pOldBoxItem
= static_cast<const SvxBoxItem
*>(GetOldItem( rOldSet
, mnBoxSlot
));
1628 if( !pOldBoxInfoItem
|| !pOldBoxItem
)
1630 std::pair
<svx::FrameBorderType
, SvxBoxInfoItemValidFlags
> eTypes1
[] = {
1631 { svx::FrameBorderType::Top
,SvxBoxInfoItemValidFlags::TOP
},
1632 { svx::FrameBorderType::Bottom
,SvxBoxInfoItemValidFlags::BOTTOM
},
1633 { svx::FrameBorderType::Left
,SvxBoxInfoItemValidFlags::LEFT
},
1634 { svx::FrameBorderType::Right
,SvxBoxInfoItemValidFlags::RIGHT
},
1636 SvxBoxItemLine
const eTypes2
[] = {
1637 SvxBoxItemLine::TOP
,
1638 SvxBoxItemLine::BOTTOM
,
1639 SvxBoxItemLine::LEFT
,
1640 SvxBoxItemLine::RIGHT
,
1643 // Check if current selection involves deletion of at least one border
1644 bool bBorderDeletionReq
= false;
1645 for ( size_t i
=0; i
< std::size( eTypes1
); ++i
)
1647 if( pOldBoxItem
->GetLine( eTypes2
[i
] ) || !( pOldBoxInfoItem
->IsValid( eTypes1
[i
].second
) ) )
1649 if( m_aFrameSel
.GetFrameBorderState( eTypes1
[i
].first
) == svx::FrameBorderState::Hide
)
1651 bBorderDeletionReq
= true;
1657 if( !bBorderDeletionReq
&& ( nPreset
== IID_PRE_CELL_NONE
|| nPreset
== IID_PRE_TABLE_NONE
) )
1658 bBorderDeletionReq
= true;
1660 m_xRemoveAdjacentCellBordersCB
->set_sensitive(bBorderDeletionReq
);
1662 if( !bBorderDeletionReq
)
1664 mbRemoveAdjacentCellBorders
= false;
1665 m_xRemoveAdjacentCellBordersCB
->set_active(false);
1669 void SvxBorderTabPage::PageCreated(const SfxAllItemSet
& aSet
)
1671 const SfxUInt16Item
* pSWModeItem
= aSet
.GetItem
<SfxUInt16Item
>(SID_SWMODE_TYPE
, false);
1672 const SfxUInt32Item
* pFlagItem
= aSet
.GetItem
<SfxUInt32Item
>(SID_FLAG_TYPE
, false);
1675 nSWMode
= static_cast<SwBorderModes
>(pSWModeItem
->GetValue());
1677 // show checkbox <m_xMergeWithNextCB> for format.paragraph
1678 if ( nSWMode
== SwBorderModes::PARA
)
1680 m_xMergeWithNextCB
->show();
1681 m_xPropertiesFrame
->show();
1683 // show checkbox <m_xMergeAdjacentBordersCB> for format.paragraph
1684 else if ( nSWMode
== SwBorderModes::TABLE
)
1686 m_xMergeAdjacentBordersCB
->show();
1687 m_xPropertiesFrame
->show();
1691 if ( ( pFlagItem
->GetValue() & SVX_HIDESHADOWCTL
) == SVX_HIDESHADOWCTL
)
1692 HideShadowControls();
1695 void SvxBorderTabPage::SetTableMode()
1697 nSWMode
= SwBorderModes::TABLE
;
1700 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */