LibreOffice Module cui (master) 1
border.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <sfx2/objsh.hxx>
23#include <svx/strings.hrc>
24#include <svx/svxids.hrc>
25
26#include <strings.hrc>
27#include <bitmaps.hlst>
28
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>
48
49using namespace ::editeng;
50using ::com::sun::star::uno::Reference;
51using ::com::sun::star::lang::XServiceInfo;
52using ::com::sun::star::uno::UNO_QUERY;
53
54
55/*
56 * [Description:]
57 * TabPage for setting the border attributes.
58 * Needs
59 * a SvxShadowItem: shadow
60 * a SvxBoxItem: lines left, right, top, bottom,
61 * a SvxBoxInfo: lines vertical, horizontal, distance, flags
62 *
63 * Lines can have three conditions:
64 * 1. Show ( -> valid values )
65 * 2. Hide ( -> NULL-Pointer )
66 * 3. DontCare ( -> special Valid-Flags in the InfoItem )
67 */
68
69// static ----------------------------------------------------------------
70
73 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
74 SID_ATTR_ALIGN_MARGIN, SID_ATTR_ALIGN_MARGIN,
75 SID_ATTR_BORDER_CONNECT, SID_ATTR_BORDER_CONNECT,
76 SID_SW_COLLAPSING_BORDERS, SID_SW_COLLAPSING_BORDERS,
77 SID_ATTR_BORDER_DIAG_TLBR, SID_ATTR_BORDER_DIAG_BLTR>);
78
79namespace
80{
81int lcl_twipsToPt(sal_Int64 nTwips)
82{
83 return vcl::ConvertDoubleValue(nTwips, 0, FieldUnit::TWIP, MapUnit::MapPoint) * 100;
84}
85}
86
87const 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),
94 -1
95};
96
98{
99 auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP));
100 rField.set_digits(1);
101 rField.set_min(rField.normalize(nMin), FieldUnit::TWIP);
102}
103
104// returns in pt
106{
107 switch (aStyle)
108 {
109 case SvxBorderLineStyle::NONE:
110 return 0;
111
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;
119
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;
129
130 case SvxBorderLineStyle::EMBOSSED: return 15;
131 case SvxBorderLineStyle::ENGRAVED: return 15;
132
133 case SvxBorderLineStyle::OUTSET: return 10;
134 case SvxBorderLineStyle::INSET: return 10;
135
136 default:
137 return 15;
138 }
139}
140
141// number of preset images to show
142const sal_uInt16 BORDER_PRESET_COUNT = 5;
143
144// number of shadow images to show
145const sal_uInt16 BORDER_SHADOW_COUNT = 5;
146
148 : mrVsPos(rVsPos)
149 , mrMfSize(rMfSize)
150 , mrLbColor(rLbColor)
151{
152}
153
155{
156 SvxShadowItem aItem(rItem);
157 if (!mrVsPos.IsNoSelection())
158 {
159 switch (mrVsPos.GetSelectedItemId())
160 {
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;
179 }
180 }
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
185 aItem.SetWidth(mrMfSize.denormalize(mrMfSize.get_value(FieldUnit::TWIP)));
188 return aItem;
189}
190
192{
193 switch (rItem.GetLocation())
194 {
195 case SvxShadowLocation::NONE:
197 break;
198 case SvxShadowLocation::BottomRight:
200 break;
201 case SvxShadowLocation::TopRight:
203 break;
204 case SvxShadowLocation::BottomLeft:
206 break;
207 case SvxShadowLocation::TopLeft:
209 break;
210 default:
212 break;
213 }
215 mrMfSize.set_value(mrMfSize.normalize(rItem.GetWidth()), FieldUnit::TWIP);
219}
220
222{
226}
227
229{
231 mrMfSize.set_text("");
233}
234
237 : mrLeftWrp(rMfLeft)
238 , mrRightWrp(rMfRight)
239 , mrTopWrp(rMfTop)
240 , mrBottomWrp(rMfBottom)
241{
242}
243
245{
246 SvxMarginItem aItem(rItem);
248 aItem.SetLeftMargin(mrLeftWrp.denormalize(mrLeftWrp.get_value(FieldUnit::TWIP)));
252 aItem.SetTopMargin(mrTopWrp.denormalize(mrTopWrp.get_value(FieldUnit::TWIP)));
255 return aItem;
256}
257
259{
264}
265
267{
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);
276}
277
279{
280 const OUString sEmpty;
285}
286
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"))
337{
338 static std::vector<OUString> aBorderImageIds;
339
340 if (aBorderImageIds.empty())
341 {
343 {
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
351 });
352 }
353 else
354 {
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
362 });
363 }
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
380 });
381 }
382
383 for (auto const & rImageId : aBorderImageIds)
384 m_aBorderImgVec.emplace_back(StockImage::Yes, rImageId);
385
386 static std::vector<OUString> aShadowImageIds;
387 if (aShadowImageIds.empty())
388 {
390 {
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
397 });
398 }
399 else
400 {
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
407 });
408 }
409 }
410
411 for (auto const & rImageId : aShadowImageIds)
412 m_aShadowImgVec.emplace_back(StockImage::Yes, rImageId);
413
414 assert(m_aShadowImgVec.size() == BORDER_SHADOW_COUNT);
415
416 // this page needs ExchangeSupport
417 SetExchangeSupport();
418
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;
423
424 if (const SfxIntegerListItem* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_STYLES))
425 {
426 std::vector<sal_Int32> aUsedStyles = p->GetList();
427 for (int aUsedStyle : aUsedStyles)
428 maUsedBorderStyles.insert(static_cast<SvxBorderLineStyle>(aUsedStyle));
429 }
430
431 if (const SfxInt64Item* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_DEFAULT_WIDTH))
432 {
433 // The caller specifies default line width. Honor it.
434 SetLineWidth(p->GetValue());
435 }
436
437 // set metric
438 FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
439
440 if( mbUseMarginItem )
441 {
442 // copied from SvxAlignmentTabPage
443 switch ( eFUnit )
444 {
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;
453
454 case FieldUnit::CM:
455 case FieldUnit::M:
456 case FieldUnit::KM:
457 eFUnit = FieldUnit::MM;
458 break;
459 default: ;//prevent warning
460 }
461 }
462 else
463 {
464 switch ( eFUnit )
465 {
466 case FieldUnit::M:
467 case FieldUnit::KM:
468 eFUnit = FieldUnit::MM;
469 break;
470 default: ; //prevent warning
471 }
472 }
473
474 SetFieldUnit(*m_xEdShadowSize, eFUnit);
475
476 sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, false );
477 bool bIsDontCare = true;
478
479 if ( rCoreAttrs.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
480 {
481 // paragraph or table
482 const SvxBoxInfoItem* pBoxInfo =
483 static_cast<const SvxBoxInfoItem*>(&( rCoreAttrs.Get( nWhich ) ));
484
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;
489
490 if(pBoxInfo->IsDist())
491 {
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));
501 }
502 else
503 {
504 m_xSpacingFrame->hide();
505 }
506 bIsDontCare = !pBoxInfo->IsValid( SvxBoxInfoItemValidFlags::DISABLE );
507 }
508 if(!mbUseMarginItem && eFUnit == FieldUnit::MM && MapUnit::MapTwip == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
509 {
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);
516 }
517
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 );
530
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 ) );
538
539 FillValueSets();
540 FillLineListBox_Impl();
541
542 // Reapply line width: probably one of predefined values should be selected
543 SetLineWidth(m_xLineWidthMF->get_value(FieldUnit::NONE));
544
545 // connections
546 const SfxPoolItem* pItem = nullptr;
547 if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG), &pItem))
548 {
549 const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem);
550 auto it = pGrabBag->GetGrabBag().find("DialogUseCharAttr");
551 if (it != pGrabBag->GetGrabBag().end())
552 {
553 bool bDialogUseCharAttr = false;
554 it->second >>= bDialogUseCharAttr;
555 if (bDialogUseCharAttr)
556 {
557 mnShadowSlot = SID_ATTR_CHAR_SHADOW;
558 mnBoxSlot = SID_ATTR_CHAR_BOX;
559 }
560 }
561 }
562
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();
568
569 if (mbUseMarginItem)
570 m_xMarginControls.reset(new MarginControlsWrapper(*m_xLeftMF, *m_xRightMF, *m_xTopMF, *m_xBottomMF));
571
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();
576
578 {
579 Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
580 if ( xSI.is() )
581 bIsCalcDoc = xSI->supportsService("com.sun.star.sheet.SpreadsheetDocument");
582 }
583 if( bIsCalcDoc )
584 {
585 m_xRemoveAdjacentCellBordersCB->connect_toggled(LINK(this, SvxBorderTabPage, RemoveAdjacentCellBorderHdl_Impl));
586 m_xRemoveAdjacentCellBordersCB->show();
587 m_xRemoveAdjacentCellBordersCB->set_sensitive(false);
588 }
589 else
590 {
591 m_xRemoveAdjacentCellBordersCB->hide();
592 m_xRemoveAdjacentCellBordersFT->hide();
593 }
594}
595
597{
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();
606}
607
608std::unique_ptr<SfxTabPage> SvxBorderTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
609 const SfxItemSet* rAttrSet )
610{
611 return std::make_unique<SvxBorderTabPage>(pPage, pController, *rAttrSet);
612}
613
614void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
615{
616 if( m_aFrameSel.IsBorderEnabled( eBorder ) )
617 {
618 if( bValid )
619 m_aFrameSel.ShowBorder( eBorder, pCoreLine );
620 else
622 }
623}
624
626{
627 if (maUsedBorderStyles.empty())
628 // All border styles are allowed.
629 return true;
630
631 return maUsedBorderStyles.count(nStyle) > 0;
632}
633
635{
636 SfxItemPool* pPool = rSet->GetPool();
637
639 {
640 sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_TLBR);
641 if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId)))
643 else
645 }
646
648 {
649 sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_BLTR);
650 if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId)))
652 else
654 }
655
657 {
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();
664 }
665
667 {
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();
674 }
675
676 sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
677 const SfxBoolItem *pMergeAdjacentBorders = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeAdjacentBordersId));
678 if (!pMergeAdjacentBorders)
680 else
681 m_xMergeAdjacentBordersCB->set_active(pMergeAdjacentBorders->GetValue());
682 m_xMergeAdjacentBordersCB->save_state();
683
684 sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
685 const SfxBoolItem *pMergeWithNext = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeWithNextId));
686 if (!pMergeWithNext)
688 else
689 m_xMergeWithNextCB->set_active(pMergeWithNext->GetValue());
690 m_xMergeWithNextCB->save_state();
691
692 const SvxBoxItem* pBoxItem;
693 const SvxBoxInfoItem* pBoxInfoItem;
694 sal_uInt16 nWhichBox = GetWhich(mnBoxSlot);
695 MapUnit eCoreUnit;
696
697 pBoxItem = static_cast<const SvxBoxItem*>(GetItem( *rSet, mnBoxSlot ));
698
699 pBoxInfoItem = GetItem( *rSet, SID_ATTR_BORDER_INNER, false );
700
701 eCoreUnit = pPool->GetMetric( nWhichBox );
702
703 if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
704 {
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 ) );
711
712
713 // distance inside
714
715 if( !mbUseMarginItem )
716 {
717 if (m_xLeftMF->get_visible())
718 {
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);
723
724 nMinValue = m_xLeftMF->get_value(FieldUnit::NONE);
725
726 if ( pBoxInfoItem->IsDist() )
727 {
728 if( rSet->GetItemState( nWhichBox ) >= SfxItemState::DEFAULT )
729 {
730 bool bIsAnyBorderVisible = m_aFrameSel.IsAnyBorderVisible();
731 if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
732 {
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);
737 }
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 );
746
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 )
756 {
757 mbLeftModified = true;
758 mbRightModified = true;
759 mbTopModified = true;
760 mbBottomModified = true;
761 }
762 }
763 else
764 {
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() );
770 }
771 }
772 m_xLeftMF->save_value();
773 m_xRightMF->save_value();
774 m_xTopMF->save_value();
775 m_xBottomMF->save_value();
776 }
777 }
778 }
779 else
780 {
781 // avoid ResetFrameLine-calls:
783 }
784
787
788 // depict line (color) in controllers if unambiguous:
789
790 {
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 )
796 {
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);
803
804 // then set the style
805 m_xLbLineStyle->SelectEntry( nStyle );
806 }
807 else
808 m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
809
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;
815
816 m_xLbLineColor->SelectEntry(aColor);
818 m_xLbLineStyle->SetColor(nTextColor);
819
820 // Select all visible lines, if they are all equal.
821 if( bWidthEq && bColorEq )
823
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);
827 }
828
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);
834
835 m_xWndPresets->SetNoSelection();
836
837 // - no line - should not be selected
838
839 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
840 {
841 m_xLbLineStyle->SelectEntry(SvxBorderLineStyle::SOLID);
842 SelStyleHdl_Impl(*m_xLbLineStyle);
843 }
844
845 const SfxUInt16Item* pHtmlModeItem = rSet->GetItemIfSet(SID_HTML_MODE, false);
846 if(!pHtmlModeItem)
847 {
849 pHtmlModeItem = pShell->GetItem(SID_HTML_MODE);
850 }
851 if(pHtmlModeItem)
852 {
853 sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue();
854 if(nHtmlMode & HTMLMODE_ON)
855 {
856 // there are no shadows in Html-mode and only complete borders
857 m_xShadowFrame->set_sensitive(false);
858
859 if( !(nSWMode & SwBorderModes::TABLE) )
860 {
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);
866 }
867 }
868 }
869
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))
874 {
875 mbSync = true;
876 }
877 else
878 mbSync = false;
879 m_xSynchronizeCB->set_active(mbSync);
880
882 m_xRemoveAdjacentCellBordersCB->set_active(false);
883 m_xRemoveAdjacentCellBordersCB->set_sensitive(false);
884}
885
887{
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();
894}
895
897{
898 if ( _pSet )
899 FillItemSet( _pSet );
900
901 return DeactivateRC::LeavePage;
902}
903
905{
906 bool bAttrsChanged = false;
907
908 SfxItemPool* pPool = rCoreAttrs->GetPool();
909
912 {
913 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR))
914 {
915 SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
917 rCoreAttrs->Put(aLineItem);
918 bAttrsChanged = true;
919 }
920 }
921
924 {
925 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR))
926 {
927 SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
929 rCoreAttrs->Put(aLineItem);
930 bAttrsChanged = true;
931 }
932 }
933
934 if (m_xShadowControls && m_xShadowControls->get_value_changed_from_saved())
935 {
936 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, mnShadowSlot))
937 {
938 const SvxShadowItem& rOldShadowItem = *static_cast<const SvxShadowItem*>(pOldItem);
939 rCoreAttrs->Put(m_xShadowControls->GetControlValue(rOldShadowItem));
940 bAttrsChanged = true;
941 }
942 }
943
944 if (m_xMarginControls && m_xMarginControls->get_value_changed_from_saved())
945 {
946 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_ALIGN_MARGIN))
947 {
948 const SvxMarginItem& rOldMarginItem = *static_cast<const SvxMarginItem*>(pOldItem);
949 rCoreAttrs->Put(m_xMarginControls->GetControlValue(rOldMarginItem));
950 bAttrsChanged = true;
951 }
952 }
953
954 if (m_xMergeAdjacentBordersCB->get_state_changed_from_saved())
955 {
956 auto nState = m_xMergeAdjacentBordersCB->get_state();
957 if (nState == TRISTATE_INDET)
958 {
959 sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
960 rCoreAttrs->ClearItem(nMergeAdjacentBordersId);
961 }
962 else
963 {
964 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_SW_COLLAPSING_BORDERS))
965 {
966 std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
967 xNewItem->SetValue(static_cast<bool>(nState));
968 rCoreAttrs->Put(std::move(xNewItem));
969 }
970 }
971 bAttrsChanged = true;
972 }
973
974 if (m_xMergeWithNextCB->get_state_changed_from_saved())
975 {
976 auto nState = m_xMergeWithNextCB->get_state();
977 if (nState == TRISTATE_INDET)
978 {
979 sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
980 rCoreAttrs->ClearItem(nMergeWithNextId);
981 }
982 else
983 {
984 if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_CONNECT))
985 {
986 std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
987 xNewItem->SetValue(static_cast<bool>(nState));
988 rCoreAttrs->Put(std::move(xNewItem));
989 }
990 }
991 bAttrsChanged = true;
992 }
993
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 ));
1001
1002 MapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
1003
1004
1005 // outer border:
1006
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 },
1012 };
1013
1014 for (std::pair<svx::FrameBorderType,SvxBoxItemLine> const & i : eTypes1)
1015 aBoxItem.SetLine( m_aFrameSel.GetFrameBorderStyle( i.first ), i.second );
1016
1017
1019 // border hor/ver and TableFlag
1020
1021 std::pair<svx::FrameBorderType,SvxBoxInfoItemLine> eTypes2[] = {
1022 { svx::FrameBorderType::Horizontal,SvxBoxInfoItemLine::HORI },
1023 { svx::FrameBorderType::Vertical,SvxBoxInfoItemLine::VERT }
1024 };
1025 for (std::pair<svx::FrameBorderType,SvxBoxInfoItemLine> const & j : eTypes2)
1026 aBoxInfoItem.SetLine( m_aFrameSel.GetFrameBorderStyle( j.first ), j.second );
1027
1028 aBoxInfoItem.EnableHor( mbHorEnabled );
1029 aBoxInfoItem.EnableVer( mbVerEnabled );
1030
1031
1032 // inner distance
1033
1034 if (m_xLeftMF->get_visible())
1035 {
1036 // #i40405# enable distance controls for next dialog call
1037 aBoxInfoItem.SetDist( true );
1038
1039 if( !mbUseMarginItem )
1040 {
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() )
1044 {
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))
1057 )
1058 {
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);
1063 }
1064 else
1065 {
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);
1070 }
1071 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
1072 }
1073 }
1074 }
1075
1076
1077 // note Don't Care Status in the Info-Item:
1078
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 );
1085
1086
1087 // Put or Clear of the border?
1088
1089 bPut = true;
1090
1091 if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxWhich, false ))
1092 {
1093 bPut = aBoxItem != static_cast<const SvxBoxItem&>(rOldSet.Get(nBoxWhich));
1094 }
1095 if( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, false ) )
1096 {
1097 const SvxBoxInfoItem& rOldBoxInfo = static_cast<const SvxBoxInfoItem&>(
1098 rOldSet.Get(nBoxInfoWhich));
1099
1100 aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
1101 aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
1102 bPut |= (aBoxInfoItem != rOldBoxInfo );
1103 }
1104
1105 if ( bPut )
1106 {
1107 if ( !pOldBoxItem || *pOldBoxItem != aBoxItem )
1108 {
1109 rCoreAttrs->Put( aBoxItem );
1110 bAttrsChanged = true;
1111 }
1112 const SfxPoolItem* pOld = GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_INNER, false );
1113
1114 if ( !pOld || *static_cast<const SvxBoxInfoItem*>(pOld) != aBoxInfoItem )
1115 {
1116 rCoreAttrs->Put( aBoxInfoItem );
1117 bAttrsChanged = true;
1118 }
1119 }
1120 else
1121 {
1122 rCoreAttrs->ClearItem( nBoxWhich );
1123 rCoreAttrs->ClearItem( nBoxInfoWhich );
1124 }
1125
1126 return bAttrsChanged;
1127}
1128
1130{
1131 m_xShadowFrame->hide();
1132}
1133
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
1155
1157{
1161
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 }
1186 };
1187
1188 // first hide and deselect all frame borders
1189 m_aFrameSel.HideAllBorders();
1190 m_aFrameSel.DeselectAllBorders();
1191
1192 // Using image ID to find correct line in table above.
1193 sal_uInt16 nLine = GetPresetImageId( m_xWndPresets->GetSelectedItemId() ) - 1;
1194
1195 // Apply all styles from the table
1197 {
1199 switch( ppeStates[ nLine ][ nBorder ] )
1200 {
1201 case SHOW: m_aFrameSel.SelectBorder( eBorder ); break;
1202 case HIDE: /* nothing to do */ break;
1203 case DONT: m_aFrameSel.SetBorderDontCare( eBorder ); break;
1204 }
1205 }
1206
1207 // Show all lines that have been selected above
1208 if( m_aFrameSel.IsAnyBorderSelected() )
1209 {
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);
1213
1214 // set current style to all previously selected lines
1215 SelStyleHdl_Impl(*m_xLbLineStyle);
1216 SelColHdl_Impl(*m_xLbLineColor);
1217 }
1218
1219 // Presets ValueSet does not show a selection (used as push buttons).
1220 m_xWndPresets->SetNoSelection();
1221
1222 LinesChanged_Impl( nullptr );
1223 UpdateRemoveAdjCellBorderCB( nLine + 1 );
1224}
1225
1227{
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);
1233}
1234
1235IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void)
1236{
1237 NamedColor aNamedColor = rColorBox.GetSelectedEntry();
1238 m_aFrameSel.SetColorToSelection(aNamedColor.m_aColor, aNamedColor.getComplexColor());
1239}
1240
1241IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void)
1242{
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();
1247 }
1248
1249 SetLineWidth(m_aLineWidths[nPos + nRemovedType], nRemovedType);
1250
1251 // Call the spinner handler to trigger all related modifications
1252 ModifyWidthMFHdl_Impl(*m_xLineWidthMF);
1253}
1254
1256{
1257 sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
1258
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);
1264
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 );
1270
1271 m_aFrameSel.SetStyleToSelection( nVal,
1272 m_xLbLineStyle->GetSelectEntryStyle() );
1273}
1274
1276{
1277 sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE);
1278
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);
1284
1285 nOldWidth = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
1286 nOldWidth,
1287 m_xLineWidthMF->get_digits(),
1288 FieldUnit::POINT,
1289 MapUnit::MapTwip));
1290
1291 const sal_Int64 nOldMinWidth = lcl_GetMinLineWidth(m_aFrameSel.getCurrentStyleLineStyle());
1292 const sal_Int64 nNewMinWidth = lcl_GetMinLineWidth(m_xLbLineStyle->GetSelectEntryStyle());
1293
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;
1297
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;
1304
1305 // set value inside edit box
1306 if (nOldWidth != nNewWidth)
1307 {
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);
1314 }
1315
1316 if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
1317 {
1318 for (size_t i = 0; i < 3; i++)
1319 {
1320 m_xLineWidthLB->save_values_by_id(OUString::number(i));
1321 m_xLineWidthLB->remove_id(OUString::number(i));
1322 }
1323 if (m_xLineWidthLB->get_active_id().isEmpty())
1324 m_xLineWidthLB->set_active_id("3");
1325 }
1326 else
1327 {
1328 if (m_xLineWidthLB->get_values_changed_from_saved())
1329 {
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();
1333 }
1334 }
1335
1336 // set value inside style box
1337 m_aFrameSel.SetStyleToSelection( nNewWidth,
1338 m_xLbLineStyle->GetSelectEntryStyle() );
1339}
1340
1341
1342// ValueSet handling
1343sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
1344{
1345 // table with all sets of predefined border styles
1346 static const sal_uInt16 ppnImgIds[][ BORDER_PRESET_COUNT ] =
1347 {
1348 // simple cell without diagonal frame borders
1350 // simple cell with diagonal frame borders
1352 // with horizontal inner frame border
1354 // with vertical inner frame border
1356 // with horizontal and vertical inner frame borders
1358 };
1359
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;
1370
1371 DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= BORDER_PRESET_COUNT),
1372 "SvxBorderTabPage::GetPresetImageId - wrong index" );
1373 return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
1374}
1375
1376TranslateId SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
1377{
1378 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
1379 static const TranslateId pnStrIds[] =
1380 {
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,
1387
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,
1393
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,
1399
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
1405 };
1406 return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
1407}
1408
1410{
1411 // basic initialization of the ValueSet
1412 m_xWndPresets->SetStyle( m_xWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1413 m_xWndPresets->SetColCount( BORDER_PRESET_COUNT );
1414
1415 // insert images and help texts
1416 for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_PRESET_COUNT; ++nVSIdx )
1417 {
1418 m_xWndPresets->InsertItem( nVSIdx );
1419 m_xWndPresets->SetItemImage(nVSIdx, m_aBorderImgVec[GetPresetImageId(nVSIdx) - 1]);
1420 m_xWndPresets->SetItemText( nVSIdx, SvxResId( GetPresetStringId( nVSIdx ) ) );
1421 }
1422
1423 // show the control
1424 m_xWndPresets->SetNoSelection();
1425 m_xWndPresets->SetOptimalSize();
1426 m_xWndPresets->Show();
1427}
1428
1430{
1431 // basic initialization of the ValueSet
1432 m_xWndShadows->SetStyle( m_xWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1433 m_xWndShadows->SetColCount( BORDER_SHADOW_COUNT );
1434
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 };
1438
1439 // insert images and help texts
1440 for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_SHADOW_COUNT; ++nVSIdx )
1441 {
1442 m_xWndShadows->InsertItem( nVSIdx );
1443 m_xWndShadows->SetItemImage(nVSIdx, m_aShadowImgVec[nVSIdx-1]);
1444 m_xWndShadows->SetItemText( nVSIdx, CuiResId( pnStrIds[ nVSIdx - 1 ] ) );
1445 }
1446
1447 // show the control
1448 m_xWndShadows->SelectItem( 1 );
1449 m_xWndShadows->SetOptimalSize();
1450 m_xWndShadows->Show();
1451}
1452
1453
1455{
1456 FillPresetVS();
1457 FillShadowVS();
1458}
1459
1460void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth, sal_Int32 nRemovedType )
1461{
1462 if ( nWidth >= 0 )
1463 m_xLineWidthMF->set_value( nWidth, FieldUnit::POINT );
1464
1465 auto it = std::find_if( m_aLineWidths.begin(), m_aLineWidths.end(),
1466 [nWidth](const int val) -> bool { return val == nWidth; } );
1467
1468 if ( it != m_aLineWidths.end() && *it >= 0 )
1469 {
1470 // Select predefined value in combobox
1471 m_xLineWidthMF->hide();
1472 m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it) - nRemovedType);
1473 }
1474 else
1475 {
1476 // This is not one of predefined values. Show spinner
1477 m_xLineWidthLB->set_active(m_aLineWidths.size() - nRemovedType -1);
1478 m_xLineWidthMF->show();
1479 }
1480}
1481
1482static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1483{
1484 return SvxBorderLine::threeDMediumColor( aMain );
1485}
1486
1488{
1489 using namespace ::com::sun::star::table::BorderLineStyle;
1490
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 },
1504
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 },
1514
1515 { SvxBorderLineStyle::EMBOSSED, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor },
1516 { SvxBorderLineStyle::ENGRAVED, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor },
1517
1518 { SvxBorderLineStyle::OUTSET, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor },
1519 { SvxBorderLineStyle::INSET, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor }
1520 };
1521
1522 m_xLbLineStyle->SetSourceUnit( FieldUnit::TWIP );
1523
1524 for (size_t i = 0; i < std::size(aLines); ++i)
1525 {
1526 if (!IsBorderLineStyleAllowed(aLines[i].mnStyle))
1527 continue;
1528
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);
1536 }
1537
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 );
1542}
1543
1544
1546{
1547 if (!mbUseMarginItem && m_xLeftMF->get_visible())
1548 {
1549 bool bLineSet = m_aFrameSel.IsAnyBorderVisible();
1550 bool bSpaceModified = mbLeftModified ||
1551 mbRightModified ||
1552 mbTopModified ||
1553 mbBottomModified;
1554
1555 if(bLineSet)
1556 {
1557 if(!bSpaceModified)
1558 {
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);
1563 }
1564 }
1565 else
1566 {
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);
1571 }
1572 // for tables everything is allowed
1573 SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::TOP|SvxBoxInfoItemValidFlags::BOTTOM|SvxBoxInfoItemValidFlags::LEFT|SvxBoxInfoItemValidFlags::RIGHT;
1574
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());
1585 }
1586 UpdateRemoveAdjCellBorderCB( SAL_MAX_UINT16 );
1587}
1588
1589
1590IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, weld::MetricSpinButton&, rField, void)
1591{
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;
1600
1601 if (mbSync)
1602 {
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);
1612 }
1613}
1614
1615IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, weld::Toggleable&, rBox, void)
1616{
1617 mbSync = rBox.get_active();
1618}
1619
1620IMPL_LINK( SvxBorderTabPage, RemoveAdjacentCellBorderHdl_Impl, weld::Toggleable&, rBox, void)
1621{
1622 mbRemoveAdjacentCellBorders = rBox.get_active();
1623}
1624
1626{
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 },
1639 };
1640 SvxBoxItemLine const eTypes2[] = {
1641 SvxBoxItemLine::TOP,
1642 SvxBoxItemLine::BOTTOM,
1643 SvxBoxItemLine::LEFT,
1644 SvxBoxItemLine::RIGHT,
1645 };
1646
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 )
1650 {
1651 if( pOldBoxItem->GetLine( eTypes2[i] ) || !( pOldBoxInfoItem->IsValid( eTypes1[i].second ) ) )
1652 {
1654 {
1655 bBorderDeletionReq = true;
1656 break;
1657 }
1658 }
1659 }
1660
1661 if( !bBorderDeletionReq && ( nPreset == IID_PRE_CELL_NONE || nPreset == IID_PRE_TABLE_NONE ) )
1662 bBorderDeletionReq = true;
1663
1664 m_xRemoveAdjacentCellBordersCB->set_sensitive(bBorderDeletionReq);
1665
1666 if( !bBorderDeletionReq )
1667 {
1669 m_xRemoveAdjacentCellBordersCB->set_active(false);
1670 }
1671}
1672
1674{
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)
1678 {
1679 nSWMode = static_cast<SwBorderModes>(pSWModeItem->GetValue());
1680 // #i43593#
1681 // show checkbox <m_xMergeWithNextCB> for format.paragraph
1682 if ( nSWMode == SwBorderModes::PARA )
1683 {
1684 m_xMergeWithNextCB->show();
1685 m_xPropertiesFrame->show();
1686 }
1687 // show checkbox <m_xMergeAdjacentBordersCB> for format.paragraph
1688 else if ( nSWMode == SwBorderModes::TABLE )
1689 {
1691 m_xPropertiesFrame->show();
1692 }
1693 }
1694 if (pFlagItem)
1695 if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1697}
1698
1700{
1701 nSWMode = SwBorderModes::TABLE;
1702}
1703
1704/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define IID_PRE_TABLE_OUTER2
Definition: border.cxx:1154
#define IID_PRE_CELL_L
Definition: border.cxx:1138
#define IID_PRE_HOR_NONE
Definition: border.cxx:1140
static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle)
Definition: border.cxx:105
#define IID_PRE_CELL_ALL
Definition: border.cxx:1135
#define IID_PRE_VER_NONE
Definition: border.cxx:1145
#define IID_PRE_HOR_OUTER2
Definition: border.cxx:1144
#define IID_PRE_CELL_LR
Definition: border.cxx:1136
#define IID_PRE_TABLE_NONE
Definition: border.cxx:1150
#define IID_PRE_VER_VER
Definition: border.cxx:1147
IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox &, rColorBox, void)
Definition: border.cxx:1235
#define IID_PRE_TABLE_OUTERH
Definition: border.cxx:1152
static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton &rField)
Definition: border.cxx:97
static Color lcl_mediumColor(Color aMain, Color)
Definition: border.cxx:1482
#define IID_PRE_TABLE_OUTER
Definition: border.cxx:1151
#define IID_PRE_VER_OUTER2
Definition: border.cxx:1149
#define IID_PRE_CELL_NONE
Definition: border.cxx:1134
#define IID_PRE_VER_OUTER
Definition: border.cxx:1146
#define IID_PRE_VER_ALL
Definition: border.cxx:1148
IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl, ValueSet *, void)
Definition: border.cxx:1156
#define IID_PRE_CELL_DIAG
Definition: border.cxx:1139
#define IID_PRE_HOR_OUTER
Definition: border.cxx:1141
#define IID_PRE_HOR_ALL
Definition: border.cxx:1143
#define IID_PRE_TABLE_ALL
Definition: border.cxx:1153
const sal_uInt16 BORDER_PRESET_COUNT
Definition: border.cxx:142
#define IID_PRE_HOR_HOR
Definition: border.cxx:1142
const sal_uInt16 BORDER_SHADOW_COUNT
Definition: border.cxx:145
#define IID_PRE_CELL_TB
Definition: border.cxx:1137
SvxBorderLineStyle
SvxBoxInfoItemValidFlags
SvxBoxItemLine
#define GetWhich(nSlot)
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
sal_uInt16 GetValue() const
Color const & GetSelectEntryColor() const
bool IsValueChangedFromSaved() const
void SelectEntry(const NamedColor &rColor)
void SaveValue()
void SetNoSelection()
bool IsNoSelection() const
weld::MetricSpinButton & mrTopWrp
Definition: border.hxx:73
SvxMarginItem GetControlValue(const SvxMarginItem &rItem) const
Definition: border.cxx:244
weld::MetricSpinButton & mrBottomWrp
Definition: border.hxx:74
bool get_value_changed_from_saved() const
Definition: border.cxx:258
void SetControlDontKnow()
Definition: border.cxx:278
void SetControlValue(const SvxMarginItem &rItem)
Definition: border.cxx:266
weld::MetricSpinButton & mrLeftWrp
Definition: border.hxx:71
MarginControlsWrapper(weld::MetricSpinButton &rMfLeft, weld::MetricSpinButton &rMfRight, weld::MetricSpinButton &rMfTop, weld::MetricSpinButton &rMfBottom)
Definition: border.cxx:235
weld::MetricSpinButton & mrRightWrp
Definition: border.hxx:72
bool GetValue() const
const std::map< OUString, css::uno::Any > & GetGrabBag() const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
static bool IsSlot(sal_uInt16 nId)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
const SfxItemSet & GetItemSet() const
SfxOkDialogController * GetDialogController() const
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
void SetControlValue(const SvxShadowItem &rItem)
Definition: border.cxx:191
void SetControlDontKnow()
Definition: border.cxx:228
ShadowControlsWrapper(ValueSet &rVsPos, weld::MetricSpinButton &rMfSize, ColorListBox &rLbColor)
Definition: border.cxx:147
weld::MetricSpinButton & mrMfSize
Definition: border.hxx:54
ValueSet & mrVsPos
Definition: border.hxx:53
ColorListBox & mrLbColor
Definition: border.hxx:55
SvxShadowItem GetControlValue(const SvxShadowItem &rItem) const
Definition: border.cxx:154
bool get_value_changed_from_saved() const
Definition: border.cxx:221
const Color & GetWindowTextColor() const
Color(* ColorDistFunc)(Color, Color)
Color(* ColorFunc)(Color)
static const sal_Int16 VeryThin
static const sal_Int16 ExtraThick
static const sal_Int16 Thin
static const sal_Int16 Medium
static const sal_Int16 Hairline
static const sal_Int16 Thick
sal_uInt16 GetPresetImageId(sal_uInt16 nValueSetIdx) const
Definition: border.cxx:1343
std::unique_ptr< ShadowControlsWrapper > m_xShadowControls
Definition: border.hxx:160
void FillLineListBox_Impl()
Definition: border.cxx:1487
SvxBorderTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreAttrs)
Definition: border.cxx:287
bool mbTopModified
Definition: border.hxx:115
void SetTableMode()
Definition: border.cxx:1699
std::vector< Image > m_aShadowImgVec
Definition: border.hxx:100
bool mbRemoveAdjacentCellBorders
Definition: border.hxx:118
SwBorderModes nSWMode
table, textframe, paragraph
Definition: border.hxx:104
std::unique_ptr< weld::CustomWeld > m_xFrameSelWin
Definition: border.hxx:128
std::unique_ptr< weld::CustomWeld > m_xWndShadowsWin
Definition: border.hxx:148
std::unique_ptr< weld::CustomWeld > m_xWndPresetsWin
Definition: border.hxx:126
std::unique_ptr< ValueSet > m_xWndShadows
Definition: border.hxx:147
std::unique_ptr< ValueSet > m_xWndPresets
Definition: border.hxx:125
void FillPresetVS()
Definition: border.cxx:1409
std::unique_ptr< weld::Container > m_xPropertiesFrame
properties - "Merge with next paragraph" in Writer
Definition: border.hxx:154
std::vector< Image > m_aBorderImgVec
Definition: border.hxx:101
std::unique_ptr< weld::Container > m_xShadowFrame
Definition: border.hxx:146
svx::FrameSelector m_aFrameSel
Definition: border.hxx:124
tools::Long nMinValue
minimum distance
Definition: border.hxx:103
std::unique_ptr< weld::ComboBox > m_xLineWidthLB
Definition: border.hxx:132
static const std::vector< int > m_aLineWidths
Definition: border.hxx:80
std::unique_ptr< weld::CheckButton > m_xMergeWithNextCB
Definition: border.hxx:155
void SetLineWidth(sal_Int64 nWidth, sal_Int32 nRemovedType=0)
Definition: border.cxx:1460
TranslateId GetPresetStringId(sal_uInt16 nValueSetIdx) const
Definition: border.cxx:1376
sal_uInt16 mnShadowSlot
Definition: border.hxx:106
std::unique_ptr< ColorListBox > m_xLbLineColor
Definition: border.hxx:131
std::unique_ptr< MarginControlsWrapper > m_xMarginControls
Definition: border.hxx:161
bool mbRightModified
Definition: border.hxx:114
bool mbUseMarginItem
Definition: border.hxx:112
virtual bool FillItemSet(SfxItemSet *rCoreAttrs) override
Definition: border.cxx:904
bool mbBottomModified
Definition: border.hxx:116
std::unique_ptr< weld::MetricSpinButton > m_xEdShadowSize
Definition: border.hxx:150
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: border.cxx:1673
bool mbTLBREnabled
true = Top-left to bottom-right border enabled.
Definition: border.hxx:110
bool mbHorEnabled
true = Inner horizontal border enabled.
Definition: border.hxx:108
bool mbBLTREnabled
true = Bottom-left to top-right border enabled.
Definition: border.hxx:111
virtual ~SvxBorderTabPage() override
Definition: border.cxx:596
virtual void Reset(const SfxItemSet *) override
Definition: border.cxx:634
std::set< SvxBorderLineStyle > maUsedBorderStyles
Definition: border.hxx:121
sal_uInt16 mnBoxSlot
Definition: border.hxx:105
std::unique_ptr< SvtLineListBox > m_xLbLineStyle
Definition: border.hxx:130
static const WhichRangesContainer pRanges
Definition: border.hxx:79
bool IsBorderLineStyleAllowed(SvxBorderLineStyle nStyle) const
Definition: border.cxx:625
std::unique_ptr< weld::Label > m_xFtShadowSize
Definition: border.hxx:149
std::unique_ptr< weld::Label > m_xFtShadowColor
Definition: border.hxx:151
void HideShadowControls()
Definition: border.cxx:1129
std::unique_ptr< weld::CheckButton > m_xMergeAdjacentBordersCB
Definition: border.hxx:157
void ResetFrameLine_Impl(svx::FrameBorderType eBorder, const editeng::SvxBorderLine *pCurLine, bool bValid)
share for individual Frame-/Core-Line
Definition: border.cxx:614
std::unique_ptr< weld::CheckButton > m_xRemoveAdjacentCellBordersCB
Definition: border.hxx:158
std::unique_ptr< weld::MetricSpinButton > m_xLeftMF
Definition: border.hxx:137
std::unique_ptr< weld::MetricSpinButton > m_xTopMF
Definition: border.hxx:141
virtual void ChangesApplied() override
Definition: border.cxx:886
std::unique_ptr< weld::MetricSpinButton > m_xLineWidthMF
Definition: border.hxx:133
void UpdateRemoveAdjCellBorderCB(sal_uInt16 nPreset)
Definition: border.cxx:1625
bool mbLeftModified
Definition: border.hxx:113
void FillShadowVS()
Definition: border.cxx:1429
void FillValueSets()
Definition: border.cxx:1454
std::unique_ptr< ColorListBox > m_xLbShadowColor
Definition: border.hxx:152
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: border.cxx:896
std::unique_ptr< weld::MetricSpinButton > m_xBottomMF
Definition: border.hxx:143
bool mbVerEnabled
true = Inner vertical border enabled.
Definition: border.hxx:109
std::unique_ptr< weld::MetricSpinButton > m_xRightMF
Definition: border.hxx:139
std::unique_ptr< weld::Label > m_xUserDefFT
Definition: border.hxx:127
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: border.cxx:608
std::unique_ptr< weld::CheckButton > m_xSynchronizeCB
Definition: border.hxx:144
bool IsMinDist() const
bool IsDist() const
bool IsValid(SvxBoxInfoItemValidFlags nValid) const
bool IsHorEnabled() const
void EnableVer(bool bEnable)
void SetDist(bool bNew)
void SetMinDist(bool bNew)
void SetDefDist(sal_uInt16 nNew)
const editeng::SvxBorderLine * GetHori() const
sal_uInt16 GetDefDist() const
bool IsVerEnabled() const
const editeng::SvxBorderLine * GetVert() const
void EnableHor(bool bEnable)
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
void SetRemoveAdjacentCellBorder(bool bSet)
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
sal_uInt16 GetSmallestDistance() const
const editeng::SvxBorderLine * GetRight() const
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetLeft() const
sal_Int16 GetDistance(SvxBoxItemLine nLine, bool bAllowNegative=false) const
void SetDistance(sal_Int16 nNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetBottom() const
void SetLine(const editeng::SvxBorderLine *pNew)
void SetLeftMargin(sal_Int16 nLeft)
void SetBottomMargin(sal_Int16 nBottom)
void SetRightMargin(sal_Int16 nRight)
void SetTopMargin(sal_Int16 nTop)
sal_Int16 GetRightMargin() const
sal_Int16 GetTopMargin() const
sal_Int16 GetBottomMargin() const
sal_Int16 GetLeftMargin() const
sal_uInt16 GetWidth() const
const Color & GetColor() const
void SetLocation(SvxShadowLocation eNew)
SvxShadowLocation GetLocation() const
void SetWidth(sal_uInt16 nNew)
void SetColor(const Color &rNew)
bool IsNoSelection() const
void SaveValue()
void SelectItem(sal_uInt16 nItemId)
sal_uInt16 GetSelectedItemId() const
bool IsValueChangedFromSaved() const
void SetNoSelection()
const editeng::SvxBorderLine * GetFrameBorderStyle(FrameBorderType eBorder) const
bool IsAnyBorderVisible() const
void SetBorderDontCare(FrameBorderType eBorder)
bool GetVisibleWidth(tools::Long &rnWidth, SvxBorderLineStyle &rnStyle) const
void ShowBorder(FrameBorderType eBorder, const editeng::SvxBorderLine *pStyle)
FrameBorderState GetFrameBorderState(FrameBorderType eBorder) const
bool IsBorderEnabled(FrameBorderType eBorder) const
bool GetVisibleColor(Color &rColor) const
void SelectAllVisibleBorders()
sal_Int64 normalize(sal_Int64 nValue) const
void set_text(const OUString &rText)
bool get_sensitive() const
sal_Int64 denormalize(sal_Int64 nValue) const
void set_digits(unsigned int digits)
sal_Int64 get_min(FieldUnit eValueUnit) const
void set_value(sal_Int64 nValue, FieldUnit eValueUnit)
bool get_value_changed_from_saved() const
void set_min(sal_Int64 min, FieldUnit eValueUnit)
sal_Int64 get_value(FieldUnit eDestUnit) const
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
Color sameDistColor(Color, Color rDefault)
Color sameColor(Color rMain)
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
#define DBG_ASSERT(sCon, aError)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
SVXCORE_DLLPUBLIC FieldUnit GetModuleFieldUnit(const SfxItemSet &)
sal_Int32 nState
#define SVX_HIDESHADOWCTL
SwBorderModes
FieldUnit
FrameSelFlags
TRISTATE_INDET
HTMLMODE_ON
void * p
sal_uInt16 nPos
MapUnit
NONE
tools::Long const nBorder
int i
const OUString sEmpty
static constexpr auto Items
FrameBorderType GetFrameBorderTypeFromIndex(size_t nIndex)
FrameBorderType
FrameBorderState
const int FRAMEBORDERTYPE_COUNT
long Long
double ConvertDoubleValue(double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
static SfxItemSet & rSet
model::ComplexColor getComplexColor()
Color m_aColor
DeactivateRC
#define SAL_MAX_UINT16
SVT_DLLPUBLIC sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)
#define WB_ITEMBORDER
#define WB_DOUBLEBORDER