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