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
, 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 SvxJustifyMethodItem
aItem(eJM
, nWhichJM
);
99 AlignmentTabPage::AlignmentTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
100 : SfxTabPage(pPage
, pController
, "cui/ui/cellalignment.ui", "CellAlignPage", &rCoreAttrs
)
101 , m_aVsRefEdge(nullptr)
103 , m_xLbHorAlign(m_xBuilder
->weld_combo_box("comboboxHorzAlign"))
104 , m_xFtIndent(m_xBuilder
->weld_label("labelIndent"))
105 , m_xEdIndent(m_xBuilder
->weld_metric_spin_button("spinIndentFrom", FieldUnit::POINT
))
106 , m_xFtVerAlign(m_xBuilder
->weld_label("labelVertAlign"))
107 , m_xLbVerAlign(m_xBuilder
->weld_combo_box("comboboxVertAlign"))
109 , m_xFtRotate(m_xBuilder
->weld_label("labelDegrees"))
110 , m_xNfRotate(m_xBuilder
->weld_spin_button("spinDegrees"))
111 , m_xFtRefEdge(m_xBuilder
->weld_label("labelRefEdge"))
113 , m_xCbStacked(m_xBuilder
->weld_check_button("checkVertStack"))
114 , m_xCbAsianMode(m_xBuilder
->weld_check_button("checkAsianMode"))
116 , m_xBoxDirection(m_xBuilder
->weld_widget("boxDirection"))
117 , m_xBtnWrap(m_xBuilder
->weld_check_button("checkWrapTextAuto"))
118 , m_xBtnHyphen(m_xBuilder
->weld_check_button("checkHyphActive"))
119 , m_xBtnShrink(m_xBuilder
->weld_check_button("checkShrinkFitCellSize"))
120 , m_xLbFrameDir(new svx::FrameDirectionListBox(m_xBuilder
->weld_combo_box("comboTextDirBox")))
121 //ValueSet hover strings
122 , m_xFtBotLock(m_xBuilder
->weld_label("labelSTR_BOTTOMLOCK"))
123 , m_xFtTopLock(m_xBuilder
->weld_label("labelSTR_TOPLOCK"))
124 , m_xFtCelLock(m_xBuilder
->weld_label("labelSTR_CELLLOCK"))
125 , m_xFtABCD(m_xBuilder
->weld_label("labelABCD"))
126 , m_xAlignmentFrame(m_xBuilder
->weld_widget("alignment"))
127 , m_xOrientFrame(m_xBuilder
->weld_widget("orientation"))
128 , m_xPropertiesFrame(m_xBuilder
->weld_widget("properties"))
129 , m_xVsRefEdge(new weld::CustomWeld(*m_xBuilder
, "references", m_aVsRefEdge
))
130 , m_xCtrlDial(new weld::CustomWeld(*m_xBuilder
, "dialcontrol", m_aCtrlDial
))
132 m_aCtrlDial
.SetLinkedField(m_xNfRotate
.get());
133 m_aCtrlDial
.SetText(m_xFtABCD
->get_label());
137 m_xLbHorAlign
->connect_changed(LINK(this, AlignmentTabPage
, UpdateEnableHdl
));
139 m_xCbStacked
->connect_toggled(LINK(this, AlignmentTabPage
, StackedClickHdl
));
140 m_xCbAsianMode
->connect_toggled(LINK(this, AlignmentTabPage
, AsianModeClickHdl
));
141 m_xBtnWrap
->connect_toggled(LINK(this, AlignmentTabPage
, WrapClickHdl
));
142 m_xBtnHyphen
->connect_toggled(LINK(this, AlignmentTabPage
, HyphenClickHdl
));
143 m_xBtnShrink
->connect_toggled(LINK(this, AlignmentTabPage
, ShrinkClickHdl
));
145 // Asian vertical mode
146 m_xCbAsianMode
->set_visible(SvtCJKOptions().IsVerticalTextEnabled());
148 m_xLbFrameDir
->append(SvxFrameDirection::Horizontal_LR_TB
, SvxResId(RID_SVXSTR_FRAMEDIR_LTR
));
149 m_xLbFrameDir
->append(SvxFrameDirection::Horizontal_RL_TB
, SvxResId(RID_SVXSTR_FRAMEDIR_RTL
));
150 m_xLbFrameDir
->append(SvxFrameDirection::Environment
, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER
));
152 // This page needs ExchangeSupport.
153 SetExchangeSupport();
156 AlignmentTabPage::~AlignmentTabPage()
159 m_xVsRefEdge
.reset();
160 m_xLbFrameDir
.reset();
163 std::unique_ptr
<SfxTabPage
> AlignmentTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrSet
)
165 return std::make_unique
<AlignmentTabPage
>(pPage
, pController
, *rAttrSet
);
168 bool AlignmentTabPage::FillItemSet( SfxItemSet
* rSet
)
170 bool bChanged
= SfxTabPage::FillItemSet(rSet
);
172 if (m_xLbHorAlign
->get_value_changed_from_saved())
174 SvxCellHorJustify
eJustify(SvxCellHorJustify::Standard
);
175 switch (m_xLbHorAlign
->get_active_id().toInt32())
177 case ALIGNDLG_HORALIGN_STD
:
178 eJustify
= SvxCellHorJustify::Standard
;
180 case ALIGNDLG_HORALIGN_LEFT
:
181 eJustify
= SvxCellHorJustify::Left
;
183 case ALIGNDLG_HORALIGN_CENTER
:
184 eJustify
= SvxCellHorJustify::Center
;
186 case ALIGNDLG_HORALIGN_RIGHT
:
187 eJustify
= SvxCellHorJustify::Right
;
189 case ALIGNDLG_HORALIGN_BLOCK
:
190 eJustify
= SvxCellHorJustify::Block
;
192 case ALIGNDLG_HORALIGN_FILL
:
193 eJustify
= SvxCellHorJustify::Repeat
;
196 rSet
->Put(SvxHorJustifyItem(eJustify
, GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY
)));
200 if (m_xEdIndent
->get_value_changed_from_saved())
202 rSet
->Put(SfxUInt16Item(GetWhich(SID_ATTR_ALIGN_INDENT
), m_xEdIndent
->get_value(FieldUnit::TWIP
)));
206 if (m_xLbVerAlign
->get_value_changed_from_saved())
208 SvxCellVerJustify
eJustify(SvxCellVerJustify::Standard
);
209 switch (m_xLbVerAlign
->get_active_id().toInt32())
211 case ALIGNDLG_VERALIGN_STD
:
212 eJustify
= SvxCellVerJustify::Standard
;
214 case ALIGNDLG_VERALIGN_TOP
:
215 eJustify
= SvxCellVerJustify::Top
;
217 case ALIGNDLG_VERALIGN_MID
:
218 eJustify
= SvxCellVerJustify::Center
;
220 case ALIGNDLG_VERALIGN_BOTTOM
:
221 eJustify
= SvxCellVerJustify::Bottom
;
223 case ALIGNDLG_VERALIGN_BLOCK
:
224 eJustify
= SvxCellVerJustify::Block
;
227 rSet
->Put(SvxVerJustifyItem(eJustify
, GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY
)));
231 if (m_xNfRotate
->get_value_changed_from_saved())
233 rSet
->Put(SfxInt32Item(GetWhich(SID_ATTR_ALIGN_DEGREES
), m_aCtrlDial
.GetRotation()));
237 if (m_aVsRefEdge
.IsValueChangedFromSaved())
239 switch (m_aVsRefEdge
.GetSelectedItemId())
242 rSet
->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD
, GetWhich(SID_ATTR_ALIGN_LOCKPOS
)));
245 rSet
->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP
, GetWhich(SID_ATTR_ALIGN_LOCKPOS
)));
248 rSet
->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM
, GetWhich(SID_ATTR_ALIGN_LOCKPOS
)));
251 m_aVsRefEdge
.SetNoSelection();
257 if (m_xCbStacked
->get_state_changed_from_saved())
259 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_STACKED
), m_xCbStacked
->get_active()));
263 if (m_xCbAsianMode
->get_state_changed_from_saved())
265 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL
), m_xCbAsianMode
->get_active()));
269 if (m_xBtnWrap
->get_state_changed_from_saved())
271 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_LINEBREAK
), m_xBtnWrap
->get_active()));
275 if (m_xBtnHyphen
->get_state_changed_from_saved())
277 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_HYPHENATION
), m_xBtnHyphen
->get_active()));
281 if (m_xBtnShrink
->get_state_changed_from_saved())
283 rSet
->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT
), m_xBtnShrink
->get_active()));
287 if (m_xLbFrameDir
->get_visible())
289 if (m_xLbFrameDir
->get_value_changed_from_saved())
291 SvxFrameDirection eDir
= m_xLbFrameDir
->get_active_id();
292 rSet
->Put(SvxFrameDirectionItem(eDir
, GetWhich(SID_ATTR_FRAMEDIRECTION
)));
297 // Special treatment for distributed alignment; we need to set the justify
298 // method to 'distribute' to distinguish from the normal justification.
300 sal_uInt16 nWhichHorJM
= GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD
);
301 lcl_SetJustifyMethodToItemSet(*rSet
, nWhichHorJM
, *m_xLbHorAlign
, ALIGNDLG_HORALIGN_DISTRIBUTED
);
303 bChanged
= HasAlignmentChanged(*rSet
, nWhichHorJM
);
305 sal_uInt16 nWhichVerJM
= GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD
);
306 lcl_SetJustifyMethodToItemSet(*rSet
, nWhichVerJM
, *m_xLbVerAlign
, ALIGNDLG_VERALIGN_DISTRIBUTED
);
308 bChanged
= HasAlignmentChanged(*rSet
, nWhichVerJM
);
315 void ResetBool(sal_uInt16 nWhich
, const SfxItemSet
* pSet
, weld::CheckButton
& rBtn
, weld::TriStateEnabled
& rTriState
)
317 SfxItemState eState
= pSet
->GetItemState(nWhich
);
320 case SfxItemState::UNKNOWN
:
322 rTriState
.bTriStateEnabled
= false;
324 case SfxItemState::DISABLED
:
325 case SfxItemState::READONLY
:
326 rBtn
.set_sensitive(false);
327 rTriState
.bTriStateEnabled
= false;
329 case SfxItemState::DONTCARE
:
330 rBtn
.set_state(TRISTATE_INDET
);
331 rTriState
.bTriStateEnabled
= true;
333 case SfxItemState::DEFAULT
:
334 case SfxItemState::SET
:
336 const SfxBoolItem
& rItem
= static_cast<const SfxBoolItem
&>(pSet
->Get(nWhich
));
337 rBtn
.set_state(static_cast<TriState
>(rItem
.GetValue()));
338 rTriState
.bTriStateEnabled
= false;
346 void AlignmentTabPage::Reset(const SfxItemSet
* pCoreAttrs
)
348 SfxTabPage::Reset(pCoreAttrs
);
350 ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED
), pCoreAttrs
, *m_xCbStacked
, m_aStackedState
);
351 ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL
), pCoreAttrs
, *m_xCbAsianMode
, m_aAsianModeState
);
352 ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK
), pCoreAttrs
, *m_xBtnWrap
, m_aWrapState
);
353 ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION
), pCoreAttrs
, *m_xBtnHyphen
, m_aHyphenState
);
354 ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT
), pCoreAttrs
, *m_xBtnShrink
, m_aShrinkState
);
356 sal_uInt16 nWhich
= GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY
);
357 SfxItemState eState
= pCoreAttrs
->GetItemState(nWhich
);
360 case SfxItemState::UNKNOWN
:
361 m_xLbHorAlign
->hide();
363 case SfxItemState::DISABLED
:
364 case SfxItemState::READONLY
:
365 m_xLbHorAlign
->set_sensitive(false);
367 case SfxItemState::DONTCARE
:
368 m_xLbHorAlign
->set_active(-1);
370 case SfxItemState::DEFAULT
:
371 case SfxItemState::SET
:
373 const SvxHorJustifyItem
& rJustifyItem
= static_cast<const SvxHorJustifyItem
&>(pCoreAttrs
->Get(nWhich
));
374 switch (rJustifyItem
.GetValue())
376 case SvxCellHorJustify::Standard
:
377 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_STD
));
379 case SvxCellHorJustify::Left
:
380 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_LEFT
));
382 case SvxCellHorJustify::Center
:
383 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_CENTER
));
385 case SvxCellHorJustify::Right
:
386 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_RIGHT
));
388 case SvxCellHorJustify::Block
:
389 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_BLOCK
));
391 case SvxCellHorJustify::Repeat
:
392 m_xLbHorAlign
->set_active_id(OUString::number(ALIGNDLG_HORALIGN_FILL
));
399 nWhich
= GetWhich(SID_ATTR_ALIGN_INDENT
);
400 eState
= pCoreAttrs
->GetItemState(nWhich
);
403 case SfxItemState::UNKNOWN
:
407 case SfxItemState::DISABLED
:
408 case SfxItemState::READONLY
:
409 m_xEdIndent
->set_sensitive(false);
411 case SfxItemState::DONTCARE
:
412 m_xEdIndent
->set_text("");
414 case SfxItemState::DEFAULT
:
415 case SfxItemState::SET
:
417 const SfxUInt16Item
& rIndentItem
= static_cast<const SfxUInt16Item
&>(pCoreAttrs
->Get(nWhich
));
418 m_xEdIndent
->set_value(rIndentItem
.GetValue(), FieldUnit::TWIP
);
423 nWhich
= GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY
);
424 eState
= pCoreAttrs
->GetItemState(nWhich
);
427 case SfxItemState::UNKNOWN
:
428 m_xLbVerAlign
->hide();
429 m_xFtVerAlign
->hide();
431 case SfxItemState::DISABLED
:
432 case SfxItemState::READONLY
:
433 m_xLbVerAlign
->set_sensitive(false);
435 case SfxItemState::DONTCARE
:
436 m_xLbVerAlign
->set_active(-1);
438 case SfxItemState::DEFAULT
:
439 case SfxItemState::SET
:
441 const SvxVerJustifyItem
& rJustifyItem
= static_cast<const SvxVerJustifyItem
&>(pCoreAttrs
->Get(nWhich
));
442 switch (rJustifyItem
.GetValue())
444 case SvxCellVerJustify::Standard
:
445 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_STD
));
447 case SvxCellVerJustify::Top
:
448 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_TOP
));
450 case SvxCellVerJustify::Center
:
451 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_MID
));
453 case SvxCellVerJustify::Bottom
:
454 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BOTTOM
));
456 case SvxCellVerJustify::Block
:
457 m_xLbVerAlign
->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BLOCK
));
464 nWhich
= GetWhich(SID_ATTR_ALIGN_DEGREES
);
465 eState
= pCoreAttrs
->GetItemState(nWhich
);
468 case SfxItemState::UNKNOWN
:
472 case SfxItemState::DISABLED
:
473 case SfxItemState::READONLY
:
474 m_xNfRotate
->set_sensitive(false);
475 m_xCtrlDial
->set_sensitive(false);
477 case SfxItemState::DONTCARE
:
478 m_aCtrlDial
.SetNoRotation();
480 case SfxItemState::DEFAULT
:
481 case SfxItemState::SET
:
483 const SfxInt32Item
& rAlignItem
= static_cast<const SfxInt32Item
&>(pCoreAttrs
->Get(nWhich
));
484 m_aCtrlDial
.SetRotation(rAlignItem
.GetValue());
489 nWhich
= GetWhich(SID_ATTR_ALIGN_LOCKPOS
);
490 eState
= pCoreAttrs
->GetItemState(nWhich
);
493 case SfxItemState::UNKNOWN
:
494 m_xVsRefEdge
->hide();
496 case SfxItemState::DISABLED
:
497 case SfxItemState::READONLY
:
498 m_xVsRefEdge
->set_sensitive(false);
500 case SfxItemState::DONTCARE
:
501 m_aVsRefEdge
.SetNoSelection();
503 case SfxItemState::DEFAULT
:
504 case SfxItemState::SET
:
506 const SvxRotateModeItem
& rRotateModeItem
= static_cast<const SvxRotateModeItem
&>(pCoreAttrs
->Get(nWhich
));
507 switch (rRotateModeItem
.GetValue())
509 case SvxRotateMode::SVX_ROTATE_MODE_STANDARD
:
510 m_aVsRefEdge
.SelectItem(IID_CELLLOCK
);
512 case SvxRotateMode::SVX_ROTATE_MODE_TOP
:
513 m_aVsRefEdge
.SelectItem(IID_TOPLOCK
);
515 case SvxRotateMode::SVX_ROTATE_MODE_BOTTOM
:
516 m_aVsRefEdge
.SelectItem(IID_BOTTOMLOCK
);
519 m_aVsRefEdge
.SetNoSelection();
525 m_aVsRefEdge
.SaveValue();
528 nWhich
= GetWhich(SID_ATTR_FRAMEDIRECTION
);
529 eState
= pCoreAttrs
->GetItemState(nWhich
);
532 case SfxItemState::UNKNOWN
:
533 m_xLbFrameDir
->hide();
535 case SfxItemState::DISABLED
:
536 case SfxItemState::READONLY
:
537 m_xLbFrameDir
->set_sensitive(false);
539 case SfxItemState::DONTCARE
:
540 m_xLbFrameDir
->set_active(-1);
542 case SfxItemState::DEFAULT
:
543 case SfxItemState::SET
:
545 const SvxFrameDirectionItem
& rFrameDirItem
= static_cast<const SvxFrameDirectionItem
&>(pCoreAttrs
->Get(nWhich
));
546 m_xLbFrameDir
->set_active_id(rFrameDirItem
.GetValue());
552 // Special treatment for distributed alignment; we need to set the justify
553 // method to 'distribute' to distinguish from the normal justification.
555 lcl_MaybeResetAlignToDistro
<SvxCellHorJustify
, SvxCellHorJustify
>(
556 *m_xLbHorAlign
, ALIGNDLG_HORALIGN_DISTRIBUTED
, *pCoreAttrs
,
557 GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY
), GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD
),
558 SvxCellHorJustify::Block
);
560 lcl_MaybeResetAlignToDistro
<SvxCellVerJustify
, SvxCellVerJustify
>(
561 *m_xLbVerAlign
, ALIGNDLG_VERALIGN_DISTRIBUTED
, *pCoreAttrs
,
562 GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY
), GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD
),
563 SvxCellVerJustify::Block
);
565 m_xLbHorAlign
->save_value();
566 m_xLbFrameDir
->save_value();
567 m_xLbVerAlign
->save_value();
568 m_xNfRotate
->save_value();
569 m_xEdIndent
->save_value();
571 UpdateEnableControls();
574 DeactivateRC
AlignmentTabPage::DeactivatePage( SfxItemSet
* _pSet
)
577 FillItemSet( _pSet
);
578 return DeactivateRC::LeavePage
;
581 void AlignmentTabPage::InitVsRefEgde()
583 // remember selection - is deleted in call to ValueSet::Clear()
584 sal_uInt16 nSel
= m_aVsRefEdge
.GetSelectedItemId();
586 Image
aBottomLock(StockImage::Yes
, RID_SVXBMP_BOTTOMLOCK
);
587 Image
aTopLock(StockImage::Yes
, RID_SVXBMP_TOPLOCK
);
588 Image
aCellLock(StockImage::Yes
, RID_SVXBMP_CELLLOCK
);
590 m_aVsRefEdge
.Clear();
591 m_aVsRefEdge
.SetStyle(m_aVsRefEdge
.GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
593 m_aVsRefEdge
.SetColCount(3);
594 m_aVsRefEdge
.InsertItem(IID_BOTTOMLOCK
, aBottomLock
, m_xFtBotLock
->get_label());
595 m_aVsRefEdge
.InsertItem(IID_TOPLOCK
, aTopLock
, m_xFtTopLock
->get_label());
596 m_aVsRefEdge
.InsertItem(IID_CELLLOCK
, aCellLock
, m_xFtCelLock
->get_label());
597 m_aVsRefEdge
.SetOptimalSize();
599 m_aVsRefEdge
.SelectItem( nSel
);
602 void AlignmentTabPage::UpdateEnableControls()
604 const sal_Int32 nHorAlign
= m_xLbHorAlign
->get_active();
605 bool bHorLeft
= (nHorAlign
== ALIGNDLG_HORALIGN_LEFT
);
606 bool bHorBlock
= (nHorAlign
== ALIGNDLG_HORALIGN_BLOCK
);
607 bool bHorFill
= (nHorAlign
== ALIGNDLG_HORALIGN_FILL
);
608 bool bHorDist
= (nHorAlign
== ALIGNDLG_HORALIGN_DISTRIBUTED
);
610 // indent edit field only for left alignment
611 m_xFtIndent
->set_sensitive( bHorLeft
);
612 m_xEdIndent
->set_sensitive( bHorLeft
);
614 // stacked disabled for fill alignment
615 m_xCbStacked
->set_sensitive(!bHorFill
);
617 // hyphenation only for automatic line breaks or for block alignment
618 m_xBtnHyphen
->set_sensitive( m_xBtnWrap
->get_active() || bHorBlock
);
620 // shrink only without automatic line break, and not for block, fill or distribute.
621 m_xBtnShrink
->set_sensitive( (m_xBtnWrap
->get_state() == TRISTATE_FALSE
) && !bHorBlock
&& !bHorFill
&& !bHorDist
);
623 // visibility of frames
624 m_xAlignmentFrame
->set_visible(m_xLbHorAlign
->get_visible() || m_xEdIndent
->get_visible() ||
625 m_xLbVerAlign
->get_visible());
626 m_xOrientFrame
->set_visible(m_xCtrlDial
->get_visible() || m_xVsRefEdge
->get_visible() ||
627 m_xCbStacked
->get_visible() || m_xCbAsianMode
->get_visible());
628 m_xPropertiesFrame
->set_visible(m_xBtnWrap
->get_visible() || m_xBtnHyphen
->get_visible() ||
629 m_xBtnShrink
->get_visible() || m_xLbFrameDir
->get_visible());
631 bool bStackedText
= m_xCbStacked
->get_active();
632 // windows to be disabled, if stacked text is turned ON
633 m_xFtRotate
->set_sensitive(!bStackedText
);
634 m_xFtRefEdge
->set_sensitive(!bStackedText
);
635 m_xVsRefEdge
->set_sensitive(!bStackedText
);
636 // windows to be disabled, if stacked text is turned OFF
637 m_xCbAsianMode
->set_sensitive(bStackedText
);
638 // rotation/stacked disabled for fill alignment/stacked
639 m_xCtrlDial
->set_sensitive(!bHorFill
&& !bStackedText
);
640 m_xNfRotate
->set_sensitive(!bHorFill
&& !bStackedText
);
643 bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet
& rNew
, sal_uInt16 nWhich
) const
645 const SfxItemSet
& rOld
= GetItemSet();
646 const SfxPoolItem
* pItem
;
647 SvxCellJustifyMethod eMethodOld
= SvxCellJustifyMethod::Auto
;
648 SvxCellJustifyMethod eMethodNew
= SvxCellJustifyMethod::Auto
;
649 if (rOld
.GetItemState(nWhich
, true, &pItem
) == SfxItemState::SET
)
651 const SfxEnumItemInterface
* p
= static_cast<const SfxEnumItemInterface
*>(pItem
);
652 eMethodOld
= static_cast<SvxCellJustifyMethod
>(p
->GetEnumValue());
655 if (rNew
.GetItemState(nWhich
, true, &pItem
) == SfxItemState::SET
)
657 const SfxEnumItemInterface
* p
= static_cast<const SfxEnumItemInterface
*>(pItem
);
658 eMethodNew
= static_cast<SvxCellJustifyMethod
>(p
->GetEnumValue());
661 return eMethodOld
!= eMethodNew
;
664 IMPL_LINK(AlignmentTabPage
, StackedClickHdl
, weld::ToggleButton
&, rToggle
, void)
666 m_aStackedState
.ButtonToggled(rToggle
);
667 UpdateEnableControls();
670 IMPL_LINK(AlignmentTabPage
, AsianModeClickHdl
, weld::ToggleButton
&, rToggle
, void)
672 m_aAsianModeState
.ButtonToggled(rToggle
);
675 IMPL_LINK(AlignmentTabPage
, WrapClickHdl
, weld::ToggleButton
&, rToggle
, void)
677 m_aWrapState
.ButtonToggled(rToggle
);
678 UpdateEnableControls();
681 IMPL_LINK(AlignmentTabPage
, HyphenClickHdl
, weld::ToggleButton
&, rToggle
, void)
683 m_aHyphenState
.ButtonToggled(rToggle
);
686 IMPL_LINK(AlignmentTabPage
, ShrinkClickHdl
, weld::ToggleButton
&, rToggle
, void)
688 m_aShrinkState
.ButtonToggled(rToggle
);
691 IMPL_LINK_NOARG(AlignmentTabPage
, UpdateEnableHdl
, weld::ComboBox
&, void)
693 UpdateEnableControls();
698 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */