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 .
22 #include <editeng/svxenum.hxx>
23 #include <svx/svxids.hrc>
24 #include <svx/strings.hrc>
25 #include <svx/dialmgr.hxx>
26 #include <bitmaps.hlst>
27 #include <svx/rotmodit.hxx>
29 #include <editeng/frmdiritem.hxx>
30 #include <editeng/justifyitem.hxx>
31 #include <svl/cjkoptions.hxx>
32 #include <svl/intitem.hxx>
33 #include <vcl/settings.hxx>
34 #include <vcl/event.hxx>
36 #define IID_BOTTOMLOCK 1
38 #define IID_CELLLOCK 3
42 const sal_uInt16
AlignmentTabPage::s_pRanges
[] =
44 SID_ATTR_ALIGN_HOR_JUSTIFY
,SID_ATTR_ALIGN_VER_JUSTIFY
,
45 SID_ATTR_ALIGN_STACKED
,SID_ATTR_ALIGN_LINEBREAK
,
46 SID_ATTR_ALIGN_INDENT
,SID_ATTR_ALIGN_INDENT
,
47 SID_ATTR_ALIGN_DEGREES
,SID_ATTR_ALIGN_DEGREES
,
48 SID_ATTR_ALIGN_LOCKPOS
,SID_ATTR_ALIGN_LOCKPOS
,
49 SID_ATTR_ALIGN_HYPHENATION
,SID_ATTR_ALIGN_HYPHENATION
,
50 SID_ATTR_ALIGN_ASIANVERTICAL
,SID_ATTR_ALIGN_ASIANVERTICAL
,
51 SID_ATTR_FRAMEDIRECTION
,SID_ATTR_FRAMEDIRECTION
,
52 SID_ATTR_ALIGN_SHRINKTOFIT
,SID_ATTR_ALIGN_SHRINKTOFIT
,
59 template<typename JustContainerType
, typename JustEnumType
>
60 void lcl_MaybeResetAlignToDistro(
61 weld::ComboBox
& rLB
, sal_uInt16 nListPos
, const SfxItemSet
& rCoreAttrs
, sal_uInt16 nWhichAlign
, sal_uInt16 nWhichJM
, JustEnumType eBlock
)
63 const SfxPoolItem
* pItem
;
64 if (rCoreAttrs
.GetItemState(nWhichAlign
, true, &pItem
) != SfxItemState::SET
)
68 const SfxEnumItemInterface
* p
= static_cast<const SfxEnumItemInterface
*>(pItem
);
69 JustContainerType eVal
= static_cast<JustContainerType
>(p
->GetEnumValue());
71 // alignment is not 'justify'. No need to go further.
74 if (rCoreAttrs
.GetItemState(nWhichJM
, true, &pItem
) != SfxItemState::SET
)
75 // justification method is not set.
78 p
= static_cast<const SfxEnumItemInterface
*>(pItem
);
79 SvxCellJustifyMethod eMethod
= static_cast<SvxCellJustifyMethod
>(p
->GetEnumValue());
80 if (eMethod
== SvxCellJustifyMethod::Distribute
)
82 // Select the 'distribute' entry in the specified list box.
83 rLB
.set_active(nListPos
);
87 void lcl_SetJustifyMethodToItemSet(SfxItemSet
& rSet
, const SfxItemSet
& rOldSet
, sal_uInt16 nWhichJM
, const weld::ComboBox
& rLB
, sal_uInt16 nListPos
)
89 SvxCellJustifyMethod eJM
= SvxCellJustifyMethod::Auto
;
90 if (rLB
.get_active() == nListPos
)
91 eJM
= SvxCellJustifyMethod::Distribute
;
93 // tdf#129300 If it would create no change, don't force it
94 const SvxJustifyMethodItem
& rOldItem
= static_cast<const SvxJustifyMethodItem
&>(rOldSet
.Get(nWhichJM
));
95 if (rOldItem
.GetValue() == eJM
)
97 rSet
.InvalidateItem(nWhichJM
);
101 SvxJustifyMethodItem
aItem(eJM
, nWhichJM
);
107 AlignmentTabPage::AlignmentTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
108 : SfxTabPage(pPage
, pController
, "cui/ui/cellalignment.ui", "CellAlignPage", &rCoreAttrs
)
109 , m_aVsRefEdge(nullptr)
111 , m_xLbHorAlign(m_xBuilder
->weld_combo_box("comboboxHorzAlign"))
112 , m_xFtIndent(m_xBuilder
->weld_label("labelIndent"))
113 , m_xEdIndent(m_xBuilder
->weld_metric_spin_button("spinIndentFrom", FieldUnit::POINT
))
114 , m_xFtVerAlign(m_xBuilder
->weld_label("labelVertAlign"))
115 , m_xLbVerAlign(m_xBuilder
->weld_combo_box("comboboxVertAlign"))
117 , m_xFtRotate(m_xBuilder
->weld_label("labelDegrees"))
118 , m_xNfRotate(m_xBuilder
->weld_spin_button("spinDegrees"))
119 , m_xFtRefEdge(m_xBuilder
->weld_label("labelRefEdge"))
121 , m_xCbStacked(m_xBuilder
->weld_check_button("checkVertStack"))
122 , m_xCbAsianMode(m_xBuilder
->weld_check_button("checkAsianMode"))
124 , m_xBoxDirection(m_xBuilder
->weld_widget("boxDirection"))
125 , m_xBtnWrap(m_xBuilder
->weld_check_button("checkWrapTextAuto"))
126 , m_xBtnHyphen(m_xBuilder
->weld_check_button("checkHyphActive"))
127 , m_xBtnShrink(m_xBuilder
->weld_check_button("checkShrinkFitCellSize"))
128 , m_xLbFrameDir(new svx::FrameDirectionListBox(m_xBuilder
->weld_combo_box("comboTextDirBox")))
129 //ValueSet hover strings
130 , m_xFtBotLock(m_xBuilder
->weld_label("labelSTR_BOTTOMLOCK"))
131 , m_xFtTopLock(m_xBuilder
->weld_label("labelSTR_TOPLOCK"))
132 , m_xFtCelLock(m_xBuilder
->weld_label("labelSTR_CELLLOCK"))
133 , m_xFtABCD(m_xBuilder
->weld_label("labelABCD"))
134 , m_xAlignmentFrame(m_xBuilder
->weld_widget("alignment"))
135 , m_xOrientFrame(m_xBuilder
->weld_widget("orientation"))
136 , m_xPropertiesFrame(m_xBuilder
->weld_widget("properties"))
137 , m_xVsRefEdge(new weld::CustomWeld(*m_xBuilder
, "references", m_aVsRefEdge
))
138 , m_xCtrlDial(new weld::CustomWeld(*m_xBuilder
, "dialcontrol", m_aCtrlDial
))
140 m_aCtrlDial
.SetLinkedField(m_xNfRotate
.get());
141 m_aCtrlDial
.SetText(m_xFtABCD
->get_label());
145 m_xLbHorAlign
->connect_changed(LINK(this, AlignmentTabPage
, UpdateEnableHdl
));
147 m_xCbStacked
->connect_toggled(LINK(this, AlignmentTabPage
, StackedClickHdl
));
148 m_xCbAsianMode
->connect_toggled(LINK(this, AlignmentTabPage
, AsianModeClickHdl
));
149 m_xBtnWrap
->connect_toggled(LINK(this, AlignmentTabPage
, WrapClickHdl
));
150 m_xBtnHyphen
->connect_toggled(LINK(this, AlignmentTabPage
, HyphenClickHdl
));
151 m_xBtnShrink
->connect_toggled(LINK(this, AlignmentTabPage
, ShrinkClickHdl
));
153 // Asian vertical mode
154 m_xCbAsianMode
->set_visible(SvtCJKOptions().IsVerticalTextEnabled());
156 m_xLbFrameDir
->append(SvxFrameDirection::Horizontal_LR_TB
, SvxResId(RID_SVXSTR_FRAMEDIR_LTR
));
157 m_xLbFrameDir
->append(SvxFrameDirection::Horizontal_RL_TB
, SvxResId(RID_SVXSTR_FRAMEDIR_RTL
));
158 m_xLbFrameDir
->append(SvxFrameDirection::Environment
, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER
));
160 // This page needs ExchangeSupport.
161 SetExchangeSupport();
164 AlignmentTabPage::~AlignmentTabPage()
167 m_xVsRefEdge
.reset();
168 m_xLbFrameDir
.reset();
171 std::unique_ptr
<SfxTabPage
> AlignmentTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrSet
)
173 return std::make_unique
<AlignmentTabPage
>(pPage
, pController
, *rAttrSet
);
176 bool AlignmentTabPage::FillItemSet( SfxItemSet
* rSet
)
178 const SfxItemSet
& rOldSet
= GetItemSet();
180 bool bChanged
= SfxTabPage::FillItemSet(rSet
);
182 if (m_xLbHorAlign
->get_value_changed_from_saved())
184 SvxCellHorJustify
eJustify(SvxCellHorJustify::Standard
);
185 switch (m_xLbHorAlign
->get_active_id().toInt32())
187 case ALIGNDLG_HORALIGN_STD
:
188 eJustify
= SvxCellHorJustify::Standard
;
190 case ALIGNDLG_HORALIGN_LEFT
:
191 eJustify
= SvxCellHorJustify::Left
;
193 case ALIGNDLG_HORALIGN_CENTER
:
194 eJustify
= SvxCellHorJustify::Center
;
196 case ALIGNDLG_HORALIGN_RIGHT
:
197 eJustify
= SvxCellHorJustify::Right
;
199 case ALIGNDLG_HORALIGN_BLOCK
:
200 case ALIGNDLG_HORALIGN_DISTRIBUTED
:
201 eJustify
= SvxCellHorJustify::Block
;
203 case ALIGNDLG_HORALIGN_FILL
:
204 eJustify
= SvxCellHorJustify::Repeat
;
207 rSet
->Put(SvxHorJustifyItem(eJustify
, GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY
)));
211 if (m_xEdIndent
->get_value_changed_from_saved())
213 rSet
->Put(SfxUInt16Item(GetWhich(SID_ATTR_ALIGN_INDENT
), m_xEdIndent
->get_value(FieldUnit::TWIP
)));
217 if (m_xLbVerAlign
->get_value_changed_from_saved())
219 SvxCellVerJustify
eJustify(SvxCellVerJustify::Standard
);
220 switch (m_xLbVerAlign
->get_active_id().toInt32())
222 case ALIGNDLG_VERALIGN_STD
:
223 eJustify
= SvxCellVerJustify::Standard
;
225 case ALIGNDLG_VERALIGN_TOP
:
226 eJustify
= SvxCellVerJustify::Top
;
228 case ALIGNDLG_VERALIGN_MID
:
229 eJustify
= SvxCellVerJustify::Center
;
231 case ALIGNDLG_VERALIGN_BOTTOM
:
232 eJustify
= SvxCellVerJustify::Bottom
;
234 case ALIGNDLG_VERALIGN_BLOCK
:
235 case ALIGNDLG_VERALIGN_DISTRIBUTED
:
236 eJustify
= SvxCellVerJustify::Block
;
239 rSet
->Put(SvxVerJustifyItem(eJustify
, GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY
)));
243 if (m_xNfRotate
->get_value_changed_from_saved())
245 rSet
->Put(SfxInt32Item(GetWhich(SID_ATTR_ALIGN_DEGREES
), m_aCtrlDial
.GetRotation()));
249 if (m_aVsRefEdge
.IsValueChangedFromSaved())
251 switch (m_aVsRefEdge
.GetSelectedItemId())
254 rSet
->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD
, GetWhich(SID_ATTR_ALIGN_LOCKPOS
)));
257 rSet
->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP
, GetWhich(SID_ATTR_ALIGN_LOCKPOS
)));
260 rSet
->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM
, GetWhich(SID_ATTR_ALIGN_LOCKPOS
)));
263 m_aVsRefEdge
.SetNoSelection();
269 if (m_xCbStacked
->get_state_changed_from_saved())
271 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_STACKED
), m_xCbStacked
->get_active()));
275 if (m_xCbAsianMode
->get_state_changed_from_saved())
277 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL
), m_xCbAsianMode
->get_active()));
281 if (m_xBtnWrap
->get_state_changed_from_saved())
283 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_LINEBREAK
), m_xBtnWrap
->get_active()));
287 if (m_xBtnHyphen
->get_state_changed_from_saved())
289 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_HYPHENATION
), m_xBtnHyphen
->get_active()));
293 if (m_xBtnShrink
->get_state_changed_from_saved())
295 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT
), m_xBtnShrink
->get_active()));
299 if (m_xLbFrameDir
->get_visible())
301 if (m_xLbFrameDir
->get_value_changed_from_saved())
303 SvxFrameDirection eDir
= m_xLbFrameDir
->get_active_id();
304 rSet
->Put(SvxFrameDirectionItem(eDir
, GetWhich(SID_ATTR_FRAMEDIRECTION
)));
309 // Special treatment for distributed alignment; we need to set the justify
310 // method to 'distribute' to distinguish from the normal justification.
312 sal_uInt16 nWhichHorJM
= GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD
);
313 lcl_SetJustifyMethodToItemSet(*rSet
, rOldSet
, nWhichHorJM
, *m_xLbHorAlign
, ALIGNDLG_HORALIGN_DISTRIBUTED
);
315 bChanged
= HasAlignmentChanged(*rSet
, nWhichHorJM
);
317 sal_uInt16 nWhichVerJM
= GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD
);
318 lcl_SetJustifyMethodToItemSet(*rSet
, rOldSet
, nWhichVerJM
, *m_xLbVerAlign
, ALIGNDLG_VERALIGN_DISTRIBUTED
);
320 bChanged
= HasAlignmentChanged(*rSet
, nWhichVerJM
);
327 void ResetBool(sal_uInt16 nWhich
, const SfxItemSet
* pSet
, weld::CheckButton
& rBtn
, weld::TriStateEnabled
& rTriState
)
329 SfxItemState eState
= pSet
->GetItemState(nWhich
);
332 case SfxItemState::UNKNOWN
:
334 rTriState
.bTriStateEnabled
= false;
336 case SfxItemState::DISABLED
:
337 case SfxItemState::READONLY
:
338 rBtn
.set_sensitive(false);
339 rTriState
.bTriStateEnabled
= false;
341 case SfxItemState::DONTCARE
:
342 rBtn
.set_state(TRISTATE_INDET
);
343 rTriState
.bTriStateEnabled
= true;
345 case SfxItemState::DEFAULT
:
346 case SfxItemState::SET
:
348 const SfxBoolItem
& rItem
= static_cast<const SfxBoolItem
&>(pSet
->Get(nWhich
));
349 rBtn
.set_state(static_cast<TriState
>(rItem
.GetValue()));
350 rTriState
.bTriStateEnabled
= false;
358 void AlignmentTabPage::Reset(const SfxItemSet
* pCoreAttrs
)
360 SfxTabPage::Reset(pCoreAttrs
);
362 ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED
), pCoreAttrs
, *m_xCbStacked
, m_aStackedState
);
363 ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL
), pCoreAttrs
, *m_xCbAsianMode
, m_aAsianModeState
);
364 ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK
), pCoreAttrs
, *m_xBtnWrap
, m_aWrapState
);
365 ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION
), pCoreAttrs
, *m_xBtnHyphen
, m_aHyphenState
);
366 ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT
), pCoreAttrs
, *m_xBtnShrink
, m_aShrinkState
);
368 sal_uInt16 nWhich
= GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY
);
369 SfxItemState eState
= pCoreAttrs
->GetItemState(nWhich
);
372 case SfxItemState::UNKNOWN
:
373 m_xLbHorAlign
->hide();
375 case SfxItemState::DISABLED
:
376 case SfxItemState::READONLY
:
377 m_xLbHorAlign
->set_sensitive(false);
379 case SfxItemState::DONTCARE
:
380 m_xLbHorAlign
->set_active(-1);
382 case SfxItemState::DEFAULT
:
383 case SfxItemState::SET
:
385 const SvxHorJustifyItem
& rJustifyItem
= static_cast<const SvxHorJustifyItem
&>(pCoreAttrs
->Get(nWhich
));
386 switch (rJustifyItem
.GetValue())
388 case SvxCellHorJustify::Standard
:
389 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_STD
));
391 case SvxCellHorJustify::Left
:
392 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_LEFT
));
394 case SvxCellHorJustify::Center
:
395 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_CENTER
));
397 case SvxCellHorJustify::Right
:
398 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_RIGHT
));
400 case SvxCellHorJustify::Block
:
401 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_BLOCK
));
403 case SvxCellHorJustify::Repeat
:
404 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_FILL
));
411 nWhich
= GetWhich(SID_ATTR_ALIGN_INDENT
);
412 eState
= pCoreAttrs
->GetItemState(nWhich
);
415 case SfxItemState::UNKNOWN
:
419 case SfxItemState::DISABLED
:
420 case SfxItemState::READONLY
:
421 m_xEdIndent
->set_sensitive(false);
423 case SfxItemState::DONTCARE
:
424 m_xEdIndent
->set_text("");
426 case SfxItemState::DEFAULT
:
427 case SfxItemState::SET
:
429 const SfxUInt16Item
& rIndentItem
= static_cast<const SfxUInt16Item
&>(pCoreAttrs
->Get(nWhich
));
430 m_xEdIndent
->set_value(rIndentItem
.GetValue(), FieldUnit::TWIP
);
435 nWhich
= GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY
);
436 eState
= pCoreAttrs
->GetItemState(nWhich
);
439 case SfxItemState::UNKNOWN
:
440 m_xLbVerAlign
->hide();
441 m_xFtVerAlign
->hide();
443 case SfxItemState::DISABLED
:
444 case SfxItemState::READONLY
:
445 m_xLbVerAlign
->set_sensitive(false);
447 case SfxItemState::DONTCARE
:
448 m_xLbVerAlign
->set_active(-1);
450 case SfxItemState::DEFAULT
:
451 case SfxItemState::SET
:
453 const SvxVerJustifyItem
& rJustifyItem
= static_cast<const SvxVerJustifyItem
&>(pCoreAttrs
->Get(nWhich
));
454 switch (rJustifyItem
.GetValue())
456 case SvxCellVerJustify::Standard
:
457 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_STD
));
459 case SvxCellVerJustify::Top
:
460 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_TOP
));
462 case SvxCellVerJustify::Center
:
463 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_MID
));
465 case SvxCellVerJustify::Bottom
:
466 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BOTTOM
));
468 case SvxCellVerJustify::Block
:
469 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BLOCK
));
476 nWhich
= GetWhich(SID_ATTR_ALIGN_DEGREES
);
477 eState
= pCoreAttrs
->GetItemState(nWhich
);
480 case SfxItemState::UNKNOWN
:
484 case SfxItemState::DISABLED
:
485 case SfxItemState::READONLY
:
486 m_xNfRotate
->set_sensitive(false);
487 m_xCtrlDial
->set_sensitive(false);
489 case SfxItemState::DONTCARE
:
490 m_aCtrlDial
.SetNoRotation();
492 case SfxItemState::DEFAULT
:
493 case SfxItemState::SET
:
495 const SfxInt32Item
& rAlignItem
= static_cast<const SfxInt32Item
&>(pCoreAttrs
->Get(nWhich
));
496 m_aCtrlDial
.SetRotation(rAlignItem
.GetValue());
501 nWhich
= GetWhich(SID_ATTR_ALIGN_LOCKPOS
);
502 eState
= pCoreAttrs
->GetItemState(nWhich
);
505 case SfxItemState::UNKNOWN
:
506 m_xVsRefEdge
->hide();
508 case SfxItemState::DISABLED
:
509 case SfxItemState::READONLY
:
510 m_xVsRefEdge
->set_sensitive(false);
512 case SfxItemState::DONTCARE
:
513 m_aVsRefEdge
.SetNoSelection();
515 case SfxItemState::DEFAULT
:
516 case SfxItemState::SET
:
518 const SvxRotateModeItem
& rRotateModeItem
= static_cast<const SvxRotateModeItem
&>(pCoreAttrs
->Get(nWhich
));
519 switch (rRotateModeItem
.GetValue())
521 case SvxRotateMode::SVX_ROTATE_MODE_STANDARD
:
522 m_aVsRefEdge
.SelectItem(IID_CELLLOCK
);
524 case SvxRotateMode::SVX_ROTATE_MODE_TOP
:
525 m_aVsRefEdge
.SelectItem(IID_TOPLOCK
);
527 case SvxRotateMode::SVX_ROTATE_MODE_BOTTOM
:
528 m_aVsRefEdge
.SelectItem(IID_BOTTOMLOCK
);
531 m_aVsRefEdge
.SetNoSelection();
537 m_aVsRefEdge
.SaveValue();
540 nWhich
= GetWhich(SID_ATTR_FRAMEDIRECTION
);
541 eState
= pCoreAttrs
->GetItemState(nWhich
);
544 case SfxItemState::UNKNOWN
:
545 m_xLbFrameDir
->hide();
547 case SfxItemState::DISABLED
:
548 case SfxItemState::READONLY
:
549 m_xLbFrameDir
->set_sensitive(false);
551 case SfxItemState::DONTCARE
:
552 m_xLbFrameDir
->set_active(-1);
554 case SfxItemState::DEFAULT
:
555 case SfxItemState::SET
:
557 const SvxFrameDirectionItem
& rFrameDirItem
= static_cast<const SvxFrameDirectionItem
&>(pCoreAttrs
->Get(nWhich
));
558 m_xLbFrameDir
->set_active_id(rFrameDirItem
.GetValue());
564 // Special treatment for distributed alignment; we need to set the justify
565 // method to 'distribute' to distinguish from the normal justification.
567 lcl_MaybeResetAlignToDistro
<SvxCellHorJustify
, SvxCellHorJustify
>(
568 *m_xLbHorAlign
, ALIGNDLG_HORALIGN_DISTRIBUTED
, *pCoreAttrs
,
569 GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY
), GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD
),
570 SvxCellHorJustify::Block
);
572 lcl_MaybeResetAlignToDistro
<SvxCellVerJustify
, SvxCellVerJustify
>(
573 *m_xLbVerAlign
, ALIGNDLG_VERALIGN_DISTRIBUTED
, *pCoreAttrs
,
574 GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY
), GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD
),
575 SvxCellVerJustify::Block
);
577 m_xLbHorAlign
->save_value();
578 m_xLbFrameDir
->save_value();
579 m_xLbVerAlign
->save_value();
580 m_xNfRotate
->save_value();
581 m_xEdIndent
->save_value();
583 UpdateEnableControls();
586 DeactivateRC
AlignmentTabPage::DeactivatePage( SfxItemSet
* _pSet
)
589 FillItemSet( _pSet
);
590 return DeactivateRC::LeavePage
;
593 void AlignmentTabPage::InitVsRefEgde()
595 // remember selection - is deleted in call to ValueSet::Clear()
596 sal_uInt16 nSel
= m_aVsRefEdge
.GetSelectedItemId();
598 Image
aBottomLock(StockImage::Yes
, RID_SVXBMP_BOTTOMLOCK
);
599 Image
aTopLock(StockImage::Yes
, RID_SVXBMP_TOPLOCK
);
600 Image
aCellLock(StockImage::Yes
, RID_SVXBMP_CELLLOCK
);
602 m_aVsRefEdge
.Clear();
603 m_aVsRefEdge
.SetStyle(m_aVsRefEdge
.GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
605 m_aVsRefEdge
.SetColCount(3);
606 m_aVsRefEdge
.InsertItem(IID_BOTTOMLOCK
, aBottomLock
, m_xFtBotLock
->get_label());
607 m_aVsRefEdge
.InsertItem(IID_TOPLOCK
, aTopLock
, m_xFtTopLock
->get_label());
608 m_aVsRefEdge
.InsertItem(IID_CELLLOCK
, aCellLock
, m_xFtCelLock
->get_label());
609 m_aVsRefEdge
.SetOptimalSize();
611 m_aVsRefEdge
.SelectItem( nSel
);
614 void AlignmentTabPage::UpdateEnableControls()
616 const sal_Int32 nHorAlign
= m_xLbHorAlign
->get_active();
617 bool bHorLeft
= (nHorAlign
== ALIGNDLG_HORALIGN_LEFT
);
618 bool bHorBlock
= (nHorAlign
== ALIGNDLG_HORALIGN_BLOCK
);
619 bool bHorFill
= (nHorAlign
== ALIGNDLG_HORALIGN_FILL
);
620 bool bHorDist
= (nHorAlign
== ALIGNDLG_HORALIGN_DISTRIBUTED
);
622 // indent edit field only for left alignment
623 m_xFtIndent
->set_sensitive( bHorLeft
);
624 m_xEdIndent
->set_sensitive( bHorLeft
);
626 // stacked disabled for fill alignment
627 m_xCbStacked
->set_sensitive(!bHorFill
);
629 // hyphenation only for automatic line breaks or for block alignment
630 m_xBtnHyphen
->set_sensitive( m_xBtnWrap
->get_active() || bHorBlock
);
632 // shrink only without automatic line break, and not for block, fill or distribute.
633 m_xBtnShrink
->set_sensitive( (m_xBtnWrap
->get_state() == TRISTATE_FALSE
) && !bHorBlock
&& !bHorFill
&& !bHorDist
);
635 // visibility of frames
636 m_xAlignmentFrame
->set_visible(m_xLbHorAlign
->get_visible() || m_xEdIndent
->get_visible() ||
637 m_xLbVerAlign
->get_visible());
638 m_xOrientFrame
->set_visible(m_xCtrlDial
->get_visible() || m_xVsRefEdge
->get_visible() ||
639 m_xCbStacked
->get_visible() || m_xCbAsianMode
->get_visible());
640 m_xPropertiesFrame
->set_visible(m_xBtnWrap
->get_visible() || m_xBtnHyphen
->get_visible() ||
641 m_xBtnShrink
->get_visible() || m_xLbFrameDir
->get_visible());
643 bool bStackedText
= m_xCbStacked
->get_active();
644 // windows to be disabled, if stacked text is turned ON
645 m_xFtRotate
->set_sensitive(!bStackedText
);
646 m_xFtRefEdge
->set_sensitive(!bStackedText
);
647 m_xVsRefEdge
->set_sensitive(!bStackedText
);
648 // windows to be disabled, if stacked text is turned OFF
649 m_xCbAsianMode
->set_sensitive(bStackedText
);
650 // rotation/stacked disabled for fill alignment/stacked
651 m_xCtrlDial
->set_sensitive(!bHorFill
&& !bStackedText
);
652 m_xNfRotate
->set_sensitive(!bHorFill
&& !bStackedText
);
655 bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet
& rNew
, sal_uInt16 nWhich
) const
657 const SfxItemSet
& rOld
= GetItemSet();
658 const SfxPoolItem
* pItem
;
659 SvxCellJustifyMethod eMethodOld
= SvxCellJustifyMethod::Auto
;
660 SvxCellJustifyMethod eMethodNew
= SvxCellJustifyMethod::Auto
;
661 if (rOld
.GetItemState(nWhich
, true, &pItem
) == SfxItemState::SET
)
663 const SfxEnumItemInterface
* p
= static_cast<const SfxEnumItemInterface
*>(pItem
);
664 eMethodOld
= static_cast<SvxCellJustifyMethod
>(p
->GetEnumValue());
667 if (rNew
.GetItemState(nWhich
, true, &pItem
) == SfxItemState::SET
)
669 const SfxEnumItemInterface
* p
= static_cast<const SfxEnumItemInterface
*>(pItem
);
670 eMethodNew
= static_cast<SvxCellJustifyMethod
>(p
->GetEnumValue());
673 return eMethodOld
!= eMethodNew
;
676 IMPL_LINK(AlignmentTabPage
, StackedClickHdl
, weld::ToggleButton
&, rToggle
, void)
678 m_aStackedState
.ButtonToggled(rToggle
);
679 UpdateEnableControls();
682 IMPL_LINK(AlignmentTabPage
, AsianModeClickHdl
, weld::ToggleButton
&, rToggle
, void)
684 m_aAsianModeState
.ButtonToggled(rToggle
);
687 IMPL_LINK(AlignmentTabPage
, WrapClickHdl
, weld::ToggleButton
&, rToggle
, void)
689 m_aWrapState
.ButtonToggled(rToggle
);
690 UpdateEnableControls();
693 IMPL_LINK(AlignmentTabPage
, HyphenClickHdl
, weld::ToggleButton
&, rToggle
, void)
695 m_aHyphenState
.ButtonToggled(rToggle
);
698 IMPL_LINK(AlignmentTabPage
, ShrinkClickHdl
, weld::ToggleButton
&, rToggle
, void)
700 m_aShrinkState
.ButtonToggled(rToggle
);
703 IMPL_LINK_NOARG(AlignmentTabPage
, UpdateEnableHdl
, weld::ComboBox
&, void)
705 UpdateEnableControls();
710 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */