LibreOffice Module cui (master)  1
align.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 <align.hxx>
21 
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>
28 #include <svx/sdangitm.hxx>
29 
30 #include <editeng/frmdiritem.hxx>
31 #include <editeng/justifyitem.hxx>
32 #include <svl/cjkoptions.hxx>
33 #include <svl/intitem.hxx>
34 #include <vcl/image.hxx>
35 
36 #define IID_BOTTOMLOCK 1
37 #define IID_TOPLOCK 2
38 #define IID_CELLLOCK 3
39 
40 namespace svx {
41 
42 const sal_uInt16 AlignmentTabPage::s_pRanges[] =
43 {
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,
53  0
54 };
55 
56 
57 namespace {
58 
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)
62 {
63  const SfxPoolItem* pItem;
64  if (rCoreAttrs.GetItemState(nWhichAlign, true, &pItem) != SfxItemState::SET)
65  // alignment not set.
66  return;
67 
68  const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem);
69  JustContainerType eVal = static_cast<JustContainerType>(p->GetEnumValue());
70  if (eVal != eBlock)
71  // alignment is not 'justify'. No need to go further.
72  return;
73 
74  if (rCoreAttrs.GetItemState(nWhichJM, true, &pItem) != SfxItemState::SET)
75  // justification method is not set.
76  return;
77 
78  p = static_cast<const SfxEnumItemInterface*>(pItem);
79  SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
80  if (eMethod == SvxCellJustifyMethod::Distribute)
81  {
82  // Select the 'distribute' entry in the specified list box.
83  rLB.set_active(nListPos);
84  }
85 }
86 
87 void lcl_SetJustifyMethodToItemSet(SfxItemSet& rSet, const SfxItemSet& rOldSet, sal_uInt16 nWhichJM, const weld::ComboBox& rLB, sal_uInt16 nListPos)
88 {
89  SvxCellJustifyMethod eJM = SvxCellJustifyMethod::Auto;
90  if (rLB.get_active() == nListPos)
91  eJM = SvxCellJustifyMethod::Distribute;
92 
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)
96  {
97  rSet.InvalidateItem(nWhichJM);
98  return;
99  }
100 
101  SvxJustifyMethodItem aItem(eJM, nWhichJM);
102  rSet.Put(aItem);
103 }
104 
105 }//namespace
106 
108  : SfxTabPage(pPage, pController, "cui/ui/cellalignment.ui", "CellAlignPage", &rCoreAttrs)
109  , m_aVsRefEdge(nullptr)
110  // text alignment
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"))
116  //text rotation
117  , m_xFtRotate(m_xBuilder->weld_label("labelDegrees"))
118  , m_xNfRotate(m_xBuilder->weld_metric_spin_button("spinDegrees", FieldUnit::DEGREE))
119  , m_xFtRefEdge(m_xBuilder->weld_label("labelRefEdge"))
120  //Asian mode
121  , m_xCbStacked(m_xBuilder->weld_check_button("checkVertStack"))
122  , m_xCbAsianMode(m_xBuilder->weld_check_button("checkAsianMode"))
123  // Properties
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 DialControl)
139  , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, "dialcontrol", *m_xCtrlDial))
140 {
141  m_xCtrlDial->SetLinkedField(m_xNfRotate.get());
142  m_xCtrlDial->SetText(m_xFtABCD->get_label());
143 
144  InitVsRefEgde();
145 
146  m_xLbHorAlign->connect_changed(LINK(this, AlignmentTabPage, UpdateEnableHdl));
147 
148  m_xCbStacked->connect_toggled(LINK(this, AlignmentTabPage, StackedClickHdl));
149  m_xCbAsianMode->connect_toggled(LINK(this, AlignmentTabPage, AsianModeClickHdl));
150  m_xBtnWrap->connect_toggled(LINK(this, AlignmentTabPage, WrapClickHdl));
151  m_xBtnHyphen->connect_toggled(LINK(this, AlignmentTabPage, HyphenClickHdl));
152  m_xBtnShrink->connect_toggled(LINK(this, AlignmentTabPage, ShrinkClickHdl));
153 
154  // Asian vertical mode
155  m_xCbAsianMode->set_visible(SvtCJKOptions().IsVerticalTextEnabled());
156 
157  m_xLbFrameDir->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
158  m_xLbFrameDir->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
159  m_xLbFrameDir->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
160 
161  // This page needs ExchangeSupport.
163 }
164 
166 {
167  m_xCtrlDialWin.reset();
168  m_xCtrlDial.reset();
169  m_xVsRefEdge.reset();
170  m_xLbFrameDir.reset();
171 }
172 
173 std::unique_ptr<SfxTabPage> AlignmentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
174 {
175  return std::make_unique<AlignmentTabPage>(pPage, pController, *rAttrSet);
176 }
177 
179 {
180  const SfxItemSet& rOldSet = GetItemSet();
181 
182  bool bChanged = SfxTabPage::FillItemSet(rSet);
183 
184  sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
185  if (m_xLbHorAlign->get_value_changed_from_saved())
186  {
187  SvxCellHorJustify eJustify(SvxCellHorJustify::Standard);
188  switch (m_xLbHorAlign->get_active_id().toInt32())
189  {
191  eJustify = SvxCellHorJustify::Standard;
192  break;
194  eJustify = SvxCellHorJustify::Left;
195  break;
197  eJustify = SvxCellHorJustify::Center;
198  break;
200  eJustify = SvxCellHorJustify::Right;
201  break;
204  eJustify = SvxCellHorJustify::Block;
205  break;
207  eJustify = SvxCellHorJustify::Repeat;
208  break;
209  }
210  rSet->Put(SvxHorJustifyItem(eJustify, nWhich));
211  bChanged = true;
212  }
213  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
214  rSet->InvalidateItem(nWhich);
215 
216  nWhich = GetWhich(SID_ATTR_ALIGN_INDENT);
217  if (m_xEdIndent->get_value_changed_from_saved())
218  {
219  const SfxUInt16Item* pIndentItem = static_cast<const SfxUInt16Item*>(GetOldItem(
220  *rSet, SID_ATTR_ALIGN_INDENT));
221  assert(pIndentItem);
222  std::unique_ptr<SfxUInt16Item> pNewIndentItem(pIndentItem->Clone());
223  pNewIndentItem->SetValue(m_xEdIndent->get_value(FieldUnit::TWIP));
224  rSet->Put(*pNewIndentItem);
225  bChanged = true;
226  }
227  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
228  rSet->InvalidateItem(nWhich);
229 
230  nWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY);
231  if (m_xLbVerAlign->get_value_changed_from_saved())
232  {
233  SvxCellVerJustify eJustify(SvxCellVerJustify::Standard);
234  switch (m_xLbVerAlign->get_active_id().toInt32())
235  {
237  eJustify = SvxCellVerJustify::Standard;
238  break;
240  eJustify = SvxCellVerJustify::Top;
241  break;
243  eJustify = SvxCellVerJustify::Center;
244  break;
246  eJustify = SvxCellVerJustify::Bottom;
247  break;
250  eJustify = SvxCellVerJustify::Block;
251  break;
252  }
253  rSet->Put(SvxVerJustifyItem(eJustify, nWhich));
254  bChanged = true;
255  }
256  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
257  rSet->InvalidateItem(nWhich);
258 
259  nWhich = GetWhich(SID_ATTR_ALIGN_DEGREES);
260  if (m_xNfRotate->get_value_changed_from_saved())
261  {
262  const SdrAngleItem* pAngleItem = static_cast<const SdrAngleItem*>(GetOldItem(
263  *rSet, SID_ATTR_ALIGN_DEGREES));
264  assert(pAngleItem);
265  std::unique_ptr<SdrAngleItem> pNewAngleItem(pAngleItem->Clone());
266  pNewAngleItem->SetValue(m_xCtrlDial->GetRotation());
267  rSet->Put(*pNewAngleItem);
268  bChanged = true;
269  }
270  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
271  rSet->InvalidateItem(nWhich);
272 
273  nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS);
275  {
277  {
278  case IID_CELLLOCK:
279  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhich));
280  break;
281  case IID_TOPLOCK:
282  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhich));
283  break;
284  case IID_BOTTOMLOCK:
285  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhich));
286  break;
287  default:
289  break;
290  }
291  bChanged = true;
292  }
293  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
294  rSet->InvalidateItem(nWhich);
295 
296  nWhich = GetWhich(SID_ATTR_ALIGN_STACKED);
297  if (m_xCbStacked->get_state_changed_from_saved())
298  {
299  const SfxBoolItem* pStackItem = static_cast<const SfxBoolItem*>(GetOldItem(
300  *rSet, SID_ATTR_ALIGN_STACKED));
301  assert(pStackItem);
302  std::unique_ptr<SfxBoolItem> pNewStackItem(pStackItem->Clone());
303  pNewStackItem->SetValue(m_xCbStacked->get_active());
304  rSet->Put(*pNewStackItem);
305  bChanged = true;
306  }
307  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
308  rSet->InvalidateItem(nWhich);
309 
310  nWhich = GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL);
311  if (m_xCbAsianMode->get_state_changed_from_saved())
312  {
313  rSet->Put(SfxBoolItem(nWhich, m_xCbAsianMode->get_active()));
314  bChanged = true;
315  }
316  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
317  rSet->InvalidateItem(nWhich);
318 
319  nWhich = GetWhich(SID_ATTR_ALIGN_LINEBREAK);
320  if (m_xBtnWrap->get_state_changed_from_saved())
321  {
322  const SfxBoolItem* pWrapItem = static_cast<const SfxBoolItem*>(GetOldItem(
323  *rSet, SID_ATTR_ALIGN_LINEBREAK));
324  assert(pWrapItem);
325  std::unique_ptr<SfxBoolItem> pNewWrapItem(pWrapItem->Clone());
326  pNewWrapItem->SetValue(m_xBtnWrap->get_active());
327  rSet->Put(*pNewWrapItem);
328  bChanged = true;
329  }
330  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
331  rSet->InvalidateItem(nWhich);
332 
333  nWhich = GetWhich(SID_ATTR_ALIGN_HYPHENATION);
334  if (m_xBtnHyphen->get_state_changed_from_saved())
335  {
336  const SfxBoolItem* pHyphItem = static_cast<const SfxBoolItem*>(GetOldItem(
337  *rSet, SID_ATTR_ALIGN_HYPHENATION));
338  assert(pHyphItem);
339  std::unique_ptr<SfxBoolItem> pNewHyphItem(pHyphItem->Clone());
340  pNewHyphItem->SetValue(m_xBtnHyphen->get_active());
341  rSet->Put(*pNewHyphItem);
342  bChanged = true;
343  }
344  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
345  rSet->InvalidateItem(nWhich);
346 
347  nWhich = GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT);
348  if (m_xBtnShrink->get_state_changed_from_saved())
349  {
350  const SfxBoolItem* pShrinkItem = static_cast<const SfxBoolItem*>(GetOldItem(
351  *rSet, SID_ATTR_ALIGN_SHRINKTOFIT));
352  assert(pShrinkItem);
353  std::unique_ptr<SfxBoolItem> pNewShrinkItem(pShrinkItem->Clone());
354  pNewShrinkItem->SetValue(m_xBtnShrink->get_active());
355  rSet->Put(*pNewShrinkItem);
356  bChanged = true;
357  }
358  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
359  rSet->InvalidateItem(nWhich);
360 
361  if (m_xLbFrameDir->get_visible())
362  {
363  nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION);
364  if (m_xLbFrameDir->get_value_changed_from_saved())
365  {
366  SvxFrameDirection eDir = m_xLbFrameDir->get_active_id();
367  rSet->Put(SvxFrameDirectionItem(eDir, nWhich));
368  bChanged = true;
369  }
370  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
371  rSet->InvalidateItem(nWhich);
372  }
373 
374  // Special treatment for distributed alignment; we need to set the justify
375  // method to 'distribute' to distinguish from the normal justification.
376  sal_uInt16 nWhichHorJM = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD);
377  lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED);
378  if (!bChanged)
379  bChanged = HasAlignmentChanged(*rSet, nWhichHorJM);
380 
381  sal_uInt16 nWhichVerJM = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD);
382  lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichVerJM, *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED);
383  if (!bChanged)
384  bChanged = HasAlignmentChanged(*rSet, nWhichVerJM);
385 
386  return bChanged;
387 }
388 
389 namespace
390 {
391  void ResetBool(sal_uInt16 nWhich, const SfxItemSet* pSet, weld::CheckButton& rBtn, weld::TriStateEnabled& rTriState)
392  {
393  SfxItemState eState = pSet->GetItemState(nWhich);
394  switch (eState)
395  {
396  case SfxItemState::UNKNOWN:
397  rBtn.hide();
398  rTriState.bTriStateEnabled = false;
399  break;
400  case SfxItemState::DISABLED:
401  case SfxItemState::READONLY:
402  rBtn.set_sensitive(false);
403  rTriState.bTriStateEnabled = false;
404  break;
405  case SfxItemState::DONTCARE:
406  rBtn.set_state(TRISTATE_INDET);
407  rTriState.bTriStateEnabled = true;
408  break;
409  case SfxItemState::DEFAULT:
410  case SfxItemState::SET:
411  {
412  const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(pSet->Get(nWhich));
413  rBtn.set_state(static_cast<TriState>(rItem.GetValue()));
414  rTriState.bTriStateEnabled = false;
415  break;
416  }
417  }
418  rBtn.save_state();
419  }
420 }
421 
422 void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs)
423 {
424  SfxTabPage::Reset(pCoreAttrs);
425 
426  ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED), pCoreAttrs, *m_xCbStacked, m_aStackedState);
427  ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL), pCoreAttrs, *m_xCbAsianMode, m_aAsianModeState);
428  ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK), pCoreAttrs, *m_xBtnWrap, m_aWrapState);
429  ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION), pCoreAttrs, *m_xBtnHyphen, m_aHyphenState);
430  ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), pCoreAttrs, *m_xBtnShrink, m_aShrinkState);
431 
432  sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
433  SfxItemState eState = pCoreAttrs->GetItemState(nWhich);
434  switch (eState)
435  {
436  case SfxItemState::UNKNOWN:
437  m_xLbHorAlign->hide();
438  break;
439  case SfxItemState::DISABLED:
440  case SfxItemState::READONLY:
441  m_xLbHorAlign->set_sensitive(false);
442  break;
443  case SfxItemState::DONTCARE:
444  m_xLbHorAlign->set_active(-1);
445  break;
446  case SfxItemState::DEFAULT:
447  case SfxItemState::SET:
448  {
449  const SvxHorJustifyItem& rJustifyItem = static_cast<const SvxHorJustifyItem&>(pCoreAttrs->Get(nWhich));
450  switch (rJustifyItem.GetValue())
451  {
452  case SvxCellHorJustify::Standard:
453  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_STD));
454  break;
455  case SvxCellHorJustify::Left:
456  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_LEFT));
457  break;
458  case SvxCellHorJustify::Center:
459  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_CENTER));
460  break;
461  case SvxCellHorJustify::Right:
462  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_RIGHT));
463  break;
464  case SvxCellHorJustify::Block:
465  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_BLOCK));
466  break;
467  case SvxCellHorJustify::Repeat:
468  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_FILL));
469  break;
470  }
471  break;
472  }
473  }
474 
475  nWhich = GetWhich(SID_ATTR_ALIGN_INDENT);
476  eState = pCoreAttrs->GetItemState(nWhich);
477  switch (eState)
478  {
479  case SfxItemState::UNKNOWN:
480  m_xEdIndent->hide();
481  m_xFtIndent->hide();
482  break;
483  case SfxItemState::DISABLED:
484  case SfxItemState::READONLY:
485  m_xEdIndent->set_sensitive(false);
486  break;
487  case SfxItemState::DONTCARE:
488  m_xEdIndent->set_text("");
489  break;
490  case SfxItemState::DEFAULT:
491  case SfxItemState::SET:
492  {
493  const SfxUInt16Item& rIndentItem = static_cast<const SfxUInt16Item&>(pCoreAttrs->Get(nWhich));
494  m_xEdIndent->set_value(rIndentItem.GetValue(), FieldUnit::TWIP);
495  break;
496  }
497  }
498 
499  nWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY);
500  eState = pCoreAttrs->GetItemState(nWhich);
501  switch (eState)
502  {
503  case SfxItemState::UNKNOWN:
504  m_xLbVerAlign->hide();
505  m_xFtVerAlign->hide();
506  break;
507  case SfxItemState::DISABLED:
508  case SfxItemState::READONLY:
509  m_xLbVerAlign->set_sensitive(false);
510  break;
511  case SfxItemState::DONTCARE:
512  m_xLbVerAlign->set_active(-1);
513  break;
514  case SfxItemState::DEFAULT:
515  case SfxItemState::SET:
516  {
517  const SvxVerJustifyItem& rJustifyItem = static_cast<const SvxVerJustifyItem&>(pCoreAttrs->Get(nWhich));
518  switch (rJustifyItem.GetValue())
519  {
520  case SvxCellVerJustify::Standard:
521  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_STD));
522  break;
523  case SvxCellVerJustify::Top:
524  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_TOP));
525  break;
526  case SvxCellVerJustify::Center:
527  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_MID));
528  break;
529  case SvxCellVerJustify::Bottom:
530  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BOTTOM));
531  break;
532  case SvxCellVerJustify::Block:
533  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BLOCK));
534  break;
535  }
536  break;
537  }
538  }
539 
540  nWhich = GetWhich(SID_ATTR_ALIGN_DEGREES);
541  eState = pCoreAttrs->GetItemState(nWhich);
542  switch (eState)
543  {
544  case SfxItemState::UNKNOWN:
545  m_xNfRotate->hide();
546  m_xCtrlDialWin->hide();
547  break;
548  case SfxItemState::DISABLED:
549  case SfxItemState::READONLY:
550  m_xNfRotate->set_sensitive(false);
551  m_xCtrlDialWin->set_sensitive(false);
552  break;
553  case SfxItemState::DONTCARE:
554  m_xCtrlDial->SetNoRotation();
555  break;
556  case SfxItemState::DEFAULT:
557  case SfxItemState::SET:
558  {
559  const SdrAngleItem& rAlignItem = static_cast<const SdrAngleItem&>(pCoreAttrs->Get(nWhich));
560  m_xCtrlDial->SetRotation(rAlignItem.GetValue());
561  break;
562  }
563  }
564 
565  nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS);
566  eState = pCoreAttrs->GetItemState(nWhich);
567  switch (eState)
568  {
569  case SfxItemState::UNKNOWN:
570  m_xVsRefEdge->hide();
571  break;
572  case SfxItemState::DISABLED:
573  case SfxItemState::READONLY:
574  m_xVsRefEdge->set_sensitive(false);
575  break;
576  case SfxItemState::DONTCARE:
578  break;
579  case SfxItemState::DEFAULT:
580  case SfxItemState::SET:
581  {
582  const SvxRotateModeItem& rRotateModeItem = static_cast<const SvxRotateModeItem&>(pCoreAttrs->Get(nWhich));
583  switch (rRotateModeItem.GetValue())
584  {
585  case SvxRotateMode::SVX_ROTATE_MODE_STANDARD:
587  break;
588  case SvxRotateMode::SVX_ROTATE_MODE_TOP:
590  break;
591  case SvxRotateMode::SVX_ROTATE_MODE_BOTTOM:
593  break;
594  default:
596  break;
597  }
598  break;
599  }
600  }
602 
603  //text direction
604  nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION);
605  eState = pCoreAttrs->GetItemState(nWhich);
606  switch (eState)
607  {
608  case SfxItemState::UNKNOWN:
609  m_xLbFrameDir->hide();
610  break;
611  case SfxItemState::DISABLED:
612  case SfxItemState::READONLY:
613  m_xLbFrameDir->set_sensitive(false);
614  break;
615  case SfxItemState::DONTCARE:
616  m_xLbFrameDir->set_active(-1);
617  break;
618  case SfxItemState::DEFAULT:
619  case SfxItemState::SET:
620  {
621  const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>(pCoreAttrs->Get(nWhich));
622  m_xLbFrameDir->set_active_id(rFrameDirItem.GetValue());
623  break;
624  }
625  }
626 
627 
628  // Special treatment for distributed alignment; we need to set the justify
629  // method to 'distribute' to distinguish from the normal justification.
630 
631  lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>(
633  GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD),
634  SvxCellHorJustify::Block);
635 
636  lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>(
638  GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD),
639  SvxCellVerJustify::Block);
640 
641  m_xLbHorAlign->save_value();
642  m_xLbFrameDir->save_value();
643  m_xLbVerAlign->save_value();
644  m_xNfRotate->save_value();
645  m_xEdIndent->save_value();
646 
648 }
649 
651 {
652  if( _pSet )
653  FillItemSet( _pSet );
654  return DeactivateRC::LeavePage;
655 }
656 
658 {
659  // remember selection - is deleted in call to ValueSet::Clear()
660  sal_uInt16 nSel = m_aVsRefEdge.GetSelectedItemId();
661 
662  Image aBottomLock(StockImage::Yes, RID_SVXBMP_BOTTOMLOCK);
663  Image aTopLock(StockImage::Yes, RID_SVXBMP_TOPLOCK);
664  Image aCellLock(StockImage::Yes, RID_SVXBMP_CELLLOCK);
665 
668 
670  m_aVsRefEdge.InsertItem(IID_BOTTOMLOCK, aBottomLock, m_xFtBotLock->get_label());
671  m_aVsRefEdge.InsertItem(IID_TOPLOCK, aTopLock, m_xFtTopLock->get_label());
672  m_aVsRefEdge.InsertItem(IID_CELLLOCK, aCellLock, m_xFtCelLock->get_label());
674 
675  m_aVsRefEdge.SelectItem( nSel );
676 }
677 
679 {
680  const sal_Int32 nHorAlign = m_xLbHorAlign->get_active();
681  bool bHorLeft = (nHorAlign == ALIGNDLG_HORALIGN_LEFT);
682  bool bHorBlock = (nHorAlign == ALIGNDLG_HORALIGN_BLOCK);
683  bool bHorFill = (nHorAlign == ALIGNDLG_HORALIGN_FILL);
684  bool bHorDist = (nHorAlign == ALIGNDLG_HORALIGN_DISTRIBUTED);
685 
686  // indent edit field only for left alignment
687  m_xFtIndent->set_sensitive( bHorLeft );
688  m_xEdIndent->set_sensitive( bHorLeft );
689 
690  // stacked disabled for fill alignment
691  m_xCbStacked->set_sensitive(!bHorFill);
692 
693  // hyphenation only for automatic line breaks or for block alignment
694  m_xBtnHyphen->set_sensitive( m_xBtnWrap->get_active() || bHorBlock );
695 
696  // shrink only without automatic line break, and not for block, fill or distribute.
697  m_xBtnShrink->set_sensitive( (m_xBtnWrap->get_state() == TRISTATE_FALSE) && !bHorBlock && !bHorFill && !bHorDist );
698 
699  // visibility of frames
700  m_xAlignmentFrame->set_visible(m_xLbHorAlign->get_visible() || m_xEdIndent->get_visible() ||
701  m_xLbVerAlign->get_visible());
702  m_xOrientFrame->set_visible(m_xCtrlDialWin->get_visible() || m_xVsRefEdge->get_visible() ||
703  m_xCbStacked->get_visible() || m_xCbAsianMode->get_visible());
704  m_xPropertiesFrame->set_visible(m_xBtnWrap->get_visible() || m_xBtnHyphen->get_visible() ||
705  m_xBtnShrink->get_visible() || m_xLbFrameDir->get_visible());
706 
707  bool bStackedText = m_xCbStacked->get_active();
708  // windows to be disabled, if stacked text is turned ON
709  m_xFtRotate->set_sensitive(!bStackedText);
710  m_xFtRefEdge->set_sensitive(!bStackedText);
711  m_xVsRefEdge->set_sensitive(!bStackedText);
712  // windows to be disabled, if stacked text is turned OFF
713  m_xCbAsianMode->set_sensitive(bStackedText);
714  // rotation/stacked disabled for fill alignment/stacked
715  m_xCtrlDialWin->set_sensitive(!bHorFill && !bStackedText);
716  m_xNfRotate->set_sensitive(!bHorFill && !bStackedText);
717 }
718 
719 bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const
720 {
721  const SfxItemSet& rOld = GetItemSet();
722  const SfxPoolItem* pItem;
723  SvxCellJustifyMethod eMethodOld = SvxCellJustifyMethod::Auto;
724  SvxCellJustifyMethod eMethodNew = SvxCellJustifyMethod::Auto;
725  if (rOld.GetItemState(nWhich, true, &pItem) == SfxItemState::SET)
726  {
727  const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem);
728  eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
729  }
730 
731  if (rNew.GetItemState(nWhich, true, &pItem) == SfxItemState::SET)
732  {
733  const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem);
734  eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
735  }
736 
737  return eMethodOld != eMethodNew;
738 }
739 
740 IMPL_LINK(AlignmentTabPage, StackedClickHdl, weld::ToggleButton&, rToggle, void)
741 {
742  m_aStackedState.ButtonToggled(rToggle);
743  UpdateEnableControls();
744 }
745 
746 IMPL_LINK(AlignmentTabPage, AsianModeClickHdl, weld::ToggleButton&, rToggle, void)
747 {
748  m_aAsianModeState.ButtonToggled(rToggle);
749 }
750 
751 IMPL_LINK(AlignmentTabPage, WrapClickHdl, weld::ToggleButton&, rToggle, void)
752 {
753  m_aWrapState.ButtonToggled(rToggle);
754  UpdateEnableControls();
755 }
756 
757 IMPL_LINK(AlignmentTabPage, HyphenClickHdl, weld::ToggleButton&, rToggle, void)
758 {
759  m_aHyphenState.ButtonToggled(rToggle);
760 }
761 
762 IMPL_LINK(AlignmentTabPage, ShrinkClickHdl, weld::ToggleButton&, rToggle, void)
763 {
764  m_aShrinkState.ButtonToggled(rToggle);
765 }
766 
768 {
769  UpdateEnableControls();
770 }
771 
772 }
773 
774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void UpdateEnableControls()
Definition: align.cxx:678
bool GetValue() const
#define ALIGNDLG_HORALIGN_DISTRIBUTED
Definition: align.hxx:28
SvxCellHorJustify
FieldUnit
weld::TriStateEnabled m_aHyphenState
Definition: align.hxx:78
virtual SfxBoolItem * Clone(SfxItemPool *=nullptr) const override
virtual sal_uInt16 GetEnumValue() const =0
std::unique_ptr< weld::Widget > m_xAlignmentFrame
Definition: align.hxx:107
virtual void hide()=0
void SetOptimalSize()
std::unique_ptr< svx::FrameDirectionListBox > m_xLbFrameDir
Definition: align.hxx:99
std::unique_ptr< weld::Label > m_xFtRefEdge
Definition: align.hxx:91
sal_uInt16 GetValue() const
void InvalidateItem(sal_uInt16 nWhich)
#define ALIGNDLG_VERALIGN_STD
Definition: align.hxx:30
SvxFrameDirection
sal_uInt16 GetSelectedItemId() const
static const sal_uInt16 s_pRanges[]
Definition: align.hxx:48
virtual int get_active() const =0
void SetStyle(WinBits nStyle)
std::unique_ptr< weld::Label > m_xFtVerAlign
Definition: align.hxx:86
AlignmentTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
Definition: align.cxx:107
std::unique_ptr< weld::MetricSpinButton > m_xNfRotate
Definition: align.hxx:90
void Clear()
#define ALIGNDLG_HORALIGN_RIGHT
Definition: align.hxx:25
virtual bool FillItemSet(SfxItemSet *)
std::unique_ptr< weld::Label > m_xFtRotate
Definition: align.hxx:89
std::unique_ptr< weld::CheckButton > m_xBtnWrap
Definition: align.hxx:96
weld::TriStateEnabled m_aWrapState
Definition: align.hxx:77
SvxCellVerJustify
std::unique_ptr< weld::CheckButton > m_xBtnHyphen
Definition: align.hxx:97
OUString SvxResId(const char *pId)
std::unique_ptr< weld::ComboBox > m_xLbVerAlign
Definition: align.hxx:87
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#define WB_ITEMBORDER
void SetExchangeSupport()
std::unique_ptr< weld::CustomWeld > m_xCtrlDialWin
Definition: align.hxx:113
virtual void Reset(const SfxItemSet *)
std::unique_ptr< DialControl > m_xCtrlDial
Definition: align.hxx:112
#define ALIGNDLG_HORALIGN_CENTER
Definition: align.hxx:24
WinBits GetStyle() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: align.cxx:173
const SfxItemSet & GetItemSet() const
std::unique_ptr< weld::Label > m_xFtCelLock
Definition: align.hxx:104
#define ALIGNDLG_HORALIGN_LEFT
Definition: align.hxx:23
std::unique_ptr< weld::ComboBox > m_xLbHorAlign
Definition: align.hxx:83
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
std::unique_ptr< weld::Label > m_xFtABCD
Definition: align.hxx:105
virtual SdrAngleItem * Clone(SfxItemPool *pPool=nullptr) const override
#define ALIGNDLG_VERALIGN_BOTTOM
Definition: align.hxx:33
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define ALIGNDLG_VERALIGN_MID
Definition: align.hxx:32
bool HasAlignmentChanged(const SfxItemSet &rNew, sal_uInt16 nWhich) const
Definition: align.cxx:719
std::unique_ptr< weld::CustomWeld > m_xVsRefEdge
Definition: align.hxx:111
weld::TriStateEnabled m_aAsianModeState
Definition: align.hxx:76
TRISTATE_FALSE
#define IID_CELLLOCK
Definition: align.cxx:38
bool IsValueChangedFromSaved() const
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox &, rBox, void)
std::unique_ptr< weld::Label > m_xFtIndent
Definition: align.hxx:84
std::unique_ptr< weld::MetricSpinButton > m_xEdIndent
Definition: align.hxx:85
ValueSet m_aVsRefEdge
Definition: align.hxx:81
virtual void Reset(const SfxItemSet *rSet) override
Definition: align.cxx:422
std::unique_ptr< weld::Label > m_xFtTopLock
Definition: align.hxx:103
virtual void set_active(int pos)=0
#define ALIGNDLG_VERALIGN_DISTRIBUTED
Definition: align.hxx:35
#define ALIGNDLG_VERALIGN_BLOCK
Definition: align.hxx:34
void SaveValue()
weld::TriStateEnabled m_aStackedState
Definition: align.hxx:75
void SelectItem(sal_uInt16 nItemId)
#define ALIGNDLG_HORALIGN_FILL
Definition: align.hxx:27
#define ALIGNDLG_HORALIGN_BLOCK
Definition: align.hxx:26
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::Widget > m_xOrientFrame
Definition: align.hxx:108
std::unique_ptr< weld::CheckButton > m_xBtnShrink
Definition: align.hxx:98
SfxItemState
#define IID_TOPLOCK
Definition: align.cxx:37
#define ALIGNDLG_VERALIGN_TOP
Definition: align.hxx:31
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::CheckButton > m_xCbAsianMode
Definition: align.hxx:93
void SetNoSelection()
void SetColCount(sal_uInt16 nNewCols=1)
#define IID_BOTTOMLOCK
Definition: align.cxx:36
weld::TriStateEnabled m_aShrinkState
Definition: align.hxx:79
void * p
virtual ~AlignmentTabPage() override
Definition: align.cxx:165
IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::Button &, void)
std::unique_ptr< weld::Widget > m_xPropertiesFrame
Definition: align.hxx:109
virtual SfxUInt16Item * Clone(SfxItemPool *=nullptr) const override
DeactivateRC
#define WB_DOUBLEBORDER
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: align.cxx:178
std::unique_ptr< weld::CheckButton > m_xCbStacked
Definition: align.hxx:92
void set_state(TriState eState)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: align.cxx:650
SvxCellJustifyMethod
#define ALIGNDLG_HORALIGN_STD
Definition: align.hxx:22
std::unique_ptr< weld::Label > m_xFtBotLock
Definition: align.hxx:102
virtual void set_sensitive(bool sensitive)=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const