LibreOffice Module sw (master)  1
num.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 <hintids.hxx>
21 #include <sfx2/app.hxx>
22 #include <svx/gallery.hxx>
23 #include <editeng/brushitem.hxx>
24 #include <editeng/lrspitem.hxx>
25 #include <editeng/numitem.hxx>
26 #include <cmdid.h>
27 #include <swmodule.hxx>
28 #include <wrtsh.hxx>
29 #include <docsh.hxx>
30 #include <wview.hxx>
31 #include <uitool.hxx>
32 #include <wdocsh.hxx>
33 #include <uiitems.hxx>
34 #include <docstyle.hxx>
35 #include <charfmt.hxx>
36 #include <uinums.hxx>
37 #include <poolfmt.hxx>
38 #include <shellres.hxx>
39 #include <outline.hxx>
40 #include <num.hxx>
41 #include <viewopt.hxx>
42 #include <frmmgr.hxx>
43 
44 #include <globals.hrc>
45 #include <SwStyleNameMapper.hxx>
46 #include <svx/svxids.hrc>
47 #include <svx/dialogs.hrc>
48 #include <svl/stritem.hxx>
49 #include <svl/aeitem.hxx>
50 #include <svl/slstitm.hxx>
51 
52 static bool bLastRelative = false;
53 
54 //See cui/uiconfig/ui/numberingpositionpage.ui for effectively a duplicate
55 //dialog to this one, except with a different preview window impl.
56 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
57 //merged
59  : SfxTabPage(pParent, "modules/swriter/ui/outlinepositionpage.ui", "OutlinePositionPage", &rSet)
60  , pSaveNum(nullptr)
61  , pWrtSh(nullptr)
62  , pOutlineDlg(nullptr)
63  , nActNumLvl(0)
64  , bModified(false)
65  , bPreset(false)
66  , bInInintControl(false)
67  , bLabelAlignmentPosAndSpaceModeActive(false)
68  , m_xLevelLB(m_xBuilder->weld_tree_view("levellb"))
69  , m_xPositionFrame(m_xBuilder->weld_widget("numberingframe"))
70  , m_xDistBorderFT(m_xBuilder->weld_label("indent"))
71  , m_xDistBorderMF(m_xBuilder->weld_metric_spin_button("indentmf", FieldUnit::CM))
72  , m_xRelativeCB(m_xBuilder->weld_check_button("relative"))
73  , m_xIndentFT(m_xBuilder->weld_label("numberingwidth"))
74  , m_xIndentMF(m_xBuilder->weld_metric_spin_button("numberingwidthmf", FieldUnit::CM))
75  , m_xDistNumFT(m_xBuilder->weld_label("numdist"))
76  , m_xDistNumMF(m_xBuilder->weld_metric_spin_button("numdistmf", FieldUnit::CM))
77  , m_xAlignFT(m_xBuilder->weld_label("numalign"))
78  , m_xAlignLB(m_xBuilder->weld_combo_box("numalignlb"))
79  , m_xLabelFollowedByFT(m_xBuilder->weld_label("numfollowedby"))
80  , m_xLabelFollowedByLB(m_xBuilder->weld_combo_box("numfollowedbylb"))
81  , m_xListtabFT(m_xBuilder->weld_label("at"))
82  , m_xListtabMF(m_xBuilder->weld_metric_spin_button("atmf", FieldUnit::CM))
83  , m_xAlign2FT(m_xBuilder->weld_label("num2align"))
84  , m_xAlign2LB(m_xBuilder->weld_combo_box("num2alignlb"))
85  , m_xAlignedAtFT(m_xBuilder->weld_label("alignedat"))
86  , m_xAlignedAtMF(m_xBuilder->weld_metric_spin_button("alignedatmf", FieldUnit::CM))
87  , m_xIndentAtFT(m_xBuilder->weld_label("indentat"))
88  , m_xIndentAtMF(m_xBuilder->weld_metric_spin_button("indentatmf", FieldUnit::CM))
89  , m_xStandardPB(m_xBuilder->weld_button("standard"))
90  , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
91 {
93 
94  m_xLevelLB->set_selection_mode(SelectionMode::Multiple);
95 
96  m_xRelativeCB->set_active(true);
97  m_xAlignLB->connect_changed(LINK(this, SwNumPositionTabPage, EditModifyHdl));
98  m_xAlign2LB->connect_changed(LINK(this, SwNumPositionTabPage, EditModifyHdl));
99  for (int i = 0; i < m_xAlignLB->get_count(); ++i)
100  {
101  m_xAlign2LB->append_text(m_xAlignLB->get_text(i));
102  }
103  m_xAlign2FT->set_label(m_xAlignFT->get_label());
104 
106  m_xDistBorderMF->connect_value_changed(aLk);
107  m_xDistNumMF->connect_value_changed(aLk);
108  m_xIndentMF->connect_value_changed(aLk);
109 
110  m_xLabelFollowedByLB->connect_changed( LINK(this, SwNumPositionTabPage, LabelFollowedByHdl_Impl) );
111 
112  aLk = LINK(this, SwNumPositionTabPage, ListtabPosHdl_Impl);
113  m_xListtabMF->connect_value_changed(aLk);
114 
115  aLk = LINK(this, SwNumPositionTabPage, AlignAtHdl_Impl);
116  m_xAlignedAtMF->connect_value_changed(aLk);
117 
118  aLk = LINK(this, SwNumPositionTabPage, IndentAtHdl_Impl);
119  m_xIndentAtMF->connect_value_changed(aLk);
120 
121  m_xLevelLB->connect_changed(LINK(this, SwNumPositionTabPage, LevelHdl));
122  m_xRelativeCB->connect_toggled(LINK(this, SwNumPositionTabPage, RelativeHdl));
123  m_xStandardPB->connect_clicked(LINK(this, SwNumPositionTabPage, StandardHdl));
124 
125  // insert levels
126  for(sal_uInt16 i = 1; i <= MAXLEVEL; i++)
127  m_xLevelLB->append_text(OUString::number(i));
128  OUString sEntry("1 - ");
129  sEntry += OUString::number(MAXLEVEL);
130  m_xLevelLB->append_text(sEntry);
131  m_xLevelLB->select_text(sEntry);
132 
133  m_xRelativeCB->set_active(bLastRelative);
135 }
136 
138 {
139  disposeOnce();
140 }
141 
143 {
144  pActNum.reset();
145  pOutlineDlg = nullptr;
147 }
148 
150 {
151  bInInintControl = true;
152  const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
153  m_xRelativeCB->get_sensitive() && m_xRelativeCB->get_active();
154  const bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 &&
156 
158  ( bSingleSelection || bRelative || pOutlineDlg != nullptr ) );
160  ( bSingleSelection || bRelative || pOutlineDlg != nullptr ) );
161 
162  bool bSetDistEmpty = false;
163  bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
164  bool bSameDist = !bLabelAlignmentPosAndSpaceModeActive;
165  bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
166  bool bSameAdjust = true;
167 
168  bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
169  bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
170  bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
171  bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
172 
173  const SwNumFormat* aNumFormatArr[MAXLEVEL];
174  sal_uInt16 nMask = 1;
175  sal_uInt16 nLvl = USHRT_MAX;
176  long nFirstBorderTextRelative = -1;
177  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
178  {
179  aNumFormatArr[i] = &pActNum->Get(i);
180  if(nActNumLvl & nMask)
181  {
182  if(USHRT_MAX == nLvl)
183  {
184  nLvl = i;
185  }
186 
187  if( i > nLvl)
188  {
189  bSameAdjust &= aNumFormatArr[i]->GetNumAdjust() == aNumFormatArr[nLvl]->GetNumAdjust();
191  {
192  if(bRelative)
193  {
194  const long nBorderTextRelative =
195  aNumFormatArr[i]->GetAbsLSpace() + aNumFormatArr[i]->GetFirstLineOffset() -
196  aNumFormatArr[i - 1]->GetAbsLSpace() + aNumFormatArr[i - 1]->GetFirstLineOffset();
197  if (nFirstBorderTextRelative == -1)
198  nFirstBorderTextRelative = nBorderTextRelative;
199  else
200  bSameDistBorderNum &= nFirstBorderTextRelative == nBorderTextRelative;
201  }
202  else
203  {
204  bSameDistBorderNum &=
205  aNumFormatArr[i]->GetAbsLSpace() - aNumFormatArr[i]->GetFirstLineOffset() ==
206  aNumFormatArr[i - 1]->GetAbsLSpace() - aNumFormatArr[i - 1]->GetFirstLineOffset();
207  }
208 
209  bSameDist &= aNumFormatArr[i]->GetCharTextDistance() == aNumFormatArr[nLvl]->GetCharTextDistance();
210  bSameIndent &= aNumFormatArr[i]->GetFirstLineOffset() == aNumFormatArr[nLvl]->GetFirstLineOffset();
211  }
212  else
213  {
214  bSameLabelFollowedBy &=
215  aNumFormatArr[i]->GetLabelFollowedBy() == aNumFormatArr[nLvl]->GetLabelFollowedBy();
216  bSameListtab &=
217  aNumFormatArr[i]->GetListtabPos() == aNumFormatArr[nLvl]->GetListtabPos();
218  bSameAlignAt &=
219  ( ( aNumFormatArr[i]->GetIndentAt() + aNumFormatArr[i]->GetFirstLineIndent() )
220  == ( aNumFormatArr[nLvl]->GetIndentAt() + aNumFormatArr[nLvl]->GetFirstLineIndent() ) );
221  bSameIndentAt &=
222  aNumFormatArr[i]->GetIndentAt() == aNumFormatArr[nLvl]->GetIndentAt();
223  }
224  }
225  }
226  nMask <<= 1;
227 
228  }
229  if (MAXLEVEL <= nLvl)
230  {
231  OSL_ENSURE(false, "cannot happen.");
232  return;
233  }
234  if(bSameDistBorderNum)
235  {
236  long nDistBorderNum;
237  if(bRelative)
238  {
239  nDistBorderNum = static_cast<long>(aNumFormatArr[nLvl]->GetAbsLSpace())+ aNumFormatArr[nLvl]->GetFirstLineOffset();
240  if(nLvl)
241  nDistBorderNum -= static_cast<long>(aNumFormatArr[nLvl - 1]->GetAbsLSpace())+ aNumFormatArr[nLvl - 1]->GetFirstLineOffset();
242  }
243  else
244  {
245  nDistBorderNum = static_cast<long>(aNumFormatArr[nLvl]->GetAbsLSpace())+ aNumFormatArr[nLvl]->GetFirstLineOffset();
246  }
247  m_xDistBorderMF->set_value(m_xDistBorderMF->normalize(nDistBorderNum),FieldUnit::TWIP);
248  }
249  else
250  bSetDistEmpty = true;
251 
252  if(bSameDist)
253  m_xDistNumMF->set_value(m_xDistNumMF->normalize(aNumFormatArr[nLvl]->GetCharTextDistance()), FieldUnit::TWIP);
254  else
255  m_xDistNumMF->set_text(OUString());
256  if(bSameIndent)
257  m_xIndentMF->set_value(m_xIndentMF->normalize(-aNumFormatArr[nLvl]->GetFirstLineOffset()), FieldUnit::TWIP);
258  else
259  m_xIndentMF->set_text(OUString());
260 
261  if(bSameAdjust)
262  {
263  sal_Int32 nPos = 1; // centered
264  if(aNumFormatArr[nLvl]->GetNumAdjust() == SvxAdjust::Left)
265  nPos = 0;
266  else if(aNumFormatArr[nLvl]->GetNumAdjust() == SvxAdjust::Right)
267  nPos = 2;
268  m_xAlignLB->set_active(nPos);
269  m_xAlign2LB->set_active( nPos );
270  }
271  else
272  {
273  m_xAlignLB->set_active(-1);
274  m_xAlign2LB->set_active(-1);
275  }
276 
277  if ( bSameLabelFollowedBy )
278  {
279  sal_Int32 nPos = 0; // LISTTAB
280  if ( aNumFormatArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
281  {
282  nPos = 1;
283  }
284  else if ( aNumFormatArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
285  {
286  nPos = 2;
287  }
288  else if ( aNumFormatArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NEWLINE )
289  {
290  nPos = 3;
291  }
292  m_xLabelFollowedByLB->set_active(nPos);
293  }
294  else
295  {
296  m_xLabelFollowedByLB->set_active(-1);
297  }
298 
299  if ( aNumFormatArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
300  {
301  m_xListtabFT->set_sensitive(true);
302  m_xListtabMF->set_sensitive(true);
303  if ( bSameListtab )
304  {
305  m_xListtabMF->set_value(m_xListtabMF->normalize(aNumFormatArr[nLvl]->GetListtabPos()),FieldUnit::TWIP);
306  }
307  else
308  {
309  m_xListtabMF->set_text(OUString());
310  }
311  }
312  else
313  {
314  m_xListtabFT->set_sensitive( false );
315  m_xListtabMF->set_sensitive( false );
316  m_xListtabMF->set_text(OUString());
317  }
318 
319  if ( bSameAlignAt )
320  {
321  m_xAlignedAtMF->set_value(
322  m_xAlignedAtMF->normalize( aNumFormatArr[nLvl]->GetIndentAt() +
323  aNumFormatArr[nLvl]->GetFirstLineIndent()),
324  FieldUnit::TWIP );
325  }
326  else
327  {
328  m_xAlignedAtMF->set_text(OUString());
329  }
330 
331  if ( bSameIndentAt )
332  {
333  m_xIndentAtMF->set_value(
334  m_xIndentAtMF->normalize( aNumFormatArr[nLvl]->GetIndentAt()), FieldUnit::TWIP );
335  }
336  else
337  {
338  m_xIndentAtMF->set_text(OUString());
339  }
340 
341  if (bSetDistEmpty)
342  m_xDistBorderMF->set_text(OUString());
343 
344  bInInintControl = false;
345 }
346 
348 {
349  const SfxPoolItem* pItem;
350  sal_uInt16 nTmpNumLvl =
352  const SfxItemSet* pExampleSet = GetDialogExampleSet();
353  if(pExampleSet && pExampleSet->GetItemState(FN_PARAM_NUM_PRESET, false, &pItem) != SfxItemState::UNKNOWN)
354  {
355  bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
356  }
357  bModified = (!pActNum->GetNumFormat( 0 ) || bPreset);
358  if(*pActNum != *pSaveNum ||
359  nActNumLvl != nTmpNumLvl )
360  {
361  *pActNum = *pSaveNum;
362  nActNumLvl = nTmpNumLvl;
363  sal_uInt16 nMask = 1;
364  m_xLevelLB->unselect_all();
365  if (nActNumLvl == USHRT_MAX)
366  m_xLevelLB->select(MAXLEVEL);
367  else
368  {
369  for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
370  {
371  if (nActNumLvl & nMask)
372  m_xLevelLB->select(i);
373  nMask <<= 1 ;
374  }
375  }
376 
379 
380  InitControls();
381  }
382  m_xRelativeCB->set_sensitive(1 != nActNumLvl);
384 }
385 
387 {
389  if(_pSet)
390  FillItemSet(_pSet);
391  return DeactivateRC::LeavePage;
392 
393 }
394 
396 {
397  if(pOutlineDlg)
399  else if(bModified && pActNum)
400  {
401  *pSaveNum = *pActNum;
402  rSet->Put(SwUINumRuleItem( *pSaveNum ));
403  rSet->Put(SfxBoolItem(FN_PARAM_NUM_PRESET, false));
404  }
405  return bModified;
406 }
407 
409 {
410  const SfxPoolItem* pItem;
411  if (pOutlineDlg)
412  {
414  m_xLevelLB->set_selection_mode(SelectionMode::Single);
415  }
416  else if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_ACT_NUMBER, false, &pItem))
417  pSaveNum = const_cast<SwUINumRuleItem*>(static_cast<const SwUINumRuleItem*>(pItem))->GetNumRule();
418 
420  sal_uInt16 nMask = 1;
421  m_xLevelLB->unselect_all();
422  if(nActNumLvl == USHRT_MAX)
423  {
424  m_xLevelLB->select(MAXLEVEL);
425  }
426  else
427  {
428  for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
429  {
430  if (nActNumLvl & nMask)
431  m_xLevelLB->select(i);
432  nMask <<= 1;
433  }
434  }
435 
436  if(!pActNum)
437  pActNum.reset(new SwNumRule(*pSaveNum));
438  else if(*pSaveNum != *pActNum)
439  *pActNum = *pSaveNum;
443  InitControls();
444  bModified = false;
445 }
446 
448 {
449  if ( pActNum == nullptr )
450  {
451  OSL_FAIL( "<SwNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
452  return;
453  }
454 
457  sal_uInt16 nMask = 1;
458  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
459  {
460  if(nActNumLvl & nMask)
461  {
462  SvxNumberFormat aNumFormat( pActNum->Get(i) );
463  ePosAndSpaceMode = aNumFormat.GetPositionAndSpaceMode();
464  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
465  {
466  break;
467  }
468  }
469  nMask <<= 1;
470  }
471 
473  ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
474 }
475 
477 {
487 
498 }
499 
501  const SfxItemSet* rAttrSet)
502 {
503  return VclPtr<SwNumPositionTabPage>::Create(pParent, *rAttrSet);
504 }
505 
507 {
508  pWrtSh = pSh;
509 
511 
512  m_xDistBorderMF->set_max(m_xDistBorderMF->normalize( nWidth ), FieldUnit::TWIP );
513  m_xDistNumMF->set_max(m_xDistNumMF->normalize( nWidth ), FieldUnit::TWIP);
514  m_xIndentMF->set_max(m_xIndentMF->normalize( nWidth ), FieldUnit::TWIP );
515  m_xListtabMF->set_max(m_xListtabMF->normalize( nWidth ), FieldUnit::TWIP );
516  m_xAlignedAtMF->set_max(m_xAlignedAtMF->normalize( nWidth ), FieldUnit::TWIP );
517  m_xIndentAtMF->set_max(m_xIndentAtMF->normalize( nWidth ), FieldUnit::TWIP );
518 
519  const SwRect& rPrtRect = pWrtSh->GetAnyCurRect(CurRectType::Page);
520  m_aPreviewWIN.SetPageWidth(rPrtRect.Width());
521  FieldUnit eMetric = ::GetDfltMetric( dynamic_cast<SwWebView*>( &pWrtSh->GetView()) != nullptr );
522  if(eMetric == FieldUnit::MM)
523  {
524  m_xDistBorderMF->set_digits(1);
525  m_xDistNumMF->set_digits(1);
526  m_xIndentMF->set_digits(1);
527  m_xListtabMF->set_digits(1);
528  m_xAlignedAtMF->set_digits(1);
529  m_xIndentAtMF->set_digits(1);
530  }
531  m_xDistBorderMF->set_unit( eMetric );
532  m_xDistNumMF->set_unit( eMetric );
533  m_xIndentMF->set_unit( eMetric );
534  m_xListtabMF->set_unit( eMetric );
535  m_xAlignedAtMF->set_unit( eMetric );
536  m_xIndentAtMF->set_unit( eMetric );
537 }
538 
540 {
541  sal_uInt16 nMask = 1;
542  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
543  {
544  if(nActNumLvl & nMask)
545  {
546  SwNumFormat aNumFormat(pActNum->Get(i));
547 
548  const int nPos = m_xAlignLB->get_visible()
549  ? m_xAlignLB->get_active()
550  : m_xAlign2LB->get_active();
551  SvxAdjust eAdjust = SvxAdjust::Center;
552  if(nPos == 0)
553  eAdjust = SvxAdjust::Left;
554  else if(nPos == 2)
555  eAdjust = SvxAdjust::Right;
556  aNumFormat.SetNumAdjust( eAdjust );
557  pActNum->Set(i, aNumFormat);
558  }
559  nMask <<= 1;
560  }
561  SetModified();
562 }
563 
565 {
566  sal_uInt16 nSaveNumLvl = nActNumLvl;
567  nActNumLvl = 0;
568  auto aRows = rBox.get_selected_rows();
569  if ((std::find(aRows.begin(), aRows.end(), MAXLEVEL) != aRows.end()) &&
570  (aRows.size() == 1 || nSaveNumLvl != 0xffff))
571  {
572  nActNumLvl = 0xFFFF;
573  for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
574  rBox.unselect(i);
575  }
576  else if (!aRows.empty())
577  {
578  sal_uInt16 nMask = 1;
579  for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
580  {
581  if (std::find(aRows.begin(), aRows.end(), i) != aRows.end())
582  nActNumLvl |= nMask;
583  nMask <<= 1;
584  }
585  rBox.unselect(MAXLEVEL);
586  }
587  else
588  {
589  nActNumLvl = nSaveNumLvl;
590  sal_uInt16 nMask = 1;
591  for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
592  {
593  if(nActNumLvl & nMask)
594  {
595  rBox.select(i);
596  break;
597  }
598  nMask <<=1;
599  }
600  }
601  m_xRelativeCB->set_sensitive(1 != nActNumLvl);
602  SetModified();
603  InitPosAndSpaceMode();
604  ShowControlsDependingOnPosAndSpaceMode();
605  InitControls();
606 }
607 
609 {
610  if(bInInintControl)
611  return;
612  long nValue = static_cast< long >(rField.denormalize(rField.get_value(FieldUnit::TWIP)));
613  sal_uInt16 nMask = 1;
614  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
615  {
616  if(nActNumLvl & nMask)
617  {
618  SwNumFormat aNumFormat( pActNum->Get( i ) );
619  if (&rField == m_xDistBorderMF.get())
620  {
621 
622  if (m_xRelativeCB->get_active() && m_xRelativeCB->get_sensitive())
623  {
624  if(0 == i)
625  {
626  auto const nTmp = aNumFormat.GetFirstLineOffset();
627  aNumFormat.SetAbsLSpace( nValue - nTmp );
628  }
629  else
630  {
631  long nTmp = pActNum->Get( i - 1 ).GetAbsLSpace() +
632  pActNum->Get( i - 1 ).GetFirstLineOffset() -
633  pActNum->Get( i ).GetFirstLineOffset();
634 
635  aNumFormat.SetAbsLSpace( nValue + nTmp );
636  }
637  }
638  else
639  {
640  aNumFormat.SetAbsLSpace( nValue - aNumFormat.GetFirstLineOffset());
641  }
642  }
643  else if (&rField == m_xDistNumMF.get())
644  {
645  aNumFormat.SetCharTextDistance( nValue );
646  }
647  else if (&rField == m_xIndentMF.get())
648  {
649  // now AbsLSpace also has to be modified by FirstLineOffset
650  long nDiff = nValue + aNumFormat.GetFirstLineOffset();
651  auto const nAbsLSpace = aNumFormat.GetAbsLSpace();
652  aNumFormat.SetAbsLSpace( nAbsLSpace + nDiff );
653  aNumFormat.SetFirstLineOffset( -nValue );
654  }
655 
656  pActNum->Set( i, aNumFormat );
657  }
658  nMask <<= 1;
659  }
660 
661  SetModified();
662  if(!m_xDistBorderMF->get_sensitive())
663  m_xDistBorderMF->set_text(OUString());
664 }
665 
666 IMPL_LINK( SwNumPositionTabPage, RelativeHdl, weld::ToggleButton&, rBox, void )
667 {
668  bool bOn = rBox.get_active();
669  bool bSingleSelection = m_xLevelLB->n_children() == 1 && USHRT_MAX != nActNumLvl;
670  bool bSetValue = false;
671  long nValue = 0;
672  if(bOn || bSingleSelection)
673  {
674  sal_uInt16 nMask = 1;
675  bool bFirst = true;
676  bSetValue = true;
677  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
678  {
679  if(nActNumLvl & nMask)
680  {
681  const SwNumFormat &rNumFormat = pActNum->Get(i);
682  if(bFirst)
683  {
684  nValue = rNumFormat.GetAbsLSpace();
685  if(bOn && i)
686  nValue -= pActNum->Get(i - 1).GetAbsLSpace();
687  }
688  else
689  bSetValue = nValue == rNumFormat.GetAbsLSpace() - pActNum->Get(i - 1).GetAbsLSpace();
690  bFirst = false;
691  }
692  nMask <<= 1;
693  }
694 
695  }
696  if(bSetValue)
697  m_xDistBorderMF->set_value(m_xDistBorderMF->normalize(nValue), FieldUnit::TWIP);
698  else
699  m_xDistBorderMF->set_text(OUString());
700  m_xDistBorderMF->set_sensitive(bOn || bSingleSelection || pOutlineDlg);
701  bLastRelative = bOn;
702 }
703 
704 IMPL_LINK_NOARG(SwNumPositionTabPage, LabelFollowedByHdl_Impl, weld::ComboBox&, void)
705 {
706  // determine value to be set at the chosen list levels
708  {
709  const int nPos = m_xLabelFollowedByLB->get_active();
710  if ( nPos == 1 )
711  {
712  eLabelFollowedBy = SvxNumberFormat::SPACE;
713  }
714  else if ( nPos == 2 )
715  {
716  eLabelFollowedBy = SvxNumberFormat::NOTHING;
717  }
718  else if ( nPos == 3 )
719  {
720  eLabelFollowedBy = SvxNumberFormat::NEWLINE;
721  }
722  }
723 
724  // set value at the chosen list levels
725  bool bSameListtabPos = true;
726  sal_uInt16 nFirstLvl = USHRT_MAX;
727  sal_uInt16 nMask = 1;
728  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
729  {
730  if ( nActNumLvl & nMask )
731  {
732  SwNumFormat aNumFormat( pActNum->Get(i) );
733  aNumFormat.SetLabelFollowedBy( eLabelFollowedBy );
734  pActNum->Set( i, aNumFormat );
735 
736  if ( nFirstLvl == USHRT_MAX )
737  {
738  nFirstLvl = i;
739  }
740  else
741  {
742  bSameListtabPos &= aNumFormat.GetListtabPos() ==
743  pActNum->Get( nFirstLvl ).GetListtabPos();
744  }
745  }
746  nMask <<= 1;
747  }
748 
749  // enable/disable metric field for list tab stop position depending on
750  // selected item following the list label.
751  m_xListtabFT->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
752  m_xListtabMF->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
753  if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
754  {
755  m_xListtabMF->set_value(
756  m_xListtabMF->normalize( pActNum->Get( nFirstLvl ).GetListtabPos() ),
757  FieldUnit::TWIP );
758  }
759  else
760  {
761  m_xListtabMF->set_text(OUString());
762  }
763 
764  SetModified();
765 }
766 
767 IMPL_LINK( SwNumPositionTabPage, ListtabPosHdl_Impl, weld::MetricSpinButton&, rField, void )
768 {
769  // determine value to be set at the chosen list levels
770  const long nValue = static_cast< long >(rField.denormalize(rField.get_value(FieldUnit::TWIP)));
771 
772  // set value at the chosen list levels
773  sal_uInt16 nMask = 1;
774  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
775  {
776  if ( nActNumLvl & nMask )
777  {
778  SwNumFormat aNumFormat( pActNum->Get(i) );
779  aNumFormat.SetListtabPos( nValue );
780  pActNum->Set( i, aNumFormat );
781  }
782  nMask <<= 1;
783  }
784 
785  SetModified();
786 }
787 
788 IMPL_LINK( SwNumPositionTabPage, AlignAtHdl_Impl, weld::MetricSpinButton&, rField, void )
789 {
790  // determine value to be set at the chosen list levels
791  const long nValue = static_cast< long >(rField.denormalize(rField.get_value(FieldUnit::TWIP)));
792 
793  // set value at the chosen list levels
794  sal_uInt16 nMask = 1;
795  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
796  {
797  if ( nActNumLvl & nMask )
798  {
799  SwNumFormat aNumFormat( pActNum->Get(i) );
800  const long nFirstLineIndent = nValue - aNumFormat.GetIndentAt();
801  aNumFormat.SetFirstLineIndent( nFirstLineIndent );
802  pActNum->Set( i, aNumFormat );
803  }
804  nMask <<= 1;
805  }
806 
807  SetModified();
808 }
809 
810 IMPL_LINK( SwNumPositionTabPage, IndentAtHdl_Impl, weld::MetricSpinButton&, rField, void )
811 {
812  // determine value to be set at the chosen list levels
813  const long nValue = static_cast< long >(rField.denormalize(rField.get_value(FieldUnit::TWIP)));
814 
815  // set value at the chosen list levels
816  sal_uInt16 nMask = 1;
817  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
818  {
819  if ( nActNumLvl & nMask )
820  {
821  SwNumFormat aNumFormat( pActNum->Get(i) );
822  const long nAlignedAt = aNumFormat.GetIndentAt() +
823  aNumFormat.GetFirstLineIndent();
824  aNumFormat.SetIndentAt( nValue );
825  const long nNewFirstLineIndent = nAlignedAt - nValue;
826  aNumFormat.SetFirstLineIndent( nNewFirstLineIndent );
827  pActNum->Set( i, aNumFormat );
828  }
829  nMask <<= 1;
830  }
831 
832  SetModified();
833 }
834 
836 {
837  sal_uInt16 nMask = 1;
838  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
839  {
840  if(nActNumLvl & nMask)
841  {
842  SwNumFormat aNumFormat( pActNum->Get( i ) );
843  SwNumRule aTmpNumRule( pWrtSh->GetUniqueNumRuleName(),
844  aNumFormat.GetPositionAndSpaceMode(),
845  pOutlineDlg ? OUTLINE_RULE : NUM_RULE );
846  const SwNumFormat& aTempFormat(aTmpNumRule.Get( i ));
847  aNumFormat.SetPositionAndSpaceMode( aTempFormat.GetPositionAndSpaceMode() );
848  if ( aTempFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
849  {
850  aNumFormat.SetAbsLSpace( aTempFormat.GetAbsLSpace());
851  aNumFormat.SetCharTextDistance( aTempFormat.GetCharTextDistance() );
852  aNumFormat.SetFirstLineOffset( aTempFormat.GetFirstLineOffset() );
853  }
854  else if ( aTempFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
855  {
856  aNumFormat.SetNumAdjust( aTempFormat.GetNumAdjust() );
857  aNumFormat.SetLabelFollowedBy( aTempFormat.GetLabelFollowedBy() );
858  aNumFormat.SetListtabPos( aTempFormat.GetListtabPos() );
859  aNumFormat.SetFirstLineIndent( aTempFormat.GetFirstLineIndent() );
860  aNumFormat.SetIndentAt( aTempFormat.GetIndentAt() );
861  }
862  pActNum->Set( i, aNumFormat );
863  }
864  nMask <<= 1;
865  }
866 
867  InitControls();
868  SetModified();
869 }
870 
871 #ifdef DBG_UTIL
873 {
874  bModified = true;
877 }
878 #endif
879 
881  const SfxItemSet* pSwItemSet, SwWrtShell & rSh)
882  : SfxTabDialogController(pParent, "modules/swriter/ui/bulletsandnumbering.ui", "BulletsAndNumberingDialog",
883  pSwItemSet)
884  , rWrtSh(rSh)
885  , m_xDummyCombo(m_xBuilder->weld_combo_box("dummycombo"))
886 {
887  weld::Button* pButton = GetUserButton();
888  pButton->connect_clicked(LINK(this, SwSvxNumBulletTabDialog, RemoveNumberingHdl));
889  pButton->set_sensitive(rWrtSh.GetNumRuleAtCurrCursorPos() != nullptr);
890  AddTabPage("singlenum", RID_SVXPAGE_PICK_SINGLE_NUM );
891  AddTabPage("bullets", RID_SVXPAGE_PICK_BULLET );
892  AddTabPage("outlinenum", RID_SVXPAGE_PICK_NUM );
893  AddTabPage("graphics", RID_SVXPAGE_PICK_BMP );
894  AddTabPage("customize", RID_SVXPAGE_NUM_OPTIONS );
895  AddTabPage("position", RID_SVXPAGE_NUM_POSITION );
896 }
897 
899 {
900 }
901 
902 void SwSvxNumBulletTabDialog::PageCreated(const OString& rPageId, SfxTabPage& rPage)
903 {
904  // set styles' names and metric
905  OUString sNumCharFormat, sBulletCharFormat;
908 
909  if (rPageId == "singlenum")
910  {
911  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
912  aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFormat));
913  aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat));
914  rPage.PageCreated(aSet);
915  }
916  else if (rPageId == "bullets")
917  {
918  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
919  aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat));
920  rPage.PageCreated(aSet);
921  }
922  else if (rPageId == "customize")
923  {
924  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
925  aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFormat));
926  aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat));
927  // collect char styles
928  m_xDummyCombo->clear();
929  m_xDummyCombo->append_text(SwViewShell::GetShellRes()->aStrNone);
930  SwDocShell* pDocShell = rWrtSh.GetView().GetDocShell();
932 
933  std::vector<OUString> aList;
934  aList.reserve(m_xDummyCombo->get_count());
935  for (sal_Int32 j = 0; j < m_xDummyCombo->get_count(); j++)
936  aList.push_back(m_xDummyCombo->get_text(j));
937 
938  aSet.Put( SfxStringListItem( SID_CHAR_FMT_LIST_BOX,&aList ) ) ;
939 
940  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast< const SwWebDocShell *>( pDocShell ) != nullptr);
941  aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< sal_uInt16 >(eMetric) ) );
942  rPage.PageCreated(aSet);
943  }
944  else if (rPageId == "position")
945  {
946  SwDocShell* pDocShell = rWrtSh.GetView().GetDocShell();
947  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast< const SwWebDocShell *>( pDocShell ) != nullptr);
948  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
949  aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< sal_uInt16 >(eMetric)) );
950  rPage.PageCreated(aSet);
951  }
952 }
953 
955 {
956  short nRet = SfxTabDialogController::Ok();
957  m_xExampleSet->ClearItem(SID_PARAM_NUM_PRESET);
958  return nRet;
959 }
960 
962 {
963  m_xDialog->response(RET_USER);
964 }
965 
966 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: num.cxx:347
void SetWrtShell(SwWrtShell *pSh)
Definition: num.cxx:506
SwNumPositionTabPage(TabPageParent pParent, const SfxItemSet &rSet)
Definition: num.cxx:58
virtual short Ok() override
Definition: num.cxx:954
FieldUnit
void SetLabelFollowedBy(const LabelFollowedBy eLabelFollowedBy)
IMPL_LINK(SwNumPositionTabPage, LevelHdl, weld::TreeView &, rBox, void)
Definition: num.cxx:564
SwWrtShell * pWrtSh
Definition: num.hxx:34
long GetFirstLineIndent() const
NumberingPreview m_aPreviewWIN
Definition: num.hxx:44
virtual void PageCreated(const SfxAllItemSet &aSet)
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2489
std::unique_ptr< weld::TreeView > m_xLevelLB
Definition: num.hxx:46
std::unique_ptr< weld::MetricSpinButton > m_xDistBorderMF
Definition: num.hxx:52
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rAttrSet)
Definition: num.cxx:500
std::unique_ptr< weld::Label > m_xDistBorderFT
Definition: num.hxx:51
std::string GetValue
SW_DLLPUBLIC void FillCharStyleListBox(weld::ComboBox &rToFill, SwDocShell *pDocSh, bool bSorted=false, bool bWithDefault=false)
Definition: uitool.cxx:735
void SetModified()
Definition: num.cxx:872
const SwNumRule * GetNumRuleAtCurrCursorPos() const
Definition: ednumber.cxx:727
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
void SetPositionAndSpaceMode(SvxNumPositionAndSpaceMode ePositionAndSpaceMode)
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:92
void SetLevel(sal_uInt16 nSet)
Definition: numprevw.hxx:62
std::unique_ptr< SfxItemSet > m_xExampleSet
void InitPosAndSpaceMode()
Definition: num.cxx:447
long SwTwips
Definition: swtypes.hxx:49
SwNumRule * pSaveNum
Definition: num.hxx:33
std::unique_ptr< weld::MetricSpinButton > m_xListtabMF
Definition: num.hxx:66
SfxItemSet * GetInputSetImpl()
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual void PageCreated(const OString &rPageId, SfxTabPage &rPage) override
Definition: num.cxx:902
std::unique_ptr< weld::Label > m_xIndentFT
Definition: num.hxx:54
sal_uInt16 nActNumLvl
Definition: num.hxx:37
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
std::unique_ptr< weld::ComboBox > m_xAlignLB
Definition: num.hxx:59
virtual short Ok()
const SwView & GetView() const
Definition: wrtsh.hxx:426
virtual void Reset(const SfxItemSet *rSet) override
Definition: num.cxx:408
std::unique_ptr< weld::Label > m_xIndentAtFT
Definition: num.hxx:71
void SetExchangeSupport()
SwOutlineTabDialog * pOutlineDlg
Definition: num.hxx:36
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
short GetCharTextDistance() const
#define FN_PARAM_NUM_PRESET
Definition: cmdid.h:776
IMPL_LINK_NOARG(SwNumPositionTabPage, EditModifyHdl, weld::ComboBox &, void)
Definition: num.cxx:539
Numbering symbols.
Definition: poolfmt.hxx:118
virtual void dispose() override
std::unique_ptr< weld::Label > m_xLabelFollowedByFT
Definition: num.hxx:63
std::unique_ptr< weld::Label > m_xListtabFT
Definition: num.hxx:65
void connect_clicked(const Link< Button &, void > &rLink)
void SetListtabPos(const long nListtabPos)
std::unique_ptr< weld::Label > m_xAlign2FT
Definition: num.hxx:67
SwSvxNumBulletTabDialog(weld::Window *pParent, const SfxItemSet *pSwItemSet, SwWrtShell &)
Definition: num.cxx:880
std::unique_ptr< SwNumRule > pActNum
Definition: num.hxx:32
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
virtual ~SwNumPositionTabPage() override
Definition: num.cxx:137
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:710
SvxAdjust
SwNumRule * GetNumRule()
Definition: outline.hxx:58
LabelFollowedBy GetLabelFollowedBy() const
sal_Int32 GetAbsLSpace() const
std::unique_ptr< weld::Button > m_xStandardPB
Definition: num.hxx:73
std::unique_ptr< weld::Label > m_xAlignFT
Definition: num.hxx:58
int i
std::unique_ptr< weld::Label > m_xDistNumFT
Definition: num.hxx:56
void SetNumRule(const SwNumRule *pNum)
Definition: numprevw.hxx:50
void SetPositionMode()
Definition: numprevw.hxx:60
#define FN_PARAM_ACT_NUMBER
Definition: cmdid.h:774
std::unique_ptr< weld::MetricSpinButton > m_xDistNumMF
Definition: num.hxx:57
static void SetActNumLevel(sal_uInt16 nSet)
Definition: outline.hxx:63
void SetPageWidth(long nPgWidth)
Definition: numprevw.hxx:56
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: num.cxx:395
SvxAdjust GetNumAdjust() const
bool bLabelAlignmentPosAndSpaceModeActive
Definition: num.hxx:42
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
const SfxItemSet * GetDialogExampleSet() const
SwDocShell * GetDocShell()
Definition: view.cxx:1127
SwWrtShell & rWrtSh
Definition: num.hxx:126
Rect of current page.
long GetIndentAt() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::MetricSpinButton > m_xIndentMF
Definition: num.hxx:55
#define RET_USER
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: num.cxx:386
void Width(long nNew)
Definition: swrect.hxx:185
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
static VclPtr< reference_type > Create(Arg &&...arg)
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void InitControls()
Definition: num.cxx:149
long GetListtabPos() const
std::unique_ptr< weld::CheckButton > m_xRelativeCB
Definition: num.hxx:53
sal_Int32 GetFirstLineOffset() const
std::unique_ptr< weld::ComboBox > m_xDummyCombo
Definition: num.hxx:132
DeactivateRC
std::unique_ptr< weld::MetricSpinButton > m_xAlignedAtMF
Definition: num.hxx:70
std::unique_ptr< weld::MetricSpinButton > m_xIndentAtMF
Definition: num.hxx:72
virtual ~SwSvxNumBulletTabDialog() override
Definition: num.cxx:898
std::unique_ptr< weld::ComboBox > m_xLabelFollowedByLB
Definition: num.hxx:64
static bool bLastRelative
Definition: num.cxx:52
weld::Button * GetUserButton() const
std::unique_ptr< weld::ComboBox > m_xAlign2LB
Definition: num.hxx:68
sal_Int32 nPos
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:75
std::unique_ptr< weld::Label > m_xAlignedAtFT
Definition: num.hxx:69
virtual void dispose() override
Definition: num.cxx:142
virtual void set_sensitive(bool sensitive)=0
bool bInInintControl
Definition: num.hxx:41
Rect of current frame.
void ShowControlsDependingOnPosAndSpaceMode()
Definition: num.cxx:476
static sal_uInt16 GetActNumLevel()
Definition: outline.hxx:62