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 
29 #include <editeng/frmdiritem.hxx>
30 #include <editeng/justifyitem.hxx>
31 #include <svl/cjkoptions.hxx>
32 #include <svl/intitem.hxx>
33 #include <vcl/settings.hxx>
34 #include <vcl/event.hxx>
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  SvxJustifyMethodItem aItem(eJM, nWhichJM);
94  rSet.Put(aItem);
95 }
96 
97 }//namespace
98 
100  : SfxTabPage(pPage, pController, "cui/ui/cellalignment.ui", "CellAlignPage", &rCoreAttrs)
101  , m_aVsRefEdge(nullptr)
102  // text alignment
103  , m_xLbHorAlign(m_xBuilder->weld_combo_box("comboboxHorzAlign"))
104  , m_xFtIndent(m_xBuilder->weld_label("labelIndent"))
105  , m_xEdIndent(m_xBuilder->weld_metric_spin_button("spinIndentFrom", FieldUnit::POINT))
106  , m_xFtVerAlign(m_xBuilder->weld_label("labelVertAlign"))
107  , m_xLbVerAlign(m_xBuilder->weld_combo_box("comboboxVertAlign"))
108  //text rotation
109  , m_xFtRotate(m_xBuilder->weld_label("labelDegrees"))
110  , m_xNfRotate(m_xBuilder->weld_spin_button("spinDegrees"))
111  , m_xFtRefEdge(m_xBuilder->weld_label("labelRefEdge"))
112  //Asian mode
113  , m_xCbStacked(m_xBuilder->weld_check_button("checkVertStack"))
114  , m_xCbAsianMode(m_xBuilder->weld_check_button("checkAsianMode"))
115  // Properties
116  , m_xBoxDirection(m_xBuilder->weld_widget("boxDirection"))
117  , m_xBtnWrap(m_xBuilder->weld_check_button("checkWrapTextAuto"))
118  , m_xBtnHyphen(m_xBuilder->weld_check_button("checkHyphActive"))
119  , m_xBtnShrink(m_xBuilder->weld_check_button("checkShrinkFitCellSize"))
120  , m_xLbFrameDir(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboTextDirBox")))
121  //ValueSet hover strings
122  , m_xFtBotLock(m_xBuilder->weld_label("labelSTR_BOTTOMLOCK"))
123  , m_xFtTopLock(m_xBuilder->weld_label("labelSTR_TOPLOCK"))
124  , m_xFtCelLock(m_xBuilder->weld_label("labelSTR_CELLLOCK"))
125  , m_xFtABCD(m_xBuilder->weld_label("labelABCD"))
126  , m_xAlignmentFrame(m_xBuilder->weld_widget("alignment"))
127  , m_xOrientFrame(m_xBuilder->weld_widget("orientation"))
128  , m_xPropertiesFrame(m_xBuilder->weld_widget("properties"))
129  , m_xVsRefEdge(new weld::CustomWeld(*m_xBuilder, "references", m_aVsRefEdge))
130  , m_xCtrlDial(new weld::CustomWeld(*m_xBuilder, "dialcontrol", m_aCtrlDial))
131 {
133  m_aCtrlDial.SetText(m_xFtABCD->get_label());
134 
135  InitVsRefEgde();
136 
137  m_xLbHorAlign->connect_changed(LINK(this, AlignmentTabPage, UpdateEnableHdl));
138 
139  m_xCbStacked->connect_toggled(LINK(this, AlignmentTabPage, StackedClickHdl));
140  m_xCbAsianMode->connect_toggled(LINK(this, AlignmentTabPage, AsianModeClickHdl));
141  m_xBtnWrap->connect_toggled(LINK(this, AlignmentTabPage, WrapClickHdl));
142  m_xBtnHyphen->connect_toggled(LINK(this, AlignmentTabPage, HyphenClickHdl));
143  m_xBtnShrink->connect_toggled(LINK(this, AlignmentTabPage, ShrinkClickHdl));
144 
145  // Asian vertical mode
146  m_xCbAsianMode->set_visible(SvtCJKOptions().IsVerticalTextEnabled());
147 
148  m_xLbFrameDir->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
149  m_xLbFrameDir->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
150  m_xLbFrameDir->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
151 
152  // This page needs ExchangeSupport.
154 }
155 
157 {
158  m_xCtrlDial.reset();
159  m_xVsRefEdge.reset();
160  m_xLbFrameDir.reset();
161 }
162 
163 std::unique_ptr<SfxTabPage> AlignmentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
164 {
165  return std::make_unique<AlignmentTabPage>(pPage, pController, *rAttrSet);
166 }
167 
169 {
170  bool bChanged = SfxTabPage::FillItemSet(rSet);
171 
172  if (m_xLbHorAlign->get_value_changed_from_saved())
173  {
174  SvxCellHorJustify eJustify(SvxCellHorJustify::Standard);
175  switch (m_xLbHorAlign->get_active_id().toInt32())
176  {
178  eJustify = SvxCellHorJustify::Standard;
179  break;
181  eJustify = SvxCellHorJustify::Left;
182  break;
184  eJustify = SvxCellHorJustify::Center;
185  break;
187  eJustify = SvxCellHorJustify::Right;
188  break;
190  eJustify = SvxCellHorJustify::Block;
191  break;
193  eJustify = SvxCellHorJustify::Repeat;
194  break;
195  }
196  rSet->Put(SvxHorJustifyItem(eJustify, GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY)));
197  bChanged = true;
198  }
199 
200  if (m_xEdIndent->get_value_changed_from_saved())
201  {
202  rSet->Put(SfxUInt16Item(GetWhich(SID_ATTR_ALIGN_INDENT), m_xEdIndent->get_value(FieldUnit::TWIP)));
203  bChanged = true;
204  }
205 
206  if (m_xLbVerAlign->get_value_changed_from_saved())
207  {
208  SvxCellVerJustify eJustify(SvxCellVerJustify::Standard);
209  switch (m_xLbVerAlign->get_active_id().toInt32())
210  {
212  eJustify = SvxCellVerJustify::Standard;
213  break;
215  eJustify = SvxCellVerJustify::Top;
216  break;
218  eJustify = SvxCellVerJustify::Center;
219  break;
221  eJustify = SvxCellVerJustify::Bottom;
222  break;
224  eJustify = SvxCellVerJustify::Block;
225  break;
226  }
227  rSet->Put(SvxVerJustifyItem(eJustify, GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY)));
228  bChanged = true;
229  }
230 
231  if (m_xNfRotate->get_value_changed_from_saved())
232  {
233  rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_ALIGN_DEGREES), m_aCtrlDial.GetRotation()));
234  bChanged = true;
235  }
236 
238  {
240  {
241  case IID_CELLLOCK:
242  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, GetWhich(SID_ATTR_ALIGN_LOCKPOS)));
243  break;
244  case IID_TOPLOCK:
245  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, GetWhich(SID_ATTR_ALIGN_LOCKPOS)));
246  break;
247  case IID_BOTTOMLOCK:
248  rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, GetWhich(SID_ATTR_ALIGN_LOCKPOS)));
249  break;
250  default:
252  break;
253  }
254  bChanged = true;
255  }
256 
257  if (m_xCbStacked->get_state_changed_from_saved())
258  {
259  rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_STACKED), m_xCbStacked->get_active()));
260  bChanged = true;
261  }
262 
263  if (m_xCbAsianMode->get_state_changed_from_saved())
264  {
265  rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL), m_xCbAsianMode->get_active()));
266  bChanged = true;
267  }
268 
269  if (m_xBtnWrap->get_state_changed_from_saved())
270  {
271  rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_LINEBREAK), m_xBtnWrap->get_active()));
272  bChanged = true;
273  }
274 
275  if (m_xBtnHyphen->get_state_changed_from_saved())
276  {
277  rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_HYPHENATION), m_xBtnHyphen->get_active()));
278  bChanged = true;
279  }
280 
281  if (m_xBtnShrink->get_state_changed_from_saved())
282  {
283  rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), m_xBtnShrink->get_active()));
284  bChanged = true;
285  }
286 
287  if (m_xLbFrameDir->get_visible())
288  {
289  if (m_xLbFrameDir->get_value_changed_from_saved())
290  {
291  SvxFrameDirection eDir = m_xLbFrameDir->get_active_id();
292  rSet->Put(SvxFrameDirectionItem(eDir, GetWhich(SID_ATTR_FRAMEDIRECTION)));
293  bChanged = true;
294  }
295  }
296 
297  // Special treatment for distributed alignment; we need to set the justify
298  // method to 'distribute' to distinguish from the normal justification.
299 
300  sal_uInt16 nWhichHorJM = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD);
301  lcl_SetJustifyMethodToItemSet(*rSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED);
302  if (!bChanged)
303  bChanged = HasAlignmentChanged(*rSet, nWhichHorJM);
304 
305  sal_uInt16 nWhichVerJM = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD);
306  lcl_SetJustifyMethodToItemSet(*rSet, nWhichVerJM, *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED);
307  if (!bChanged)
308  bChanged = HasAlignmentChanged(*rSet, nWhichVerJM);
309 
310  return bChanged;
311 }
312 
313 namespace
314 {
315  void ResetBool(sal_uInt16 nWhich, const SfxItemSet* pSet, weld::CheckButton& rBtn, weld::TriStateEnabled& rTriState)
316  {
317  SfxItemState eState = pSet->GetItemState(nWhich);
318  switch (eState)
319  {
320  case SfxItemState::UNKNOWN:
321  rBtn.hide();
322  rTriState.bTriStateEnabled = false;
323  break;
324  case SfxItemState::DISABLED:
325  case SfxItemState::READONLY:
326  rBtn.set_sensitive(false);
327  rTriState.bTriStateEnabled = false;
328  break;
329  case SfxItemState::DONTCARE:
330  rBtn.set_state(TRISTATE_INDET);
331  rTriState.bTriStateEnabled = true;
332  break;
333  case SfxItemState::DEFAULT:
334  case SfxItemState::SET:
335  {
336  const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(pSet->Get(nWhich));
337  rBtn.set_state(static_cast<TriState>(rItem.GetValue()));
338  rTriState.bTriStateEnabled = false;
339  break;
340  }
341  }
342  rBtn.save_state();
343  }
344 }
345 
346 void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs)
347 {
348  SfxTabPage::Reset(pCoreAttrs);
349 
350  ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED), pCoreAttrs, *m_xCbStacked, m_aStackedState);
351  ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL), pCoreAttrs, *m_xCbAsianMode, m_aAsianModeState);
352  ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK), pCoreAttrs, *m_xBtnWrap, m_aWrapState);
353  ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION), pCoreAttrs, *m_xBtnHyphen, m_aHyphenState);
354  ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), pCoreAttrs, *m_xBtnShrink, m_aShrinkState);
355 
356  sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
357  SfxItemState eState = pCoreAttrs->GetItemState(nWhich);
358  switch (eState)
359  {
360  case SfxItemState::UNKNOWN:
361  m_xLbHorAlign->hide();
362  break;
363  case SfxItemState::DISABLED:
364  case SfxItemState::READONLY:
365  m_xLbHorAlign->set_sensitive(false);
366  break;
367  case SfxItemState::DONTCARE:
368  m_xLbHorAlign->set_active(-1);
369  break;
370  case SfxItemState::DEFAULT:
371  case SfxItemState::SET:
372  {
373  const SvxHorJustifyItem& rJustifyItem = static_cast<const SvxHorJustifyItem&>(pCoreAttrs->Get(nWhich));
374  switch (rJustifyItem.GetValue())
375  {
376  case SvxCellHorJustify::Standard:
377  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_STD));
378  break;
379  case SvxCellHorJustify::Left:
380  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_LEFT));
381  break;
382  case SvxCellHorJustify::Center:
383  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_CENTER));
384  break;
385  case SvxCellHorJustify::Right:
386  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_RIGHT));
387  break;
388  case SvxCellHorJustify::Block:
389  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_BLOCK));
390  break;
391  case SvxCellHorJustify::Repeat:
392  m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_FILL));
393  break;
394  }
395  break;
396  }
397  }
398 
399  nWhich = GetWhich(SID_ATTR_ALIGN_INDENT);
400  eState = pCoreAttrs->GetItemState(nWhich);
401  switch (eState)
402  {
403  case SfxItemState::UNKNOWN:
404  m_xEdIndent->hide();
405  m_xFtIndent->hide();
406  break;
407  case SfxItemState::DISABLED:
408  case SfxItemState::READONLY:
409  m_xEdIndent->set_sensitive(false);
410  break;
411  case SfxItemState::DONTCARE:
412  m_xEdIndent->set_text("");
413  break;
414  case SfxItemState::DEFAULT:
415  case SfxItemState::SET:
416  {
417  const SfxUInt16Item& rIndentItem = static_cast<const SfxUInt16Item&>(pCoreAttrs->Get(nWhich));
418  m_xEdIndent->set_value(rIndentItem.GetValue(), FieldUnit::TWIP);
419  break;
420  }
421  }
422 
423  nWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY);
424  eState = pCoreAttrs->GetItemState(nWhich);
425  switch (eState)
426  {
427  case SfxItemState::UNKNOWN:
428  m_xLbVerAlign->hide();
429  m_xFtVerAlign->hide();
430  break;
431  case SfxItemState::DISABLED:
432  case SfxItemState::READONLY:
433  m_xLbVerAlign->set_sensitive(false);
434  break;
435  case SfxItemState::DONTCARE:
436  m_xLbVerAlign->set_active(-1);
437  break;
438  case SfxItemState::DEFAULT:
439  case SfxItemState::SET:
440  {
441  const SvxVerJustifyItem& rJustifyItem = static_cast<const SvxVerJustifyItem&>(pCoreAttrs->Get(nWhich));
442  switch (rJustifyItem.GetValue())
443  {
444  case SvxCellVerJustify::Standard:
445  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_STD));
446  break;
447  case SvxCellVerJustify::Top:
448  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_TOP));
449  break;
450  case SvxCellVerJustify::Center:
451  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_MID));
452  break;
453  case SvxCellVerJustify::Bottom:
454  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BOTTOM));
455  break;
456  case SvxCellVerJustify::Block:
457  m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BLOCK));
458  break;
459  }
460  break;
461  }
462  }
463 
464  nWhich = GetWhich(SID_ATTR_ALIGN_DEGREES);
465  eState = pCoreAttrs->GetItemState(nWhich);
466  switch (eState)
467  {
468  case SfxItemState::UNKNOWN:
469  m_xNfRotate->hide();
470  m_xCtrlDial->hide();
471  break;
472  case SfxItemState::DISABLED:
473  case SfxItemState::READONLY:
474  m_xNfRotate->set_sensitive(false);
475  m_xCtrlDial->set_sensitive(false);
476  break;
477  case SfxItemState::DONTCARE:
479  break;
480  case SfxItemState::DEFAULT:
481  case SfxItemState::SET:
482  {
483  const SfxInt32Item& rAlignItem = static_cast<const SfxInt32Item&>(pCoreAttrs->Get(nWhich));
484  m_aCtrlDial.SetRotation(rAlignItem.GetValue());
485  break;
486  }
487  }
488 
489  nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS);
490  eState = pCoreAttrs->GetItemState(nWhich);
491  switch (eState)
492  {
493  case SfxItemState::UNKNOWN:
494  m_xVsRefEdge->hide();
495  break;
496  case SfxItemState::DISABLED:
497  case SfxItemState::READONLY:
498  m_xVsRefEdge->set_sensitive(false);
499  break;
500  case SfxItemState::DONTCARE:
502  break;
503  case SfxItemState::DEFAULT:
504  case SfxItemState::SET:
505  {
506  const SvxRotateModeItem& rRotateModeItem = static_cast<const SvxRotateModeItem&>(pCoreAttrs->Get(nWhich));
507  switch (rRotateModeItem.GetValue())
508  {
509  case SvxRotateMode::SVX_ROTATE_MODE_STANDARD:
511  break;
512  case SvxRotateMode::SVX_ROTATE_MODE_TOP:
514  break;
515  case SvxRotateMode::SVX_ROTATE_MODE_BOTTOM:
517  break;
518  default:
520  break;
521  }
522  break;
523  }
524  }
526 
527  //text direction
528  nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION);
529  eState = pCoreAttrs->GetItemState(nWhich);
530  switch (eState)
531  {
532  case SfxItemState::UNKNOWN:
533  m_xLbFrameDir->hide();
534  break;
535  case SfxItemState::DISABLED:
536  case SfxItemState::READONLY:
537  m_xLbFrameDir->set_sensitive(false);
538  break;
539  case SfxItemState::DONTCARE:
540  m_xLbFrameDir->set_active(-1);
541  break;
542  case SfxItemState::DEFAULT:
543  case SfxItemState::SET:
544  {
545  const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>(pCoreAttrs->Get(nWhich));
546  m_xLbFrameDir->set_active_id(rFrameDirItem.GetValue());
547  break;
548  }
549  }
550 
551 
552  // Special treatment for distributed alignment; we need to set the justify
553  // method to 'distribute' to distinguish from the normal justification.
554 
555  lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>(
557  GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD),
558  SvxCellHorJustify::Block);
559 
560  lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>(
562  GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD),
563  SvxCellVerJustify::Block);
564 
565  m_xLbHorAlign->save_value();
566  m_xLbFrameDir->save_value();
567  m_xLbVerAlign->save_value();
568  m_xNfRotate->save_value();
569  m_xEdIndent->save_value();
570 
572 }
573 
575 {
576  if( _pSet )
577  FillItemSet( _pSet );
578  return DeactivateRC::LeavePage;
579 }
580 
582 {
583  // remember selection - is deleted in call to ValueSet::Clear()
584  sal_uInt16 nSel = m_aVsRefEdge.GetSelectedItemId();
585 
586  Image aBottomLock(StockImage::Yes, RID_SVXBMP_BOTTOMLOCK);
587  Image aTopLock(StockImage::Yes, RID_SVXBMP_TOPLOCK);
588  Image aCellLock(StockImage::Yes, RID_SVXBMP_CELLLOCK);
589 
592 
594  m_aVsRefEdge.InsertItem(IID_BOTTOMLOCK, aBottomLock, m_xFtBotLock->get_label());
595  m_aVsRefEdge.InsertItem(IID_TOPLOCK, aTopLock, m_xFtTopLock->get_label());
596  m_aVsRefEdge.InsertItem(IID_CELLLOCK, aCellLock, m_xFtCelLock->get_label());
598 
599  m_aVsRefEdge.SelectItem( nSel );
600 }
601 
603 {
604  const sal_Int32 nHorAlign = m_xLbHorAlign->get_active();
605  bool bHorLeft = (nHorAlign == ALIGNDLG_HORALIGN_LEFT);
606  bool bHorBlock = (nHorAlign == ALIGNDLG_HORALIGN_BLOCK);
607  bool bHorFill = (nHorAlign == ALIGNDLG_HORALIGN_FILL);
608  bool bHorDist = (nHorAlign == ALIGNDLG_HORALIGN_DISTRIBUTED);
609 
610  // indent edit field only for left alignment
611  m_xFtIndent->set_sensitive( bHorLeft );
612  m_xEdIndent->set_sensitive( bHorLeft );
613 
614  // stacked disabled for fill alignment
615  m_xCbStacked->set_sensitive(!bHorFill);
616 
617  // hyphenation only for automatic line breaks or for block alignment
618  m_xBtnHyphen->set_sensitive( m_xBtnWrap->get_active() || bHorBlock );
619 
620  // shrink only without automatic line break, and not for block, fill or distribute.
621  m_xBtnShrink->set_sensitive( (m_xBtnWrap->get_state() == TRISTATE_FALSE) && !bHorBlock && !bHorFill && !bHorDist );
622 
623  // visibility of frames
624  m_xAlignmentFrame->set_visible(m_xLbHorAlign->get_visible() || m_xEdIndent->get_visible() ||
625  m_xLbVerAlign->get_visible());
626  m_xOrientFrame->set_visible(m_xCtrlDial->get_visible() || m_xVsRefEdge->get_visible() ||
627  m_xCbStacked->get_visible() || m_xCbAsianMode->get_visible());
628  m_xPropertiesFrame->set_visible(m_xBtnWrap->get_visible() || m_xBtnHyphen->get_visible() ||
629  m_xBtnShrink->get_visible() || m_xLbFrameDir->get_visible());
630 
631  bool bStackedText = m_xCbStacked->get_active();
632  // windows to be disabled, if stacked text is turned ON
633  m_xFtRotate->set_sensitive(!bStackedText);
634  m_xFtRefEdge->set_sensitive(!bStackedText);
635  m_xVsRefEdge->set_sensitive(!bStackedText);
636  // windows to be disabled, if stacked text is turned OFF
637  m_xCbAsianMode->set_sensitive(bStackedText);
638  // rotation/stacked disabled for fill alignment/stacked
639  m_xCtrlDial->set_sensitive(!bHorFill && !bStackedText);
640  m_xNfRotate->set_sensitive(!bHorFill && !bStackedText);
641 }
642 
643 bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const
644 {
645  const SfxItemSet& rOld = GetItemSet();
646  const SfxPoolItem* pItem;
647  SvxCellJustifyMethod eMethodOld = SvxCellJustifyMethod::Auto;
648  SvxCellJustifyMethod eMethodNew = SvxCellJustifyMethod::Auto;
649  if (rOld.GetItemState(nWhich, true, &pItem) == SfxItemState::SET)
650  {
651  const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem);
652  eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
653  }
654 
655  if (rNew.GetItemState(nWhich, true, &pItem) == SfxItemState::SET)
656  {
657  const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem);
658  eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
659  }
660 
661  return eMethodOld != eMethodNew;
662 }
663 
664 IMPL_LINK(AlignmentTabPage, StackedClickHdl, weld::ToggleButton&, rToggle, void)
665 {
666  m_aStackedState.ButtonToggled(rToggle);
667  UpdateEnableControls();
668 }
669 
670 IMPL_LINK(AlignmentTabPage, AsianModeClickHdl, weld::ToggleButton&, rToggle, void)
671 {
672  m_aAsianModeState.ButtonToggled(rToggle);
673 }
674 
675 IMPL_LINK(AlignmentTabPage, WrapClickHdl, weld::ToggleButton&, rToggle, void)
676 {
677  m_aWrapState.ButtonToggled(rToggle);
678  UpdateEnableControls();
679 }
680 
681 IMPL_LINK(AlignmentTabPage, HyphenClickHdl, weld::ToggleButton&, rToggle, void)
682 {
683  m_aHyphenState.ButtonToggled(rToggle);
684 }
685 
686 IMPL_LINK(AlignmentTabPage, ShrinkClickHdl, weld::ToggleButton&, rToggle, void)
687 {
688  m_aShrinkState.ButtonToggled(rToggle);
689 }
690 
692 {
693  UpdateEnableControls();
694 }
695 
696 }
697 
698 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void UpdateEnableControls()
Definition: align.cxx:602
bool GetValue() const
SvxDialControl m_aCtrlDial
Definition: align.hxx:82
sal_Int32 GetValue() const
#define ALIGNDLG_HORALIGN_DISTRIBUTED
Definition: align.hxx:29
SvxCellHorJustify
FieldUnit
weld::TriStateEnabled m_aHyphenState
Definition: align.hxx:79
virtual sal_uInt16 GetEnumValue() const =0
std::unique_ptr< weld::Widget > m_xAlignmentFrame
Definition: align.hxx:109
virtual void hide()=0
std::unique_ptr< svx::FrameDirectionListBox > m_xLbFrameDir
Definition: align.hxx:101
void SetLinkedField(weld::SpinButton *pField, sal_Int32 nDecimalPlaces=0)
std::unique_ptr< weld::Label > m_xFtRefEdge
Definition: align.hxx:93
IMPL_LINK_NOARG(ClassificationDialog, OnAsyncExpandHdl, void *, void)
sal_uInt16 GetValue() const
#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:88
AlignmentTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
Definition: align.cxx:99
#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:91
std::unique_ptr< weld::CheckButton > m_xBtnWrap
Definition: align.hxx:98
weld::TriStateEnabled m_aWrapState
Definition: align.hxx:78
SvxCellVerJustify
std::unique_ptr< weld::CheckButton > m_xBtnHyphen
Definition: align.hxx:99
OUString SvxResId(const char *pId)
std::unique_ptr< weld::ComboBox > m_xLbVerAlign
Definition: align.hxx:89
#define WB_ITEMBORDER
std::unique_ptr< weld::SpinButton > m_xNfRotate
Definition: align.hxx:92
sal_uInt16 GetSelectedItemId() const
void SetExchangeSupport()
void Clear()
virtual void Reset(const SfxItemSet *)
#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:163
const SfxItemSet & GetItemSet() const
std::unique_ptr< weld::Label > m_xFtCelLock
Definition: align.hxx:106
#define ALIGNDLG_HORALIGN_LEFT
Definition: align.hxx:24
std::unique_ptr< weld::CustomWeld > m_xCtrlDial
Definition: align.hxx:114
std::unique_ptr< weld::ComboBox > m_xLbHorAlign
Definition: align.hxx:85
void SetStyle(WinBits nStyle)
std::unique_ptr< weld::Label > m_xFtABCD
Definition: align.hxx:107
void SetRotation(sal_Int32 nAngle)
void SetText(const OUString &rText)
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:643
std::unique_ptr< weld::CustomWeld > m_xVsRefEdge
Definition: align.hxx:113
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:86
std::unique_ptr< weld::MetricSpinButton > m_xEdIndent
Definition: align.hxx:87
virtual void Reset(const SfxItemSet *rSet) override
Definition: align.cxx:346
std::unique_ptr< weld::Label > m_xFtTopLock
Definition: align.hxx:105
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: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:32
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::CheckButton > m_xCbAsianMode
Definition: align.hxx:95
SvtValueSet m_aVsRefEdge
Definition: align.hxx:83
#define IID_BOTTOMLOCK
Definition: align.cxx:36
weld::TriStateEnabled m_aShrinkState
Definition: align.hxx:80
virtual ~AlignmentTabPage() override
Definition: align.cxx:156
std::unique_ptr< weld::Widget > m_xPropertiesFrame
Definition: align.hxx:111
sal_Int32 GetRotation() const
DeactivateRC
void SelectItem(sal_uInt16 nItemId)
#define WB_DOUBLEBORDER
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: align.cxx:168
void SetColCount(sal_uInt16 nNewCols=1)
std::unique_ptr< weld::CheckButton > m_xCbStacked
Definition: align.hxx:94
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
void set_state(TriState eState)
void SaveValue()
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: align.cxx:574
SvxCellJustifyMethod
#define ALIGNDLG_HORALIGN_STD
Definition: align.hxx:23
std::unique_ptr< weld::Label > m_xFtBotLock
Definition: align.hxx:104
void SetNoSelection()
virtual void set_sensitive(bool sensitive)=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const