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