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 
43  svl::Items<
44  SID_ATTR_ALIGN_STACKED, SID_ATTR_ALIGN_LINEBREAK, // 10229 - 10230
45  SID_ATTR_ALIGN_INDENT, SID_ATTR_ALIGN_INDENT, // 10460 - 10460
46  SID_ATTR_ALIGN_DEGREES, SID_ATTR_ALIGN_DEGREES, // 10577 - 10577
47  SID_ATTR_ALIGN_LOCKPOS, SID_ATTR_ALIGN_LOCKPOS, // 10578 - 10578
48  SID_ATTR_ALIGN_HYPHENATION, SID_ATTR_ALIGN_HYPHENATION, // 10931 - 10931
49  SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION, // 10944 - 10944
50  SID_ATTR_ALIGN_ASIANVERTICAL, SID_ATTR_ALIGN_ASIANVERTICAL, // 10949 - 10949
51  SID_ATTR_ALIGN_SHRINKTOFIT, SID_ATTR_ALIGN_SHRINKTOFIT, // 11015 - 11015
52  SID_ATTR_ALIGN_HOR_JUSTIFY, SID_ATTR_ALIGN_VER_JUSTIFY>); // 11571 - 11572
53 
54 
55 namespace {
56 
57 template<typename JustContainerType, typename JustEnumType>
58 void lcl_MaybeResetAlignToDistro(
59  weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, TypedWhichId<SfxEnumItemInterface> nWhichAlign, TypedWhichId<SfxEnumItemInterface> nWhichJM, JustEnumType eBlock)
60 {
61  const SfxEnumItemInterface* p = rCoreAttrs.GetItemIfSet(nWhichAlign);
62  if (!p)
63  // alignment not set.
64  return;
65 
66  JustContainerType eVal = static_cast<JustContainerType>(p->GetEnumValue());
67  if (eVal != eBlock)
68  // alignment is not 'justify'. No need to go further.
69  return;
70 
71  p = rCoreAttrs.GetItemIfSet(nWhichJM);
72  if (!p)
73  // justification method is not set.
74  return;
75 
76  SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
77  if (eMethod == SvxCellJustifyMethod::Distribute)
78  {
79  // Select the 'distribute' entry in the specified list box.
80  rLB.set_active_id(OUString::number(nListId));
81  }
82 }
83 
84 void lcl_SetJustifyMethodToItemSet(SfxItemSet& rSet, const SfxItemSet& rOldSet, sal_uInt16 nWhichJM, const weld::ComboBox& rLB, sal_uInt16 nListId)
85 {
86  // tdf#138698 unsupported, e.g. dbaccess
87  if (rLB.find_id(OUString::number(nListId)) == -1)
88  return;
89 
90  // feature supported , e.g. calc
91  SvxCellJustifyMethod eJM = SvxCellJustifyMethod::Auto;
92  if (rLB.get_active_id().toInt32() == nListId)
93  eJM = SvxCellJustifyMethod::Distribute;
94 
95  // tdf#129300 If it would create no change, don't force it
96  const SvxJustifyMethodItem& rOldItem = static_cast<const SvxJustifyMethodItem&>(rOldSet.Get(nWhichJM));
97  if (rOldItem.GetValue() == eJM)
98  {
99  rSet.InvalidateItem(nWhichJM);
100  return;
101  }
102 
103  SvxJustifyMethodItem aItem(eJM, nWhichJM);
104  rSet.Put(aItem);
105 }
106 
107 }//namespace
108 
110  : SfxTabPage(pPage, pController, "cui/ui/cellalignment.ui", "CellAlignPage", &rCoreAttrs)
111  , m_aVsRefEdge(nullptr)
112  // text alignment
113  , m_xLbHorAlign(m_xBuilder->weld_combo_box("comboboxHorzAlign"))
114  , m_xFtIndent(m_xBuilder->weld_label("labelIndent"))
115  , m_xEdIndent(m_xBuilder->weld_metric_spin_button("spinIndentFrom", FieldUnit::POINT))
116  , m_xFtVerAlign(m_xBuilder->weld_label("labelVertAlign"))
117  , m_xLbVerAlign(m_xBuilder->weld_combo_box("comboboxVertAlign"))
118  //text rotation
119  , m_xFtRotate(m_xBuilder->weld_label("labelDegrees"))
120  , m_xNfRotate(m_xBuilder->weld_metric_spin_button("spinDegrees", FieldUnit::DEGREE))
121  , m_xFtRefEdge(m_xBuilder->weld_label("labelRefEdge"))
122  //Asian mode
123  , m_xCbStacked(m_xBuilder->weld_check_button("checkVertStack"))
124  , m_xCbAsianMode(m_xBuilder->weld_check_button("checkAsianMode"))
125  // Properties
126  , m_xBoxDirection(m_xBuilder->weld_widget("boxDirection"))
127  , m_xBtnWrap(m_xBuilder->weld_check_button("checkWrapTextAuto"))
128  , m_xBtnHyphen(m_xBuilder->weld_check_button("checkHyphActive"))
129  , m_xBtnShrink(m_xBuilder->weld_check_button("checkShrinkFitCellSize"))
130  , m_xLbFrameDir(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboTextDirBox")))
131  //ValueSet hover strings
132  , m_xFtBotLock(m_xBuilder->weld_label("labelSTR_BOTTOMLOCK"))
133  , m_xFtTopLock(m_xBuilder->weld_label("labelSTR_TOPLOCK"))
134  , m_xFtCelLock(m_xBuilder->weld_label("labelSTR_CELLLOCK"))
135  , m_xFtABCD(m_xBuilder->weld_label("labelABCD"))
136  , m_xAlignmentFrame(m_xBuilder->weld_widget("alignment"))
137  , m_xOrientFrame(m_xBuilder->weld_widget("orientation"))
138  , m_xPropertiesFrame(m_xBuilder->weld_widget("properties"))
139  , m_xVsRefEdge(new weld::CustomWeld(*m_xBuilder, "references", m_aVsRefEdge))
140  , m_xCtrlDial(new DialControl)
141  , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, "dialcontrol", *m_xCtrlDial))
142 {
143  m_xCtrlDial->SetLinkedField(m_xNfRotate.get());
144  m_xCtrlDial->SetText(m_xFtABCD->get_label());
145 
146  InitVsRefEgde();
147 
148  m_xLbHorAlign->connect_changed(LINK(this, AlignmentTabPage, UpdateEnableHdl));
149 
150  m_xCbStacked->connect_toggled(LINK(this, AlignmentTabPage, StackedClickHdl));
151  m_xCbAsianMode->connect_toggled(LINK(this, AlignmentTabPage, AsianModeClickHdl));
152  m_xBtnWrap->connect_toggled(LINK(this, AlignmentTabPage, WrapClickHdl));
153  m_xBtnHyphen->connect_toggled(LINK(this, AlignmentTabPage, HyphenClickHdl));
154  m_xBtnShrink->connect_toggled(LINK(this, AlignmentTabPage, ShrinkClickHdl));
155 
156  // Asian vertical mode
158 
159  m_xLbFrameDir->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
160  m_xLbFrameDir->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
161  m_xLbFrameDir->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
162 
163  // This page needs ExchangeSupport.
165 }
166 
168 {
169  m_xCtrlDialWin.reset();
170  m_xCtrlDial.reset();
171  m_xVsRefEdge.reset();
172  m_xLbFrameDir.reset();
173 }
174 
175 std::unique_ptr<SfxTabPage> AlignmentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
176 {
177  return std::make_unique<AlignmentTabPage>(pPage, pController, *rAttrSet);
178 }
179 
181 {
182  const SfxItemSet& rOldSet = GetItemSet();
183 
184  bool bChanged = SfxTabPage::FillItemSet(rSet);
185 
186  sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
187  if (m_xLbHorAlign->get_value_changed_from_saved())
188  {
189  SvxCellHorJustify eJustify(SvxCellHorJustify::Standard);
190  switch (m_xLbHorAlign->get_active_id().toInt32())
191  {
193  eJustify = SvxCellHorJustify::Standard;
194  break;
196  eJustify = SvxCellHorJustify::Left;
197  break;
199  eJustify = SvxCellHorJustify::Center;
200  break;
202  eJustify = SvxCellHorJustify::Right;
203  break;
206  eJustify = SvxCellHorJustify::Block;
207  break;
209  eJustify = SvxCellHorJustify::Repeat;
210  break;
211  }
212  rSet->Put(SvxHorJustifyItem(eJustify, nWhich));
213  bChanged = true;
214  }
215  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
216  rSet->InvalidateItem(nWhich);
217 
218  nWhich = GetWhich(SID_ATTR_ALIGN_INDENT);
219  if (m_xEdIndent->get_value_changed_from_saved())
220  {
221  const SfxUInt16Item* pIndentItem = static_cast<const SfxUInt16Item*>(GetOldItem(
222  *rSet, SID_ATTR_ALIGN_INDENT));
223  assert(pIndentItem);
224  std::unique_ptr<SfxUInt16Item> pNewIndentItem(pIndentItem->Clone());
225  pNewIndentItem->SetValue(m_xEdIndent->get_value(FieldUnit::TWIP));
226  rSet->Put(*pNewIndentItem);
227  bChanged = true;
228  }
229  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
230  rSet->InvalidateItem(nWhich);
231 
232  nWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY);
233  if (m_xLbVerAlign->get_value_changed_from_saved())
234  {
235  SvxCellVerJustify eJustify(SvxCellVerJustify::Standard);
236  switch (m_xLbVerAlign->get_active_id().toInt32())
237  {
239  eJustify = SvxCellVerJustify::Standard;
240  break;
242  eJustify = SvxCellVerJustify::Top;
243  break;
245  eJustify = SvxCellVerJustify::Center;
246  break;
248  eJustify = SvxCellVerJustify::Bottom;
249  break;
252  eJustify = SvxCellVerJustify::Block;
253  break;
254  }
255  rSet->Put(SvxVerJustifyItem(eJustify, nWhich));
256  bChanged = true;
257  }
258  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
259  rSet->InvalidateItem(nWhich);
260 
261  nWhich = GetWhich(SID_ATTR_ALIGN_DEGREES);
262  if (m_xNfRotate->get_value_changed_from_saved())
263  {
264  const SdrAngleItem* pAngleItem = static_cast<const SdrAngleItem*>(GetOldItem(
265  *rSet, SID_ATTR_ALIGN_DEGREES));
266  assert(pAngleItem);
267  std::unique_ptr<SdrAngleItem> pNewAngleItem(pAngleItem->Clone());
268  pNewAngleItem->SetValue(m_xCtrlDial->GetRotation());
269  rSet->Put(*pNewAngleItem);
270  bChanged = true;
271  }
272  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
273  rSet->InvalidateItem(nWhich);
274 
275  TypedWhichId<SvxRotateModeItem> nWhichLockPos(GetWhich(SID_ATTR_ALIGN_LOCKPOS));
277  {
279  {
280  case IID_CELLLOCK:
281  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhichLockPos));
282  break;
283  case IID_TOPLOCK:
284  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhichLockPos));
285  break;
286  case IID_BOTTOMLOCK:
287  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhichLockPos));
288  break;
289  default:
291  break;
292  }
293  bChanged = true;
294  }
295  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhichLockPos, false))
296  rSet->InvalidateItem(nWhichLockPos);
297 
298  nWhich = GetWhich(SID_ATTR_ALIGN_STACKED);
299  if (m_xCbStacked->get_state_changed_from_saved())
300  {
301  const SfxBoolItem* pStackItem = static_cast<const SfxBoolItem*>(GetOldItem(
302  *rSet, SID_ATTR_ALIGN_STACKED));
303  assert(pStackItem);
304  std::unique_ptr<SfxBoolItem> pNewStackItem(pStackItem->Clone());
305  pNewStackItem->SetValue(m_xCbStacked->get_active());
306  rSet->Put(*pNewStackItem);
307  bChanged = true;
308  }
309  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
310  rSet->InvalidateItem(nWhich);
311 
312  nWhich = GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL);
313  if (m_xCbAsianMode->get_state_changed_from_saved())
314  {
315  rSet->Put(SfxBoolItem(nWhich, m_xCbAsianMode->get_active()));
316  bChanged = true;
317  }
318  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
319  rSet->InvalidateItem(nWhich);
320 
321  nWhich = GetWhich(SID_ATTR_ALIGN_LINEBREAK);
322  if (m_xBtnWrap->get_state_changed_from_saved())
323  {
324  const SfxBoolItem* pWrapItem = static_cast<const SfxBoolItem*>(GetOldItem(
325  *rSet, SID_ATTR_ALIGN_LINEBREAK));
326  assert(pWrapItem);
327  std::unique_ptr<SfxBoolItem> pNewWrapItem(pWrapItem->Clone());
328  pNewWrapItem->SetValue(m_xBtnWrap->get_active());
329  rSet->Put(*pNewWrapItem);
330  bChanged = true;
331  }
332  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
333  rSet->InvalidateItem(nWhich);
334 
335  nWhich = GetWhich(SID_ATTR_ALIGN_HYPHENATION);
336  if (m_xBtnHyphen->get_state_changed_from_saved())
337  {
338  const SfxBoolItem* pHyphItem = static_cast<const SfxBoolItem*>(GetOldItem(
339  *rSet, SID_ATTR_ALIGN_HYPHENATION));
340  assert(pHyphItem);
341  std::unique_ptr<SfxBoolItem> pNewHyphItem(pHyphItem->Clone());
342  pNewHyphItem->SetValue(m_xBtnHyphen->get_active());
343  rSet->Put(*pNewHyphItem);
344  bChanged = true;
345  }
346  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
347  rSet->InvalidateItem(nWhich);
348 
349  nWhich = GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT);
350  if (m_xBtnShrink->get_state_changed_from_saved())
351  {
352  const SfxBoolItem* pShrinkItem = static_cast<const SfxBoolItem*>(GetOldItem(
353  *rSet, SID_ATTR_ALIGN_SHRINKTOFIT));
354  assert(pShrinkItem);
355  std::unique_ptr<SfxBoolItem> pNewShrinkItem(pShrinkItem->Clone());
356  pNewShrinkItem->SetValue(m_xBtnShrink->get_active());
357  rSet->Put(*pNewShrinkItem);
358  bChanged = true;
359  }
360  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
361  rSet->InvalidateItem(nWhich);
362 
363  if (m_xLbFrameDir->get_visible())
364  {
365  nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION);
366  if (m_xLbFrameDir->get_value_changed_from_saved())
367  {
368  SvxFrameDirection eDir = m_xLbFrameDir->get_active_id();
369  rSet->Put(SvxFrameDirectionItem(eDir, nWhich));
370  bChanged = true;
371  }
372  else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
373  rSet->InvalidateItem(nWhich);
374  }
375 
376  // Special treatment for distributed alignment; we need to set the justify
377  // method to 'distribute' to distinguish from the normal justification.
378  TypedWhichId<SfxEnumItemInterface> nWhichHorJM(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD));
379  lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED);
380  if (!bChanged)
381  bChanged = HasAlignmentChanged(*rSet, nWhichHorJM);
382 
383  TypedWhichId<SfxEnumItemInterface> nWhichVerJM(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD));
384  lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichVerJM, *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED);
385  if (!bChanged)
386  bChanged = HasAlignmentChanged(*rSet, nWhichVerJM);
387 
388  return bChanged;
389 }
390 
391 namespace
392 {
393  void ResetBool(sal_uInt16 nWhich, const SfxItemSet* pSet, weld::CheckButton& rBtn, weld::TriStateEnabled& rTriState)
394  {
395  SfxItemState eState = pSet->GetItemState(nWhich);
396  switch (eState)
397  {
398  case SfxItemState::UNKNOWN:
399  rBtn.hide();
400  rTriState.bTriStateEnabled = false;
401  break;
402  case SfxItemState::DISABLED:
403  rBtn.set_sensitive(false);
404  rTriState.bTriStateEnabled = false;
405  break;
406  case SfxItemState::DONTCARE:
407  rBtn.set_state(TRISTATE_INDET);
408  rTriState.bTriStateEnabled = true;
409  break;
410  case SfxItemState::DEFAULT:
411  case SfxItemState::SET:
412  {
413  const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(pSet->Get(nWhich));
414  rBtn.set_state(static_cast<TriState>(rItem.GetValue()));
415  rTriState.bTriStateEnabled = false;
416  break;
417  }
418  }
419  rBtn.save_state();
420  }
421 }
422 
423 void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs)
424 {
425  SfxTabPage::Reset(pCoreAttrs);
426 
427  ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED), pCoreAttrs, *m_xCbStacked, m_aStackedState);
428  ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL), pCoreAttrs, *m_xCbAsianMode, m_aAsianModeState);
429  ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK), pCoreAttrs, *m_xBtnWrap, m_aWrapState);
430  ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION), pCoreAttrs, *m_xBtnHyphen, m_aHyphenState);
431  ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), pCoreAttrs, *m_xBtnShrink, m_aShrinkState);
432 
433  sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
434  SfxItemState eState = pCoreAttrs->GetItemState(nWhich);
435  switch (eState)
436  {
437  case SfxItemState::UNKNOWN:
438  m_xLbHorAlign->hide();
439  break;
440  case SfxItemState::DISABLED:
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  m_xEdIndent->set_sensitive(false);
485  break;
486  case SfxItemState::DONTCARE:
487  m_xEdIndent->set_text("");
488  break;
489  case SfxItemState::DEFAULT:
490  case SfxItemState::SET:
491  {
492  const SfxUInt16Item& rIndentItem = static_cast<const SfxUInt16Item&>(pCoreAttrs->Get(nWhich));
493  m_xEdIndent->set_value(rIndentItem.GetValue(), FieldUnit::TWIP);
494  break;
495  }
496  }
497 
498  nWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY);
499  eState = pCoreAttrs->GetItemState(nWhich);
500  switch (eState)
501  {
502  case SfxItemState::UNKNOWN:
503  m_xLbVerAlign->hide();
504  m_xFtVerAlign->hide();
505  break;
506  case SfxItemState::DISABLED:
507  m_xLbVerAlign->set_sensitive(false);
508  break;
509  case SfxItemState::DONTCARE:
510  m_xLbVerAlign->set_active(-1);
511  break;
512  case SfxItemState::DEFAULT:
513  case SfxItemState::SET:
514  {
515  const SvxVerJustifyItem& rJustifyItem = static_cast<const SvxVerJustifyItem&>(pCoreAttrs->Get(nWhich));
516  switch (rJustifyItem.GetValue())
517  {
518  case SvxCellVerJustify::Standard:
519  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_STD));
520  break;
521  case SvxCellVerJustify::Top:
522  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_TOP));
523  break;
524  case SvxCellVerJustify::Center:
525  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_MID));
526  break;
527  case SvxCellVerJustify::Bottom:
528  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BOTTOM));
529  break;
530  case SvxCellVerJustify::Block:
531  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BLOCK));
532  break;
533  }
534  break;
535  }
536  }
537 
538  nWhich = GetWhich(SID_ATTR_ALIGN_DEGREES);
539  eState = pCoreAttrs->GetItemState(nWhich);
540  switch (eState)
541  {
542  case SfxItemState::UNKNOWN:
543  m_xNfRotate->hide();
544  m_xCtrlDialWin->hide();
545  break;
546  case SfxItemState::DISABLED:
547  m_xNfRotate->set_sensitive(false);
548  m_xCtrlDialWin->set_sensitive(false);
549  break;
550  case SfxItemState::DONTCARE:
551  m_xCtrlDial->SetNoRotation();
552  break;
553  case SfxItemState::DEFAULT:
554  case SfxItemState::SET:
555  {
556  const SdrAngleItem& rAlignItem = static_cast<const SdrAngleItem&>(pCoreAttrs->Get(nWhich));
557  m_xCtrlDial->SetRotation(rAlignItem.GetValue());
558  break;
559  }
560  }
561 
562  nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS);
563  eState = pCoreAttrs->GetItemState(nWhich);
564  switch (eState)
565  {
566  case SfxItemState::UNKNOWN:
567  m_xVsRefEdge->hide();
568  break;
569  case SfxItemState::DISABLED:
570  m_xVsRefEdge->set_sensitive(false);
571  break;
572  case SfxItemState::DONTCARE:
574  break;
575  case SfxItemState::DEFAULT:
576  case SfxItemState::SET:
577  {
578  const SvxRotateModeItem& rRotateModeItem = static_cast<const SvxRotateModeItem&>(pCoreAttrs->Get(nWhich));
579  switch (rRotateModeItem.GetValue())
580  {
581  case SvxRotateMode::SVX_ROTATE_MODE_STANDARD:
583  break;
584  case SvxRotateMode::SVX_ROTATE_MODE_TOP:
586  break;
587  case SvxRotateMode::SVX_ROTATE_MODE_BOTTOM:
589  break;
590  default:
592  break;
593  }
594  break;
595  }
596  }
598 
599  //text direction
600  nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION);
601  eState = pCoreAttrs->GetItemState(nWhich);
602  switch (eState)
603  {
604  case SfxItemState::UNKNOWN:
605  m_xLbFrameDir->hide();
606  break;
607  case SfxItemState::DISABLED:
608  m_xLbFrameDir->set_sensitive(false);
609  break;
610  case SfxItemState::DONTCARE:
611  m_xLbFrameDir->set_active(-1);
612  break;
613  case SfxItemState::DEFAULT:
614  case SfxItemState::SET:
615  {
616  const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>(pCoreAttrs->Get(nWhich));
617  m_xLbFrameDir->set_active_id(rFrameDirItem.GetValue());
618  break;
619  }
620  }
621 
622  // Special treatment for distributed alignment; we need to set the justify
623  // method to 'distribute' to distinguish from the normal justification.
624  TypedWhichId<SfxEnumItemInterface> nHorJustifyMethodWhich(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD));
625  SfxItemState eHorJustifyMethodState = pCoreAttrs->GetItemState(nHorJustifyMethodWhich);
626  if (eHorJustifyMethodState == SfxItemState::UNKNOWN)
627  {
628  // feature unknown, e.g. dbaccess, remove the option
629  int nDistribId = m_xLbHorAlign->find_id(OUString::number(ALIGNDLG_HORALIGN_DISTRIBUTED));
630  if (nDistribId != -1)
631  m_xLbHorAlign->remove(nDistribId);
632  }
633  else
634  {
635  // feature known, e.g. calc
636  lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>(
638  TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY)), nHorJustifyMethodWhich,
639  SvxCellHorJustify::Block);
640  }
641 
642  TypedWhichId<SfxEnumItemInterface> nVerJustifyMethodWhich( GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD) );
643  SfxItemState eVerJustifyMethodState = pCoreAttrs->GetItemState(nVerJustifyMethodWhich);
644  if (eVerJustifyMethodState == SfxItemState::UNKNOWN)
645  {
646  // feature unknown, e.g. dbaccess, remove the option
647  int nDistribId = m_xLbVerAlign->find_id(OUString::number(ALIGNDLG_VERALIGN_DISTRIBUTED));
648  if (nDistribId != -1)
649  m_xLbVerAlign->remove(nDistribId);
650  }
651  else
652  {
653  // feature known, e.g. calc
654  lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>(
656  TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY)), nVerJustifyMethodWhich,
657  SvxCellVerJustify::Block);
658  }
659 
660  m_xLbHorAlign->save_value();
661  m_xLbFrameDir->save_value();
662  m_xLbVerAlign->save_value();
663  m_xNfRotate->save_value();
664  m_xEdIndent->save_value();
665 
667 }
668 
670 {
671  if( _pSet )
672  FillItemSet( _pSet );
673  return DeactivateRC::LeavePage;
674 }
675 
677 {
678  // remember selection - is deleted in call to ValueSet::Clear()
679  sal_uInt16 nSel = m_aVsRefEdge.GetSelectedItemId();
680 
681  Image aBottomLock(StockImage::Yes, RID_SVXBMP_BOTTOMLOCK);
682  Image aTopLock(StockImage::Yes, RID_SVXBMP_TOPLOCK);
683  Image aCellLock(StockImage::Yes, RID_SVXBMP_CELLLOCK);
684 
687 
689  m_aVsRefEdge.InsertItem(IID_BOTTOMLOCK, aBottomLock, m_xFtBotLock->get_label());
690  m_aVsRefEdge.InsertItem(IID_TOPLOCK, aTopLock, m_xFtTopLock->get_label());
691  m_aVsRefEdge.InsertItem(IID_CELLLOCK, aCellLock, m_xFtCelLock->get_label());
693 
694  m_aVsRefEdge.SelectItem( nSel );
695 }
696 
698 {
699  const sal_Int32 nHorAlign = m_xLbHorAlign->get_active_id().toInt32();
700  bool bHorLeft = (nHorAlign == ALIGNDLG_HORALIGN_LEFT);
701  bool bHorBlock = (nHorAlign == ALIGNDLG_HORALIGN_BLOCK);
702  bool bHorFill = (nHorAlign == ALIGNDLG_HORALIGN_FILL);
703  bool bHorDist = (nHorAlign == ALIGNDLG_HORALIGN_DISTRIBUTED);
704 
705  // indent edit field only for left alignment
706  m_xFtIndent->set_sensitive( bHorLeft );
707  m_xEdIndent->set_sensitive( bHorLeft );
708 
709  // stacked disabled for fill alignment
710  m_xCbStacked->set_sensitive(!bHorFill);
711 
712  // hyphenation only for automatic line breaks or for block alignment
713  m_xBtnHyphen->set_sensitive( m_xBtnWrap->get_active() || bHorBlock );
714 
715  // shrink only without automatic line break, and not for block, fill or distribute.
716  m_xBtnShrink->set_sensitive( (m_xBtnWrap->get_state() == TRISTATE_FALSE) && !bHorBlock && !bHorFill && !bHorDist );
717 
718  // visibility of frames
719  m_xAlignmentFrame->set_visible(m_xLbHorAlign->get_visible() || m_xEdIndent->get_visible() ||
720  m_xLbVerAlign->get_visible());
721  m_xOrientFrame->set_visible(m_xCtrlDialWin->get_visible() || m_xVsRefEdge->get_visible() ||
722  m_xCbStacked->get_visible() || m_xCbAsianMode->get_visible());
723  m_xPropertiesFrame->set_visible(m_xBtnWrap->get_visible() || m_xBtnHyphen->get_visible() ||
724  m_xBtnShrink->get_visible() || m_xLbFrameDir->get_visible());
725 
726  bool bStackedText = m_xCbStacked->get_active();
727  // windows to be disabled, if stacked text is turned ON
728  m_xFtRotate->set_sensitive(!bStackedText);
729  m_xFtRefEdge->set_sensitive(!bStackedText);
730  m_xVsRefEdge->set_sensitive(!bStackedText);
731  // windows to be disabled, if stacked text is turned OFF
732  m_xCbAsianMode->set_sensitive(bStackedText);
733  // rotation/stacked disabled for fill alignment/stacked
734  m_xCtrlDialWin->set_sensitive(!bHorFill && !bStackedText);
735  m_xNfRotate->set_sensitive(!bHorFill && !bStackedText);
736 }
737 
739 {
740  const SfxItemSet& rOld = GetItemSet();
741  SvxCellJustifyMethod eMethodOld = SvxCellJustifyMethod::Auto;
742  SvxCellJustifyMethod eMethodNew = SvxCellJustifyMethod::Auto;
743  if (const SfxEnumItemInterface* p = rOld.GetItemIfSet(nWhich))
744  {
745  eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
746  }
747 
748  if (const SfxEnumItemInterface* p = rNew.GetItemIfSet(nWhich))
749  {
750  eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
751  }
752 
753  return eMethodOld != eMethodNew;
754 }
755 
756 IMPL_LINK(AlignmentTabPage, StackedClickHdl, weld::Toggleable&, rToggle, void)
757 {
758  m_aStackedState.ButtonToggled(rToggle);
759  UpdateEnableControls();
760 }
761 
762 IMPL_LINK(AlignmentTabPage, AsianModeClickHdl, weld::Toggleable&, rToggle, void)
763 {
764  m_aAsianModeState.ButtonToggled(rToggle);
765 }
766 
767 IMPL_LINK(AlignmentTabPage, WrapClickHdl, weld::Toggleable&, rToggle, void)
768 {
769  m_aWrapState.ButtonToggled(rToggle);
770  UpdateEnableControls();
771 }
772 
773 IMPL_LINK(AlignmentTabPage, HyphenClickHdl, weld::Toggleable&, rToggle, void)
774 {
775  m_aHyphenState.ButtonToggled(rToggle);
776 }
777 
778 IMPL_LINK(AlignmentTabPage, ShrinkClickHdl, weld::Toggleable&, rToggle, void)
779 {
780  m_aShrinkState.ButtonToggled(rToggle);
781 }
782 
784 {
785  UpdateEnableControls();
786 }
787 
788 }
789 
790 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void UpdateEnableControls()
Definition: align.cxx:697
bool GetValue() const
#define ALIGNDLG_HORALIGN_DISTRIBUTED
Definition: align.hxx:28
SvxCellHorJustify
FieldUnit
weld::TriStateEnabled m_aHyphenState
Definition: align.hxx:80
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
void set_state(TriState eState)
virtual SfxBoolItem * Clone(SfxItemPool *=nullptr) const override
virtual sal_uInt16 GetEnumValue() const =0
static constexpr auto Items
bool HasAlignmentChanged(const SfxItemSet &rNew, TypedWhichId< SfxEnumItemInterface > nWhich) const
Definition: align.cxx:738
std::unique_ptr< weld::Widget > m_xAlignmentFrame
Definition: align.hxx:109
virtual void hide()=0
void SetOptimalSize()
std::unique_ptr< svx::FrameDirectionListBox > m_xLbFrameDir
Definition: align.hxx:101
std::unique_ptr< weld::Label > m_xFtRefEdge
Definition: align.hxx:93
sal_uInt16 GetValue() const
void InvalidateItem(sal_uInt16 nWhich)
#define ALIGNDLG_VERALIGN_STD
Definition: align.hxx:30
SvxFrameDirection
sal_uInt16 GetSelectedItemId() const
virtual OUString get_active_id() const =0
virtual int find_id(const OUString &rId) const =0
void SetStyle(WinBits nStyle)
std::unique_ptr< weld::Label > m_xFtVerAlign
Definition: align.hxx:88
AlignmentTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
Definition: align.cxx:109
static const WhichRangesContainer s_pRanges
Definition: align.hxx:50
std::unique_ptr< weld::MetricSpinButton > m_xNfRotate
Definition: align.hxx:92
void Clear()
#define ALIGNDLG_HORALIGN_RIGHT
Definition: align.hxx:25
virtual bool FillItemSet(SfxItemSet *)
std::unique_ptr< weld::Label > m_xFtRotate
Definition: align.hxx:91
std::unique_ptr< weld::CheckButton > m_xBtnWrap
Definition: align.hxx:98
virtual void set_active_id(const OUString &rStr)=0
weld::TriStateEnabled m_aWrapState
Definition: align.hxx:79
SvxCellVerJustify
std::unique_ptr< weld::CheckButton > m_xBtnHyphen
Definition: align.hxx:99
std::unique_ptr< weld::ComboBox > m_xLbVerAlign
Definition: align.hxx:89
#define WB_ITEMBORDER
void SetExchangeSupport()
OUString SvxResId(TranslateId aId)
std::unique_ptr< weld::CustomWeld > m_xCtrlDialWin
Definition: align.hxx:115
virtual void Reset(const SfxItemSet *)
std::unique_ptr< DialControl > m_xCtrlDial
Definition: align.hxx:114
#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:175
const SfxItemSet & GetItemSet() const
std::unique_ptr< weld::Label > m_xFtCelLock
Definition: align.hxx:106
#define ALIGNDLG_HORALIGN_LEFT
Definition: align.hxx:23
std::unique_ptr< weld::ComboBox > m_xLbHorAlign
Definition: align.hxx:85
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
std::unique_ptr< weld::Label > m_xFtABCD
Definition: align.hxx:107
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
std::unique_ptr< weld::CustomWeld > m_xVsRefEdge
Definition: align.hxx:113
weld::TriStateEnabled m_aAsianModeState
Definition: align.hxx:78
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:86
std::unique_ptr< weld::MetricSpinButton > m_xEdIndent
Definition: align.hxx:87
ValueSet m_aVsRefEdge
Definition: align.hxx:83
virtual void Reset(const SfxItemSet *rSet) override
Definition: align.cxx:423
std::unique_ptr< weld::Label > m_xFtTopLock
Definition: align.hxx:105
#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:77
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:110
std::unique_ptr< weld::CheckButton > m_xBtnShrink
Definition: align.hxx:100
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:95
void SetNoSelection()
void SetColCount(sal_uInt16 nNewCols=1)
#define IID_BOTTOMLOCK
Definition: align.cxx:36
weld::TriStateEnabled m_aShrinkState
Definition: align.hxx:81
Degree100 GetValue() const
void * p
virtual ~AlignmentTabPage() override
Definition: align.cxx:167
IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::Button &, void)
std::unique_ptr< weld::Widget > m_xPropertiesFrame
Definition: align.hxx:111
virtual SfxUInt16Item * Clone(SfxItemPool *=nullptr) const override
DeactivateRC
bool IsVerticalTextEnabled()
#define WB_DOUBLEBORDER
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: align.cxx:180
std::unique_ptr< weld::CheckButton > m_xCbStacked
Definition: align.hxx:94
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: align.cxx:669
SvxCellJustifyMethod
#define ALIGNDLG_HORALIGN_STD
Definition: align.hxx:22
std::unique_ptr< weld::Label > m_xFtBotLock
Definition: align.hxx:104
virtual void set_sensitive(bool sensitive)=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const