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