LibreOffice Module sw (master)  1
tabledlg.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 <vcl/svapp.hxx>
22 #include <vcl/weld.hxx>
23 #include <svl/stritem.hxx>
24 #include <svl/intitem.hxx>
25 #include <editeng/keepitem.hxx>
27 #include <editeng/ulspitem.hxx>
28 #include <editeng/frmdiritem.hxx>
29 #include <svl/ctloptions.hxx>
30 #include <swmodule.hxx>
31 #include <fmtpdsc.hxx>
32 #include <fmtlsplt.hxx>
33 
34 #include <svtools/htmlcfg.hxx>
35 #include <fmtrowsplt.hxx>
36 #include <sfx2/htmlmode.hxx>
37 #include <sfx2/sfxdlg.hxx>
38 
39 #include <strings.hrc>
40 #include <svx/strings.hrc>
41 #include <svx/dialmgr.hxx>
42 
43 #include <wrtsh.hxx>
44 #include <view.hxx>
45 #include <viewopt.hxx>
46 #include <uitool.hxx>
47 #include <tabledlg.hxx>
48 #include "../../uibase/table/tablepg.hxx"
49 #include <tablemgr.hxx>
50 #include <pagedesc.hxx>
51 #include <uiitems.hxx>
52 #include <poolfmt.hxx>
53 #include <swtablerep.hxx>
54 #include <SwStyleNameMapper.hxx>
55 
56 #include <cmdid.h>
57 #include <svx/dialogs.hrc>
58 #include <svx/flagsdef.hxx>
59 #include <osl/diagnose.h>
60 
61 #include <com/sun/star/text/HoriOrientation.hpp>
62 #include <com/sun/star/text/VertOrientation.hpp>
63 
64 using namespace ::com::sun::star;
65 
67  : SfxTabPage(pPage, pController, "modules/swriter/ui/formattablepage.ui", "FormatTablePage", &rSet)
68  , pTableData(nullptr)
69  , nSaveWidth(0)
70  , nMinTableWidth(MINLAY)
71  , bModified(false)
72  , bFull(false)
73  , bHtmlMode(false)
74  , m_xNameED(m_xBuilder->weld_entry("name"))
75  , m_xWidthFT(m_xBuilder->weld_label("widthft"))
76  , m_xWidthMF(new SwPercentField(m_xBuilder->weld_metric_spin_button("widthmf", FieldUnit::CM)))
77  , m_xRelWidthCB(m_xBuilder->weld_check_button("relwidth"))
78  , m_xFullBtn(m_xBuilder->weld_radio_button("full"))
79  , m_xLeftBtn(m_xBuilder->weld_radio_button("left"))
80  , m_xFromLeftBtn(m_xBuilder->weld_radio_button("fromleft"))
81  , m_xRightBtn(m_xBuilder->weld_radio_button("right"))
82  , m_xCenterBtn(m_xBuilder->weld_radio_button("center"))
83  , m_xFreeBtn(m_xBuilder->weld_radio_button("free"))
84  , m_xLeftFT(m_xBuilder->weld_label("leftft"))
85  , m_xLeftMF(new SwPercentField(m_xBuilder->weld_metric_spin_button("leftmf", FieldUnit::CM)))
86  , m_xRightFT(m_xBuilder->weld_label("rightft"))
87  , m_xRightMF(new SwPercentField(m_xBuilder->weld_metric_spin_button("rightmf", FieldUnit::CM)))
88  , m_xTopFT(m_xBuilder->weld_label("aboveft"))
89  , m_xTopMF(m_xBuilder->weld_metric_spin_button("abovemf", FieldUnit::CM))
90  , m_xBottomFT(m_xBuilder->weld_label("belowft"))
91  , m_xBottomMF(m_xBuilder->weld_metric_spin_button("belowmf", FieldUnit::CM))
92  , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("textdirection")))
93  , m_xProperties(m_xBuilder->weld_widget("properties"))
94 {
95  m_xWidthMF->GetMetricFieldRange(m_nOrigWidthMin, m_nOrigWidthMax);
96  m_xLeftMF->GetMetricFieldRange(m_nOrigLeftMin, m_nOrigLeftMax);
97  m_xRightMF->GetMetricFieldRange(m_nOrigRightMin, m_nOrigRightMax);
98 
99  //lock these to initial sizes so they don't change on percent to non percent change
100  Size aPrefSize(m_xLeftMF->get()->get_preferred_size());
101  m_xLeftMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
102  m_xRightMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
103  m_xWidthMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
104 
105  m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
106  m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
107  m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
108 
110 
111  const SfxPoolItem* pItem;
112  if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem))
113  bHtmlMode = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
114 
115  bool bCTL = SW_MOD()->GetCTLOptions().IsCTLFontEnabled();
116  m_xProperties->set_visible(!bHtmlMode && bCTL);
117 
118  Init();
119 }
120 
122 {
123 }
124 
126 {
127  m_xLeftMF->SetMetricFieldMin(-999999);
128  m_xRightMF->SetMetricFieldMin(-999999);
129 
130  //handler
131  Link<weld::ToggleButton&,void> aLk2 = LINK( this, SwFormatTablePage, AutoClickHdl );
132  m_xFullBtn->connect_toggled( aLk2 );
133  m_xFreeBtn->connect_toggled( aLk2 );
134  m_xLeftBtn->connect_toggled( aLk2 );
135  m_xFromLeftBtn->connect_toggled( aLk2 );
136  m_xRightBtn->connect_toggled( aLk2 );
137  m_xCenterBtn->connect_toggled( aLk2 );
138 
139  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwFormatTablePage, ValueChangedHdl);
140  m_xTopMF->connect_value_changed(aLk);
141  m_xBottomMF->connect_value_changed(aLk);
142  m_xRightMF->connect_value_changed(aLk);
143  m_xLeftMF->connect_value_changed(aLk);
144  m_xWidthMF->connect_value_changed(aLk);
145 
146  m_xRelWidthCB->connect_toggled(LINK( this, SwFormatTablePage, RelWidthClickHdl ));
147 }
148 
149 IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, weld::ToggleButton&, rBtn, void )
150 {
151  OSL_ENSURE(pTableData, "table data not available?");
152  bool bIsChecked = rBtn.get_active();
153  sal_Int64 nLeft = m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FieldUnit::TWIP));
154  sal_Int64 nRight = m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FieldUnit::TWIP));
155  m_xWidthMF->ShowPercent(bIsChecked);
156  m_xLeftMF->ShowPercent(bIsChecked);
157  m_xRightMF->ShowPercent(bIsChecked);
158 
159  if (bIsChecked)
160  {
161  m_xWidthMF->SetRefValue(pTableData->GetSpace());
162  m_xLeftMF->SetRefValue(pTableData->GetSpace());
163  m_xRightMF->SetRefValue(pTableData->GetSpace());
164  m_xLeftMF->SetMetricFieldMin(0); //will be overwritten by the Percentfield
165  m_xRightMF->SetMetricFieldMin(0); //ditto
166  m_xLeftMF->SetMetricFieldMax(99);
167  m_xRightMF->SetMetricFieldMax(99);
168  m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(nLeft ), FieldUnit::TWIP );
169  m_xRightMF->set_value(m_xRightMF->NormalizePercent(nRight ), FieldUnit::TWIP );
170  }
171  else
172  ModifyHdl(*m_xLeftMF->get()); //correct values again
173 
174  if (m_xFreeBtn->get_active())
175  {
176  bool bEnable = !rBtn.get_active();
177  m_xRightMF->set_sensitive(bEnable);
178  m_xRightFT->set_sensitive(bEnable);
179  }
180  bModified = true;
181 }
182 
184 {
185  bool bRestore = true,
186  bLeftEnable = false,
187  bRightEnable= false,
188  bWidthEnable= false,
189  bOthers = true;
190  if (m_xFullBtn->get_active())
191  {
192  m_xLeftMF->set_value(0);
193  m_xRightMF->set_value(0);
194  nSaveWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
195  m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(pTableData->GetSpace()), FieldUnit::TWIP);
196  bFull = true;
197  bRestore = false;
198  }
199  else if (m_xLeftBtn->get_active())
200  {
201  bRightEnable = bWidthEnable = true;
202  m_xLeftMF->set_value(0);
203  }
204  else if (m_xFromLeftBtn->get_active())
205  {
206  bLeftEnable = bWidthEnable = true;
207  m_xRightMF->set_value(0);
208  }
209  else if (m_xRightBtn->get_active())
210  {
211  bLeftEnable = bWidthEnable = true;
212  m_xRightMF->set_value(0);
213  }
214  else if (m_xCenterBtn->get_active())
215  {
216  bLeftEnable = bWidthEnable = true;
217  }
218  else if (m_xFreeBtn->get_active())
219  {
220  RightModify();
221  bLeftEnable = true;
222  bWidthEnable = true;
223  bOthers = false;
224  }
225  m_xLeftMF->set_sensitive(bLeftEnable);
226  m_xLeftFT->set_sensitive(bLeftEnable);
227  m_xWidthMF->set_sensitive(bWidthEnable);
228  m_xWidthFT->set_sensitive(bWidthEnable);
229  if ( bOthers )
230  {
231  m_xRightMF->set_sensitive(bRightEnable);
232  m_xRightFT->set_sensitive(bRightEnable);
233  m_xRelWidthCB->set_sensitive(bWidthEnable);
234  }
235 
236  if(bFull && bRestore)
237  {
238  //After being switched on automatic, the width was pinned
239  //in order to restore the width while switching back to.
240  bFull = false;
241  m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(nSaveWidth ), FieldUnit::TWIP );
242  }
243  ModifyHdl(*m_xWidthMF->get());
244  bModified = true;
245 }
246 
248 {
249  if (!m_xFreeBtn->get_active())
250  return;
251 
252  bool bEnable = m_xRightMF->get_value() == 0;
253  m_xRelWidthCB->set_sensitive(bEnable);
254  if ( !bEnable )
255  {
256  m_xRelWidthCB->set_active(false);
257  RelWidthClickHdl(*m_xRelWidthCB);
258  }
259  bEnable = m_xRelWidthCB->get_active();
260  m_xRightMF->set_sensitive(!bEnable);
261  m_xRightFT->set_sensitive(!bEnable);
262 }
263 
264 IMPL_LINK( SwFormatTablePage, ValueChangedHdl, weld::MetricSpinButton&, rEdit, void )
265 {
266  if (m_xRightMF->get() == &rEdit)
267  RightModify();
268  ModifyHdl(rEdit);
269 }
270 
271 void SwFormatTablePage::ModifyHdl(const weld::MetricSpinButton& rEdit, bool bAllowInconsistencies)
272 {
273  SwTwips nCurWidth = static_cast< SwTwips >(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
274  SwTwips nPrevWidth = nCurWidth;
275  SwTwips nRight = static_cast< SwTwips >(m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FieldUnit::TWIP)));
276  SwTwips nLeft = static_cast< SwTwips >(m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FieldUnit::TWIP)));
277  SwTwips nDiff;
278 
279  if (&rEdit == m_xWidthMF->get())
280  {
281  if( nCurWidth < MINLAY )
282  nCurWidth = MINLAY;
283  nDiff = nRight + nLeft + nCurWidth - pTableData->GetSpace() ;
284  //right aligned: only change the left margin
285  if (m_xRightBtn->get_active())
286  nLeft -= nDiff;
287  //left aligned: only change the right margin
288  else if(m_xLeftBtn->get_active())
289  nRight -= nDiff;
290  //left margin and width allowed - first right - then left
291  else if (m_xFromLeftBtn->get_active())
292  {
293  if( nRight >= nDiff )
294  nRight -= nDiff;
295  else
296  {
297  nDiff -= nRight;
298  nRight = 0;
299  if(nLeft >= nDiff)
300  nLeft -= nDiff;
301  else
302  {
303  nRight += nLeft - nDiff;
304  nLeft = 0;
305  nCurWidth = pTableData->GetSpace();
306  }
307  }
308  }
309  //centered: change both sides equally
310  else if (m_xCenterBtn->get_active())
311  {
312  if(nLeft != nRight)
313  {
314  nDiff += nLeft + nRight;
315  nLeft = nDiff/2;
316  nRight = nDiff/2;
317  }
318  else
319  {
320  nLeft -= nDiff/2;
321  nRight -= nDiff/2;
322  }
323  }
324  //free alignment: decrease both margins
325  else if (m_xFreeBtn->get_active())
326  {
327  nLeft -= nDiff/2;
328  nRight -= nDiff/2;
329  }
330  }
331  if (&rEdit == m_xRightMF->get())
332  {
333 
334  if( nRight + nLeft > pTableData->GetSpace() - MINLAY )
335  nRight = pTableData->GetSpace() -nLeft - MINLAY;
336 
337  nCurWidth = pTableData->GetSpace() - nLeft - nRight;
338  }
339  if (&rEdit == m_xLeftMF->get())
340  {
341  if(!m_xFromLeftBtn->get_active())
342  {
343  bool bCenter = m_xCenterBtn->get_active();
344  if( bCenter )
345  nRight = nLeft;
346  if(nRight + nLeft > pTableData->GetSpace() - MINLAY )
347  {
348  nLeft = bCenter ? (pTableData->GetSpace() - MINLAY) /2 :
349  (pTableData->GetSpace() - MINLAY) - nRight;
350  nRight = bCenter ? (pTableData->GetSpace() - MINLAY) /2 : nRight;
351  }
352  nCurWidth = pTableData->GetSpace() - nLeft - nRight;
353  }
354  else
355  {
356  //Upon changes on the left side the right margin will be changed at first,
357  //thereafter the width.
358  nDiff = nRight + nLeft + nCurWidth - pTableData->GetSpace() ;
359 
360  nRight -= nDiff;
361  nCurWidth = pTableData->GetSpace() - nLeft - nRight;
362  }
363  }
364 
365  m_xRightMF->set_value( m_xRightMF->NormalizePercent( nRight ), FieldUnit::TWIP );
366  m_xLeftMF->set_value( m_xLeftMF->NormalizePercent( nLeft ), FieldUnit::TWIP );
367 
368  if (nCurWidth != nPrevWidth )
369  {
370  m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(nCurWidth), FieldUnit::TWIP);
371 
372  // tdf#135021 if the user changed the width spinbutton, and in this
373  // ModifyHdl we changed the value of that width spinbutton, then rerun
374  // the ModifyHdl on the replaced value so the left/right/width value
375  // relationships are consistent.
376  // But (tdf#135693) only make one effort of rectifying the inconsistency
377  if (&rEdit == m_xWidthMF->get() && !bAllowInconsistencies)
378  ModifyHdl(rEdit, true);
379  }
380 
381  bModified = true;
382 }
383 
384 std::unique_ptr<SfxTabPage> SwFormatTablePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
385 {
386  return std::make_unique<SwFormatTablePage>(pPage, pController, *rAttrSet);
387 }
388 
390 {
391  //Test if one of the controls still has the focus
392  if (m_xWidthMF->has_focus())
393  ModifyHdl(*m_xWidthMF->get());
394  else if (m_xLeftMF->has_focus())
395  ModifyHdl(*m_xLeftMF->get());
396  else if (m_xRightMF->has_focus())
397  ModifyHdl(*m_xRightMF->get());
398  else if (m_xTopMF->has_focus())
400  else if (m_xBottomMF->has_focus())
402 
403  if (bModified)
404  {
405  if (m_xBottomMF->get_value_changed_from_saved() ||
406  m_xTopMF->get_value_changed_from_saved() )
407  {
408  SvxULSpaceItem aULSpace(RES_UL_SPACE);
409  aULSpace.SetUpper(m_xTopMF->denormalize(m_xTopMF->get_value(FieldUnit::TWIP)));
410  aULSpace.SetLower(m_xBottomMF->denormalize(m_xBottomMF->get_value(FieldUnit::TWIP)));
411  rCoreSet->Put(aULSpace);
412  }
413 
414  }
415  if (m_xNameED->get_value_changed_from_saved())
416  {
417  rCoreSet->Put(SfxStringItem(FN_PARAM_TABLE_NAME, m_xNameED->get_text()));
418  bModified = true;
419  }
420 
421  if (m_xTextDirectionLB->get_visible())
422  {
423  if (m_xTextDirectionLB->get_value_changed_from_saved())
424  {
425  SvxFrameDirection nDirection = m_xTextDirectionLB->get_active_id();
426  rCoreSet->Put(SvxFrameDirectionItem(nDirection, RES_FRAMEDIR));
427  bModified = true;
428  }
429  }
430 
431  return bModified;
432 }
433 
435 {
436  const SfxItemSet& rSet = GetItemSet();
437  const SfxPoolItem* pItem;
438 
439  if(bHtmlMode)
440  {
441  m_xNameED->set_sensitive(false);
442  m_xTopFT->hide();
443  m_xTopMF->hide();
444  m_xBottomFT->hide();
445  m_xBottomMF->hide();
446  m_xFreeBtn->set_sensitive(false);
447  }
448 
449  // set back to original state
450  m_xRelWidthCB->set_active(false);
451  m_xWidthMF->ShowPercent(false);
452  m_xLeftMF->ShowPercent(false);
453  m_xRightMF->ShowPercent(false);
454  m_xWidthMF->SetMetricFieldRange(m_nOrigWidthMin, m_nOrigWidthMax);
455  m_xLeftMF->SetMetricFieldRange(m_nOrigLeftMin, m_nOrigLeftMax);
456  m_xRightMF->SetMetricFieldRange(m_nOrigRightMin, m_nOrigRightMax);
457 
459  m_xWidthMF->SetMetric(aMetric);
460  m_xRightMF->SetMetric(aMetric);
461  m_xLeftMF->SetMetric(aMetric);
462  SetFieldUnit(*m_xTopMF, aMetric);
463  SetFieldUnit(*m_xBottomMF, aMetric);
464 
465  //Name
466  if(SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, false, &pItem ))
467  {
468  m_xNameED->set_text(static_cast<const SfxStringItem*>(pItem)->GetValue());
469  m_xNameED->save_value();
470  }
471 
472  if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP, false, &pItem ))
473  {
474  pTableData = static_cast<SwTableRep*>(static_cast<const SwPtrItem*>( pItem)->GetValue());
475  if (!m_xOrigTableData)
477  else // tdf#134925 and tdf#134913, reset back to the original data seen on dialog creation
479 
481 
483  {
484  m_xRelWidthCB->set_active(true);
485  RelWidthClickHdl(*m_xRelWidthCB);
486  m_xWidthMF->set_value(pTableData->GetWidthPercent(), FieldUnit::PERCENT);
487 
488  m_xWidthMF->save_value();
489  nSaveWidth = static_cast< SwTwips >(m_xWidthMF->get_value(FieldUnit::PERCENT));
490  }
491  else
492  {
493  m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
494  pTableData->GetWidth()), FieldUnit::TWIP);
495  m_xWidthMF->save_value();
498  }
499 
500  m_xWidthMF->SetRefValue(pTableData->GetSpace());
501 
502  m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
503  pTableData->GetLeftSpace()), FieldUnit::TWIP);
504  m_xRightMF->set_value(m_xRightMF->NormalizePercent(
505  pTableData->GetRightSpace()), FieldUnit::TWIP);
506  m_xLeftMF->save_value();
507  m_xRightMF->save_value();
508 
509  bool bSetRight = false, bSetLeft = false;
510  switch( pTableData->GetAlign() )
511  {
513  m_xFreeBtn->set_active(true);
514  if (m_xRelWidthCB->get_active())
515  bSetRight = true;
516  break;
517  case text::HoriOrientation::FULL:
518  {
519  bSetRight = bSetLeft = true;
520  m_xFullBtn->set_active(true);
521  m_xWidthMF->set_sensitive(false);
522  m_xRelWidthCB->set_sensitive(false);
523  m_xWidthFT->set_sensitive(false);
524  }
525  break;
526  case text::HoriOrientation::LEFT:
527  {
528  bSetLeft = true;
529  m_xLeftBtn->set_active(true);
530  }
531  break;
532  case text::HoriOrientation::LEFT_AND_WIDTH :
533  {
534  bSetRight = true;
535  m_xFromLeftBtn->set_active(true);
536  }
537  break;
538  case text::HoriOrientation::RIGHT:
539  {
540  bSetRight = true;
541  m_xRightBtn->set_active(true);
542  }
543  break;
544  case text::HoriOrientation::CENTER:
545  {
546  bSetRight = true;
547  m_xCenterBtn->set_active(true);
548  }
549  break;
550  }
551  if ( bSetRight )
552  {
553  m_xRightMF->set_sensitive(false);
554  m_xRightFT->set_sensitive(false);
555  }
556  if ( bSetLeft )
557  {
558  m_xLeftMF->set_sensitive(false);
559  m_xLeftFT->set_sensitive(false);
560  }
561 
562  }
563 
564  //Margins
565  if(SfxItemState::SET == rSet.GetItemState( RES_UL_SPACE, false,&pItem ))
566  {
567  m_xTopMF->set_value(m_xTopMF->normalize(
568  static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()), FieldUnit::TWIP);
569  m_xBottomMF->set_value(m_xBottomMF->normalize(
570  static_cast<const SvxULSpaceItem*>(pItem)->GetLower()), FieldUnit::TWIP);
571  m_xTopMF->save_value();
572  m_xBottomMF->save_value();
573  }
574 
575  //Text direction
576  if( SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, true, &pItem ) )
577  {
578  SvxFrameDirection nVal = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
579  m_xTextDirectionLB->set_active_id(nVal);
580  m_xTextDirectionLB->save_value();
581  }
582 
583  m_xWidthMF->set_max( 2*m_xWidthMF->NormalizePercent( pTableData->GetSpace() ), FieldUnit::TWIP );
584  m_xRightMF->set_max( m_xRightMF->NormalizePercent( pTableData->GetSpace() ), FieldUnit::TWIP );
585  m_xLeftMF->set_max( m_xLeftMF->NormalizePercent( pTableData->GetSpace() ), FieldUnit::TWIP );
586  m_xWidthMF->set_min( m_xWidthMF->NormalizePercent( nMinTableWidth ), FieldUnit::TWIP );
587 }
588 
590 {
591  OSL_ENSURE(pTableData, "table data not available?");
592  if(SfxItemState::SET != rSet.GetItemState( FN_TABLE_REP ))
593  return;
594 
595  SwTwips nCurWidth = text::HoriOrientation::FULL != pTableData->GetAlign() ?
596  pTableData->GetWidth() :
597  pTableData->GetSpace();
598  if(pTableData->GetWidthPercent() != 0 ||
599  nCurWidth == m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)))
600  return;
601 
602  m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
603  nCurWidth), FieldUnit::TWIP);
604  m_xWidthMF->save_value();
605  nSaveWidth = nCurWidth;
606  m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
607  pTableData->GetLeftSpace()), FieldUnit::TWIP);
608  m_xLeftMF->save_value();
609  m_xRightMF->set_value(m_xRightMF->NormalizePercent(
610  pTableData->GetRightSpace()), FieldUnit::TWIP);
611  m_xRightMF->save_value();
612 }
613 
615 {
616  //test the table name for spaces
617  OUString sTableName = m_xNameED->get_text();
618  if(sTableName.indexOf(' ') != -1)
619  {
620  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
621  VclMessageType::Info, VclButtonsType::Ok,
622  SwResId(STR_WRONG_TABLENAME)));
623  xInfoBox->run();
624  m_xNameED->grab_focus();
625  return DeactivateRC::KeepPage;
626  }
627  if(_pSet)
628  {
629  FillItemSet(_pSet);
630  if(bModified)
631  {
632  SwTwips lLeft = static_cast< SwTwips >(m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FieldUnit::TWIP)));
633  SwTwips lRight = static_cast< SwTwips >(m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FieldUnit::TWIP)));
634 
635  if( m_xLeftMF->get_value_changed_from_saved() ||
636  m_xRightMF->get_value_changed_from_saved() )
637  {
639  pTableData->SetLeftSpace( lLeft);
640  pTableData->SetRightSpace( lRight);
641  }
642 
643  SwTwips lWidth;
644  if (m_xRelWidthCB->get_active() && m_xRelWidthCB->get_sensitive())
645  {
646  lWidth = pTableData->GetSpace() - lRight - lLeft;
647  const sal_uInt16 nPercentWidth = m_xWidthMF->get_value(FieldUnit::PERCENT);
648  if(pTableData->GetWidthPercent() != nPercentWidth)
649  {
650  pTableData->SetWidthPercent(nPercentWidth);
652  }
653  }
654  else
655  {
657  lWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
658  }
659  pTableData->SetWidth(lWidth);
660 
661  SwTwips nColSum = 0;
662 
663  for( sal_uInt16 i = 0; i < pTableData->GetColCount(); i++)
664  {
665  nColSum += pTableData->GetColumns()[i].nWidth;
666  }
667  if(nColSum != pTableData->GetWidth())
668  {
669  SwTwips nMinWidth = std::min( tools::Long(MINLAY),
670  static_cast<tools::Long>(pTableData->GetWidth() /
671  pTableData->GetColCount() - 1));
672  SwTwips nDiff = nColSum - pTableData->GetWidth();
673  while ( std::abs(nDiff) > pTableData->GetColCount() + 1 )
674  {
675  SwTwips nSub = nDiff / pTableData->GetColCount();
676  for( sal_uInt16 i = 0; i < pTableData->GetColCount(); i++)
677  {
678  if(pTableData->GetColumns()[i].nWidth - nMinWidth > nSub)
679  {
680  pTableData->GetColumns()[i].nWidth -= nSub;
681  nDiff -= nSub;
682  }
683  else
684  {
685  nDiff -= pTableData->GetColumns()[i].nWidth - nMinWidth;
686  pTableData->GetColumns()[i].nWidth = nMinWidth;
687  }
688 
689  }
690  }
691  }
692 
693  sal_Int16 nAlign = 0;
694  if (m_xRightBtn->get_active())
695  nAlign = text::HoriOrientation::RIGHT;
696  else if(m_xLeftBtn->get_active())
697  nAlign = text::HoriOrientation::LEFT;
698  else if(m_xFromLeftBtn->get_active())
699  nAlign = text::HoriOrientation::LEFT_AND_WIDTH;
700  else if(m_xCenterBtn->get_active())
701  nAlign = text::HoriOrientation::CENTER;
702  else if(m_xFreeBtn->get_active())
704  else if(m_xFullBtn->get_active())
705  {
706  nAlign = text::HoriOrientation::FULL;
707  lWidth = lAutoWidth;
708  }
709  if(nAlign != pTableData->GetAlign())
710  {
712  pTableData->SetAlign(nAlign);
713  }
714 
715  if(pTableData->GetWidth() != lWidth )
716  {
719  nAlign == text::HoriOrientation::FULL ? pTableData->GetSpace() : lWidth );
720  }
723  }
724  }
725  return DeactivateRC::LeavePage;
726 }
727 
728 //Description: Page column configuration
730  : SfxTabPage(pPage, pController, "modules/swriter/ui/tablecolumnpage.ui", "TableColumnPage", &rSet)
731  , m_pTableData(nullptr)
732  , m_pSizeHdlEvent(nullptr)
733  , m_nTableWidth(0)
734  , m_nMinWidth(MINLAY)
735  , m_nMetFields(MET_FIELDS)
736  , m_nNoOfCols(0)
737  , m_nNoOfVisibleCols(0)
738  , m_bModified(false)
739  , m_bModifyTable(false)
740  , m_bPercentMode(false)
741  , m_aFieldArr { m_xBuilder->weld_metric_spin_button("width1", FieldUnit::CM),
742  m_xBuilder->weld_metric_spin_button("width2", FieldUnit::CM),
743  m_xBuilder->weld_metric_spin_button("width3", FieldUnit::CM),
744  m_xBuilder->weld_metric_spin_button("width4", FieldUnit::CM),
745  m_xBuilder->weld_metric_spin_button("width5", FieldUnit::CM),
746  m_xBuilder->weld_metric_spin_button("width6", FieldUnit::CM) }
747  , m_aTextArr { m_xBuilder->weld_label("1"),
748  m_xBuilder->weld_label("2"),
749  m_xBuilder->weld_label("3"),
750  m_xBuilder->weld_label("4"),
751  m_xBuilder->weld_label("5"),
752  m_xBuilder->weld_label("6") }
753  , m_xModifyTableCB(m_xBuilder->weld_check_button("adaptwidth"))
754  , m_xProportionalCB(m_xBuilder->weld_check_button("adaptcolumns"))
755  , m_xSpaceFT(m_xBuilder->weld_label("spaceft"))
756  , m_xSpaceSFT(m_xBuilder->weld_label("space"))
757  , m_xSpaceED(m_xBuilder->weld_metric_spin_button("spacefmt", FieldUnit::CM))
758  , m_xUpBtn(m_xBuilder->weld_button("next"))
759  , m_xDownBtn(m_xBuilder->weld_button("back"))
760 {
761  SetExchangeSupport();
762 
763  // fire off this handler to happen on next event loop when all the rest of
764  // the pages are instantiated and the dialog preferred size is that of the
765  // all the pages that currently exist and the rest to come after this one
766  m_pSizeHdlEvent = Application::PostUserEvent(LINK(this, SwTableColumnPage, SizeHdl));
767 
768  const SfxPoolItem* pItem;
769  Init(SfxItemState::SET == GetItemSet().GetItemState(SID_HTML_MODE, false, &pItem)
770  && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
771 }
772 
773 IMPL_LINK_NOARG(SwTableColumnPage, SizeHdl, void*, void)
774 {
775  m_pSizeHdlEvent = nullptr;
776 
777  //tdf#120420 keeping showing column width fields unless
778  //the dialog begins to grow, then stop adding them
779  weld::Window* pTopLevel = GetFrameWeld();
780  Size aOrigSize = pTopLevel->get_preferred_size();
781  for (sal_uInt16 i = 0; i < MET_FIELDS; ++i)
782  {
783  m_aFieldArr[i].show();
784  m_aTextArr[i]->show();
785 
786  if (pTopLevel->get_preferred_size().Width() > aOrigSize.Width())
787  {
788  m_nMetFields = i + 1;
789  m_aTextArr[i]->set_grid_width(1);
790  m_xUpBtn->set_grid_left_attach(m_nMetFields * 2 - 1);
791  break;
792  }
793  }
794 }
795 
797 {
798  if (m_pSizeHdlEvent)
799  {
801  m_pSizeHdlEvent = nullptr;
802  }
803 }
804 
805 std::unique_ptr<SfxTabPage> SwTableColumnPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
806 {
807  return std::make_unique<SwTableColumnPage>(pPage, pController, *rAttrSet);
808 }
809 
811 {
812  const SfxItemSet& rSet = GetItemSet();
813 
814  const SfxPoolItem* pItem;
815  if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP, false, &pItem ))
816  {
817  m_pTableData = static_cast<SwTableRep*>(static_cast<const SwPtrItem*>( pItem)->GetValue());
818  if (!m_xOrigTableData)
820  else // tdf#134925 and tdf#134913, reset back to the original data seen on dialog creation
822 
825  m_nTableWidth = m_pTableData->GetAlign() != text::HoriOrientation::FULL &&
826  m_pTableData->GetAlign() != text::HoriOrientation::LEFT_AND_WIDTH?
828 
829  for( sal_uInt16 i = 0; i < m_nNoOfCols; i++ )
830  {
833  }
834  sal_Int64 nMinTwips = m_aFieldArr[0].NormalizePercent( m_nMinWidth );
835  sal_Int64 nMaxTwips = m_aFieldArr[0].NormalizePercent( m_nTableWidth );
836  for( sal_uInt16 i = 0; (i < m_nMetFields) && (i < m_nNoOfVisibleCols); i++ )
837  {
838  m_aFieldArr[i].set_value( m_aFieldArr[i].NormalizePercent(
839  GetVisibleWidth(i) ), FieldUnit::TWIP );
840  m_aFieldArr[i].set_min(nMinTwips, FieldUnit::TWIP);
841  m_aFieldArr[i].set_max(nMaxTwips, FieldUnit::TWIP);
842  m_aFieldArr[i].set_sensitive(true);
843  m_aTextArr[i]->set_sensitive(true);
844  }
845 
847  {
848  m_xUpBtn->set_sensitive(true);
849  }
850 
851  for( sal_uInt16 i = m_nNoOfVisibleCols; i < m_nMetFields; ++i )
852  {
853  m_aFieldArr[i].set_text(OUString());
854  m_aTextArr[i]->set_sensitive(false);
855  }
856  }
857  ActivatePage(rSet);
858 }
859 
860 void SwTableColumnPage::Init(bool bWeb)
861 {
862  FieldUnit aMetric = ::GetDfltMetric(bWeb);
863  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwTableColumnPage, ValueChangedHdl);
864  for (sal_uInt16 i = 0; i < MET_FIELDS; ++i)
865  {
866  m_aValueTable[i] = i;
867  m_aFieldArr[i].SetMetric(aMetric);
869  }
870  SetFieldUnit(*m_xSpaceED, aMetric);
871 
872  Link<weld::Button&,void> aClickLk = LINK(this, SwTableColumnPage, AutoClickHdl);
873  m_xUpBtn->connect_clicked(aClickLk);
874  m_xDownBtn->connect_clicked(aClickLk);
875 
876  Link<weld::ToggleButton&,void> aToggleLk = LINK(this, SwTableColumnPage, ModeHdl);
877  m_xModifyTableCB->connect_toggled(aToggleLk);
878  m_xProportionalCB->connect_toggled(aToggleLk);
879 }
880 
881 IMPL_LINK(SwTableColumnPage, AutoClickHdl, weld::Button&, rControl, void)
882 {
883  //move display window
884  if (&rControl == m_xDownBtn.get())
885  {
886  if(m_aValueTable[0] > 0)
887  {
888  for(sal_uInt16 & rn : m_aValueTable)
889  rn -= 1;
890  }
891  }
892  if (&rControl == m_xUpBtn.get())
893  {
894  if( m_aValueTable[ m_nMetFields -1 ] < m_nNoOfVisibleCols -1 )
895  {
896  for(sal_uInt16 & rn : m_aValueTable)
897  rn += 1;
898  }
899  }
900  for( sal_uInt16 i = 0; (i < m_nNoOfVisibleCols ) && ( i < m_nMetFields); i++ )
901  {
902  OUString sEntry('~');
903  OUString sIndex = OUString::number( m_aValueTable[i] + 1 );
904  sEntry += sIndex;
905  m_aTextArr[i]->set_label(sEntry);
906  }
907 
908  m_xDownBtn->set_sensitive(m_aValueTable[0] > 0);
909  m_xUpBtn->set_sensitive(m_aValueTable[ m_nMetFields -1 ] < m_nNoOfVisibleCols -1 );
910  UpdateCols(0);
911 }
912 
913 IMPL_LINK(SwTableColumnPage, ValueChangedHdl, weld::MetricSpinButton&, rEdit, void)
914 {
915  m_bModified = true;
916  ModifyHdl(&rEdit);
917 }
918 
920 {
921  const bool bCheck = rBox.get_active();
922  if (&rBox == m_xProportionalCB.get())
923  {
924  if (bCheck)
925  m_xModifyTableCB->set_active(true);
926  m_xModifyTableCB->set_sensitive(!bCheck && m_bModifyTable);
927  }
928 }
929 
931 {
932  for (SwPercentField & i : m_aFieldArr)
933  {
934  if (i.has_focus())
935  {
936  ModifyHdl(i.get());
937  break;
938  }
939  }
940 
941  if (m_bModified)
942  {
944  }
945  return m_bModified;
946 }
947 
949 {
950  SwPercentField *pEdit = nullptr;
951  sal_uInt16 i;
952 
953  for( i = 0; i < m_nMetFields; i++)
954  {
955  if (pField == m_aFieldArr[i].get())
956  {
957  pEdit = &m_aFieldArr[i];
958  break;
959  }
960  }
961 
962  if (m_nMetFields <= i || !pEdit)
963  {
964  OSL_ENSURE(false, "cannot happen.");
965  return;
966  }
967 
968  SetVisibleWidth(m_aValueTable[i], pEdit->DenormalizePercent(pEdit->get_value(FieldUnit::TWIP)));
969 
971 }
972 
973 void SwTableColumnPage::UpdateCols( sal_uInt16 nCurrentPos )
974 {
975  SwTwips nSum = 0;
976 
977  for( sal_uInt16 i = 0; i < m_nNoOfCols; i++ )
978  {
979  nSum += (m_pTableData->GetColumns())[i].nWidth;
980  }
981  SwTwips nDiff = nSum - m_nTableWidth;
982 
983  bool bModifyTableChecked = m_xModifyTableCB->get_active();
984  bool bProp = m_xProportionalCB->get_active();
985 
986  if (!bModifyTableChecked && !bProp)
987  {
988  //The table width is constant, the difference is balanced with the other columns
989  sal_uInt16 nLoopCount = 0;
990  while( nDiff )
991  {
992  if( ++nCurrentPos == m_nNoOfVisibleCols)
993  {
994  nCurrentPos = 0;
995  ++nLoopCount;
996  //#i101353# in small tables it might not be possible to balance column width
997  if( nLoopCount > 1 )
998  break;
999  }
1000  if( nDiff < 0 )
1001  {
1002  SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1003  nDiff = 0;
1004  }
1005  else if( GetVisibleWidth(nCurrentPos) >= nDiff + m_nMinWidth )
1006  {
1007  SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1008  nDiff = 0;
1009  }
1010  if( nDiff > 0 && GetVisibleWidth(nCurrentPos) > m_nMinWidth )
1011  {
1012  if( nDiff >= (GetVisibleWidth(nCurrentPos) - m_nMinWidth) )
1013  {
1014  nDiff -= (GetVisibleWidth(nCurrentPos) - m_nMinWidth);
1015  SetVisibleWidth(nCurrentPos, m_nMinWidth);
1016  }
1017  else
1018  {
1019  nDiff = 0;
1020  SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1021  }
1022  OSL_ENSURE(nDiff >= 0, "nDiff < 0 cannot be here!");
1023  }
1024  }
1025  }
1026  else if (bModifyTableChecked && !bProp)
1027  {
1028  //Difference is balanced by the width of the table,
1029  //other columns remain unchanged.
1030  OSL_ENSURE(nDiff <= m_pTableData->GetSpace() - m_nTableWidth, "wrong maximum" );
1031  SwTwips nActSpace = m_pTableData->GetSpace() - m_nTableWidth;
1032  if(nDiff > nActSpace)
1033  {
1034  m_nTableWidth = m_pTableData->GetSpace();
1035  SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) - nDiff + nActSpace );
1036  }
1037  else
1038  {
1039  m_nTableWidth += nDiff;
1040  }
1041  }
1042  else if (bModifyTableChecked && bProp)
1043  {
1044  //All columns will be changed proportionally with,
1045  //the table width is adjusted accordingly.
1046  const double fOrigColWidth = std::max(SwTwips(1), GetVisibleWidth(nCurrentPos) - nDiff);
1047  const double fMaxWidth = std::max(m_pTableData->GetSpace(), m_nTableWidth);
1048  const double fMaxPercent = fMaxWidth / m_nTableWidth;
1049  const double fPercentChange = std::min(fMaxPercent, GetVisibleWidth(nCurrentPos)/fOrigColWidth);
1050  SwTwips nNewTableSize = 0;
1051  for( sal_uInt16 i = 0; i < m_nNoOfVisibleCols; i++ )
1052  {
1053  SwTwips nNewColWidth = round( fPercentChange * (i == nCurrentPos ? fOrigColWidth : GetVisibleWidth(i)) );
1054  if ( nNewColWidth < MINLAY )
1055  nNewColWidth = MINLAY;
1056  SetVisibleWidth(i, nNewColWidth);
1057  nNewTableSize += nNewColWidth;
1058  }
1059  m_nTableWidth = nNewTableSize;
1060  }
1061 
1062  if (!m_bPercentMode)
1063  {
1064  m_xSpaceED->set_value(m_xSpaceED->normalize(m_pTableData->GetSpace() - m_nTableWidth), FieldUnit::TWIP);
1065  m_xSpaceSFT->set_label(m_xSpaceED->get_text());
1066  }
1067  else
1068  m_xSpaceSFT->set_label(OUString());
1069 
1070  for( sal_uInt16 i = 0; ( i < m_nNoOfVisibleCols ) && ( i < m_nMetFields ); i++)
1071  {
1072  m_aFieldArr[i].set_value(m_aFieldArr[i].NormalizePercent(
1073  GetVisibleWidth(m_aValueTable[i]) ), FieldUnit::TWIP);
1074  }
1075 }
1076 
1078 {
1080  for( sal_uInt16 i = 0; (i < m_nMetFields) && (i < m_nNoOfVisibleCols); i++ )
1081  {
1084  }
1085 
1086  const sal_uInt16 nTableAlign = m_pTableData->GetAlign();
1087  if((text::HoriOrientation::FULL != nTableAlign && m_nTableWidth != m_pTableData->GetWidth()) ||
1088  (text::HoriOrientation::FULL == nTableAlign && m_nTableWidth != m_pTableData->GetSpace()))
1089  {
1090  m_nTableWidth = text::HoriOrientation::FULL == nTableAlign ?
1091  m_pTableData->GetSpace() :
1093  UpdateCols(0);
1094  }
1095  m_bModifyTable = true;
1096  if (m_pTableData->GetWidthPercent() ||
1097  text::HoriOrientation::FULL == nTableAlign ||
1099  m_bModifyTable = false;
1100  if (m_bPercentMode)
1101  {
1102  m_xModifyTableCB->set_active(false);
1103  m_xProportionalCB->set_active(false);
1104  }
1105  else if (!m_bModifyTable)
1106  {
1107  m_xProportionalCB->set_active(false);
1108  m_xModifyTableCB->set_active(false);
1109  }
1110  m_xSpaceFT->set_sensitive(!m_bPercentMode);
1111  m_xSpaceSFT->set_sensitive(!m_bPercentMode);
1112  m_xModifyTableCB->set_sensitive( !m_bPercentMode && m_bModifyTable );
1113  m_xProportionalCB->set_sensitive(!m_bPercentMode && m_bModifyTable );
1114 
1115  m_xSpaceED->set_value(m_xSpaceED->normalize(
1116  m_pTableData->GetSpace() - m_nTableWidth), FieldUnit::TWIP);
1117  m_xSpaceSFT->set_label(m_xSpaceED->get_text());
1118 
1119 }
1120 
1122 {
1123  if(_pSet)
1124  {
1125  FillItemSet(_pSet);
1126  if(text::HoriOrientation::FULL != m_pTableData->GetAlign() && m_pTableData->GetWidth() != m_nTableWidth)
1127  {
1131  switch( m_pTableData->GetAlign() )
1132  {
1133  case text::HoriOrientation::RIGHT:
1135  break;
1136  case text::HoriOrientation::LEFT:
1138  break;
1140  {
1141  SwTwips nDiff2 = nDiff/2;
1142  if( nDiff > 0 ||
1143  (-nDiff2 < m_pTableData->GetRightSpace() && - nDiff2 < m_pTableData->GetLeftSpace()))
1144  {
1147  }
1148  else
1149  {
1151  {
1154  }
1155  else
1156  {
1159  }
1160  }
1161  }
1162  break;
1163  case text::HoriOrientation::CENTER:
1166  break;
1167  case text::HoriOrientation::LEFT_AND_WIDTH :
1168  if(nDiff > m_pTableData->GetRightSpace())
1169  {
1171  }
1174  break;
1175  }
1177  }
1178  _pSet->Put(SwPtrItem( FN_TABLE_REP, m_pTableData ));
1179  }
1180  return DeactivateRC::LeavePage;
1181 }
1182 
1184 {
1185  sal_uInt16 i=0;
1186 
1187  while( nPos )
1188  {
1189  if(m_pTableData->GetColumns()[i].bVisible)
1190  nPos--;
1191  i++;
1192  }
1193  SwTwips nReturn = m_pTableData->GetColumns()[i].nWidth;
1194  OSL_ENSURE(i < m_nNoOfCols, "Array index out of range");
1195  while(!m_pTableData->GetColumns()[i].bVisible && (i + 1) < m_nNoOfCols)
1196  nReturn += m_pTableData->GetColumns()[++i].nWidth;
1197 
1198  return nReturn;
1199 }
1200 
1201 void SwTableColumnPage::SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth)
1202 {
1203  sal_uInt16 i=0;
1204  while( nPos )
1205  {
1206  if(m_pTableData->GetColumns()[i].bVisible)
1207  nPos--;
1208  i++;
1209  }
1210  OSL_ENSURE(i < m_nNoOfCols, "Array index out of range");
1211  m_pTableData->GetColumns()[i].nWidth = nNewWidth;
1212  while(!m_pTableData->GetColumns()[i].bVisible && (i + 1) < m_nNoOfCols)
1213  m_pTableData->GetColumns()[++i].nWidth = 0;
1214 
1215 }
1216 
1218  : SfxTabDialogController(pParent, "modules/swriter/ui/tableproperties.ui", "TablePropertiesDialog", pItemSet)
1219  , pShell(pSh)
1220 {
1222  AddTabPage("table", &SwFormatTablePage::Create, nullptr);
1223  AddTabPage("textflow", &SwTextFlowPage::Create, nullptr);
1224  AddTabPage("columns", &SwTableColumnPage::Create, nullptr);
1225  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1226  AddTabPage("borders", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BORDER), nullptr);
1227 }
1228 
1229 void SwTableTabDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
1230 {
1231  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1232  if (rId == "background")
1233  {
1234  SvxBackgroundTabFlags const nFlagType = SvxBackgroundTabFlags::SHOW_TBLCTL;
1235  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(nFlagType)));
1236  rPage.PageCreated(aSet);
1237  }
1238  else if (rId == "borders")
1239  {
1240  aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE, static_cast<sal_uInt16>(SwBorderModes::TABLE)));
1241  rPage.PageCreated(aSet);
1242  }
1243  else if (rId == "textflow")
1244  {
1245  static_cast<SwTextFlowPage&>(rPage).SetShell(pShell);
1246  const FrameTypeFlags eType = pShell->GetFrameType(nullptr,true);
1247  if( !(FrameTypeFlags::BODY & eType) )
1248  static_cast<SwTextFlowPage&>(rPage).DisablePageBreak();
1249  }
1250 }
1251 
1253  : SfxTabPage(pPage, pController, "modules/swriter/ui/tabletextflowpage.ui", "TableTextFlowPage", &rSet)
1254  , pShell(nullptr)
1255  , bPageBreak(true)
1256  , bHtmlMode(false)
1257  , m_xPgBrkCB(m_xBuilder->weld_check_button("break"))
1258  , m_xPgBrkRB(m_xBuilder->weld_radio_button("page"))
1259  , m_xColBrkRB(m_xBuilder->weld_radio_button("column"))
1260  , m_xPgBrkBeforeRB(m_xBuilder->weld_radio_button("before"))
1261  , m_xPgBrkAfterRB(m_xBuilder->weld_radio_button("after"))
1262  , m_xPageCollCB(m_xBuilder->weld_check_button("pagestyle"))
1263  , m_xPageCollLB(m_xBuilder->weld_combo_box("pagestylelb"))
1264  , m_xPageNoCB(m_xBuilder->weld_check_button("pagenoft"))
1265  , m_xPageNoNF(m_xBuilder->weld_spin_button("pagenonf"))
1266  , m_xSplitCB(m_xBuilder->weld_check_button("split"))
1267  , m_xSplitRowCB(m_xBuilder->weld_check_button("splitrow"))
1268  , m_xKeepCB(m_xBuilder->weld_check_button("keep"))
1269  , m_xHeadLineCB(m_xBuilder->weld_check_button("headline"))
1270  , m_xRepeatHeaderCombo(m_xBuilder->weld_widget("repeatheader"))
1271  , m_xRepeatHeaderNF(m_xBuilder->weld_spin_button("repeatheadernf"))
1272  , m_xTextDirectionLB(m_xBuilder->weld_combo_box("textorientation"))
1273  , m_xVertOrientLB(m_xBuilder->weld_combo_box("vertorient"))
1274 {
1275  m_xPgBrkCB->connect_toggled(LINK(this, SwTextFlowPage, PageBreakHdl_Impl));
1276  m_xPgBrkBeforeRB->connect_toggled(
1277  LINK(this, SwTextFlowPage, PageBreakPosHdl_Impl));
1278  m_xPgBrkAfterRB->connect_toggled(
1279  LINK(this, SwTextFlowPage, PageBreakPosHdl_Impl));
1280  m_xPageCollCB->connect_toggled(
1281  LINK(this, SwTextFlowPage, ApplyCollClickHdl_Impl));
1282  m_xColBrkRB->connect_toggled(
1283  LINK(this, SwTextFlowPage, PageBreakTypeHdl_Impl));
1284  m_xPgBrkRB->connect_toggled(
1285  LINK(this, SwTextFlowPage, PageBreakTypeHdl_Impl));
1286  m_xPageNoCB->connect_toggled(
1287  LINK(this, SwTextFlowPage, PageNoClickHdl_Impl));
1288  m_xSplitCB->connect_toggled(
1289  LINK(this, SwTextFlowPage, SplitHdl_Impl));
1290  m_xHeadLineCB->connect_toggled(LINK(this, SwTextFlowPage, HeadLineCBClickHdl));
1291 
1292  const SfxPoolItem *pItem;
1293  if(SfxItemState::SET == rSet.GetItemState( SID_HTML_MODE, false,&pItem )
1294  && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
1295  {
1296  m_xKeepCB->hide();
1297  m_xSplitCB->hide();
1298  m_xSplitRowCB->hide();
1299  }
1300 
1301  HeadLineCBClickHdl(*m_xHeadLineCB);
1302 }
1303 
1305 {
1306 }
1307 
1308 std::unique_ptr<SfxTabPage> SwTextFlowPage::Create(weld::Container* pPage, weld::DialogController* pController,
1309  const SfxItemSet* rAttrSet)
1310 {
1311  return std::make_unique<SwTextFlowPage>(pPage, pController, *rAttrSet);
1312 }
1313 
1315 {
1316  bool bModified = false;
1317 
1318  //Repeat Heading
1319  if (m_xHeadLineCB->get_state_changed_from_saved() ||
1320  m_xRepeatHeaderNF->get_value_changed_from_saved() )
1321  {
1322  bModified |= nullptr != rSet->Put(
1323  SfxUInt16Item(FN_PARAM_TABLE_HEADLINE, m_xHeadLineCB->get_active() ? sal_uInt16(m_xRepeatHeaderNF->get_value()) : 0));
1324  }
1325  if (m_xKeepCB->get_state_changed_from_saved())
1326  bModified |= nullptr != rSet->Put( SvxFormatKeepItem( m_xKeepCB->get_active(), RES_KEEP));
1327 
1328  if (m_xSplitCB->get_state_changed_from_saved())
1329  bModified |= nullptr != rSet->Put( SwFormatLayoutSplit( m_xSplitCB->get_active()));
1330 
1331  if (m_xSplitRowCB->get_state_changed_from_saved())
1332  bModified |= nullptr != rSet->Put( SwFormatRowSplit( m_xSplitRowCB->get_active()));
1333 
1334  const SvxFormatBreakItem* pBreak = GetOldItem( *rSet, RES_BREAK );
1335  const SwFormatPageDesc* pDesc = GetOldItem( *rSet, RES_PAGEDESC );
1336 
1337  bool bState = m_xPageCollCB->get_active();
1338 
1339  //If we have a page style, then there's no break
1340  bool bPageItemPut = false;
1341  if ( bState != (m_xPageCollCB->get_saved_state() == TRISTATE_TRUE)
1342  || (bState && m_xPageCollLB->get_value_changed_from_saved())
1343  || (m_xPageNoCB->get_sensitive() && m_xPageNoCB->get_state_changed_from_saved())
1344  || (m_xPageNoNF->get_sensitive() && m_xPageNoNF->get_value_changed_from_saved()))
1345  {
1346  OUString sPage;
1347 
1348  if ( bState )
1349  {
1350  sPage = m_xPageCollLB->get_active_text();
1351  }
1352  sal_uInt16 nPgNum = static_cast<sal_uInt16>(m_xPageNoNF->get_value());
1353  bool const usePageNo(bState && m_xPageNoCB->get_active());
1354  std::optional<sal_uInt16> const oPageNum(
1355  usePageNo ? nPgNum : std::optional<sal_Int16>());
1356  if (!pDesc || !pDesc->GetPageDesc()
1357  || (pDesc->GetPageDesc()->GetName() != sPage)
1358  || (pDesc->GetNumOffset() != oPageNum))
1359  {
1360  SwFormatPageDesc aFormat( pShell->FindPageDescByName( sPage, true ) );
1361  aFormat.SetNumOffset(oPageNum);
1362  bModified |= nullptr != rSet->Put( aFormat );
1363  bPageItemPut = bState;
1364  }
1365  }
1366  bool bIsChecked = m_xPgBrkCB->get_active();
1367  if ( !bPageItemPut &&
1368  ( bState != (m_xPageCollCB->get_saved_state() == TRISTATE_TRUE) ||
1369  bIsChecked != (m_xPgBrkCB->get_saved_state() == TRISTATE_TRUE) ||
1370  m_xPgBrkBeforeRB->get_state_changed_from_saved() ||
1371  m_xPgBrkRB->get_state_changed_from_saved() ))
1372  {
1373  SvxFormatBreakItem aBreak( GetItemSet().Get( RES_BREAK ) );
1374 
1375  if(bIsChecked)
1376  {
1377  bool bBefore = m_xPgBrkBeforeRB->get_active();
1378 
1379  if (m_xPgBrkRB->get_active())
1380  {
1381  if ( bBefore )
1382  aBreak.SetValue( SvxBreak::PageBefore );
1383  else
1384  aBreak.SetValue( SvxBreak::PageAfter );
1385  }
1386  else
1387  {
1388  if ( bBefore )
1389  aBreak.SetValue( SvxBreak::ColumnBefore );
1390  else
1391  aBreak.SetValue( SvxBreak::ColumnAfter );
1392  }
1393  }
1394  else
1395  {
1396  aBreak.SetValue( SvxBreak::NONE );
1397  }
1398 
1399  if ( !pBreak || !( *pBreak == aBreak ) )
1400  {
1401  bModified |= nullptr != rSet->Put( aBreak );
1402  }
1403  }
1404 
1405  if (m_xTextDirectionLB->get_value_changed_from_saved())
1406  {
1407  OUString sId = m_xTextDirectionLB->get_active_id();
1408  bModified |= nullptr != rSet->Put(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(sId.toUInt32()), FN_TABLE_BOX_TEXTORIENTATION));
1409  }
1410 
1411  if (m_xVertOrientLB->get_value_changed_from_saved())
1412  {
1413  sal_uInt16 nOrient = USHRT_MAX;
1414  switch (m_xVertOrientLB->get_active())
1415  {
1416  case 0 : nOrient = text::VertOrientation::NONE; break;
1417  case 1 : nOrient = text::VertOrientation::CENTER; break;
1418  case 2 : nOrient = text::VertOrientation::BOTTOM; break;
1419  }
1420  if (nOrient != USHRT_MAX)
1421  bModified |= nullptr != rSet->Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, nOrient));
1422  }
1423 
1424  return bModified;
1425 
1426 }
1427 
1429 {
1430  const SfxPoolItem* pItem;
1431  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1432  bool bFlowAllowed = !bHtmlMode || rHtmlOpt.IsPrintLayoutExtension();
1433  if(bFlowAllowed)
1434  {
1435  //Inserting of the existing page templates in the list box
1436  const size_t nCount = pShell->GetPageDescCnt();
1437 
1438  for( size_t i = 0; i < nCount; ++i)
1439  {
1440  const SwPageDesc &rPageDesc = pShell->GetPageDesc(i);
1441  m_xPageCollLB->append_text(rPageDesc.GetName());
1442  }
1443 
1444  OUString aFormatName;
1445  for (sal_uInt16 i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i)
1446  {
1447  aFormatName = SwStyleNameMapper::GetUIName(i, aFormatName);
1448  if (m_xPageCollLB->find_text(aFormatName) == -1)
1449  m_xPageCollLB->append_text(aFormatName);
1450  }
1451 
1452  if(SfxItemState::SET == rSet->GetItemState( RES_KEEP, false, &pItem ))
1453  {
1454  m_xKeepCB->set_active( static_cast<const SvxFormatKeepItem*>(pItem)->GetValue() );
1455  m_xKeepCB->save_state();
1456  }
1457  if(SfxItemState::SET == rSet->GetItemState( RES_LAYOUT_SPLIT, false, &pItem ))
1458  {
1459  m_xSplitCB->set_active( static_cast<const SwFormatLayoutSplit*>(pItem)->GetValue() );
1460  }
1461  else
1462  m_xSplitCB->set_active(true);
1463 
1464  m_xSplitCB->save_state();
1465  SplitHdl_Impl(*m_xSplitCB);
1466 
1467  if(SfxItemState::SET == rSet->GetItemState( RES_ROW_SPLIT, false, &pItem ))
1468  {
1469  m_xSplitRowCB->set_active( static_cast<const SwFormatRowSplit*>(pItem)->GetValue() );
1470  }
1471  else
1472  m_xSplitRowCB->set_state(TRISTATE_INDET);
1473  m_xSplitRowCB->save_state();
1474 
1475  if(bPageBreak)
1476  {
1477  if(SfxItemState::SET == rSet->GetItemState( RES_PAGEDESC, false, &pItem ))
1478  {
1479  OUString sPageDesc;
1480  const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
1481 
1482  ::std::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset();
1483  if (oNumOffset)
1484  {
1485  m_xPageNoCB->set_active(true);
1486  m_xPageNoNF->set_sensitive(true);
1487  m_xPageNoNF->set_value(*oNumOffset);
1488  }
1489  else
1490  {
1491  m_xPageNoCB->set_active(false);
1492  m_xPageNoNF->set_sensitive(false);
1493  }
1494 
1495  if(pDesc)
1496  sPageDesc = pDesc->GetName();
1497  if (!sPageDesc.isEmpty() && m_xPageCollLB->find_text(sPageDesc) != -1)
1498  {
1499  m_xPageCollLB->set_active_text(sPageDesc);
1500  m_xPageCollCB->set_active(true);
1501 
1502  m_xPgBrkCB->set_sensitive(true);
1503  m_xPgBrkRB->set_sensitive(true);
1504  m_xColBrkRB->set_sensitive(true);
1505  m_xPgBrkBeforeRB->set_sensitive(true);
1506  m_xPgBrkAfterRB->set_sensitive(true);
1507  m_xPageCollCB->set_sensitive(true);
1508 
1509  m_xPgBrkCB->set_active(true);
1510  m_xColBrkRB->set_active( false );
1511  m_xPgBrkBeforeRB->set_active(true);
1512  m_xPgBrkAfterRB->set_active( false );
1513  }
1514  else
1515  {
1516  m_xPageCollLB->set_active(-1);
1517  m_xPageCollCB->set_active(false);
1518  }
1519  }
1520 
1521  if(SfxItemState::SET == rSet->GetItemState( RES_BREAK, false, &pItem ))
1522  {
1523  const SvxFormatBreakItem* pPageBreak = static_cast<const SvxFormatBreakItem*>(pItem);
1524  SvxBreak eBreak = pPageBreak->GetBreak();
1525 
1526  if ( eBreak != SvxBreak::NONE )
1527  {
1528  m_xPgBrkCB->set_active(true);
1529  m_xPageCollCB->set_sensitive(false);
1530  m_xPageCollLB->set_sensitive(false);
1531  m_xPageNoCB->set_sensitive(false);
1532  m_xPageNoNF->set_sensitive(false);
1533  }
1534  switch ( eBreak )
1535  {
1536  case SvxBreak::PageBefore:
1537  m_xPgBrkRB->set_active(true);
1538  m_xColBrkRB->set_active( false );
1539  m_xPgBrkBeforeRB->set_active(true);
1540  m_xPgBrkAfterRB->set_active( false );
1541  break;
1542  case SvxBreak::PageAfter:
1543  m_xPgBrkRB->set_active(true);
1544  m_xColBrkRB->set_active( false );
1545  m_xPgBrkBeforeRB->set_active( false );
1546  m_xPgBrkAfterRB->set_active(true);
1547  break;
1548  case SvxBreak::ColumnBefore:
1549  m_xPgBrkRB->set_active( false );
1550  m_xColBrkRB->set_active(true);
1551  m_xPgBrkBeforeRB->set_active(true);
1552  m_xPgBrkAfterRB->set_active( false );
1553  break;
1554  case SvxBreak::ColumnAfter:
1555  m_xPgBrkRB->set_active( false );
1556  m_xColBrkRB->set_active(true);
1557  m_xPgBrkBeforeRB->set_active( false );
1558  m_xPgBrkAfterRB->set_active(true);
1559  break;
1560  default:; //prevent warning
1561  }
1562 
1563  }
1564  if (m_xPgBrkBeforeRB->get_active())
1565  PageBreakPosHdl_Impl(*m_xPgBrkBeforeRB);
1566  else if (m_xPgBrkAfterRB->get_active())
1567  PageBreakPosHdl_Impl(*m_xPgBrkAfterRB);
1568  PageBreakHdl_Impl(*m_xPgBrkCB);
1569  }
1570  }
1571  else
1572  {
1573  m_xPgBrkRB->set_sensitive(false);
1574  m_xColBrkRB->set_sensitive(false);
1575  m_xPgBrkBeforeRB->set_sensitive(false);
1576  m_xPgBrkAfterRB->set_sensitive(false);
1577  m_xKeepCB->set_sensitive(false);
1578  m_xSplitCB->set_sensitive(false);
1579  m_xPgBrkCB->set_sensitive(false);
1580  m_xPageCollCB->set_sensitive(false);
1581  m_xPageCollLB->set_sensitive(false);
1582  }
1583 
1584  if(SfxItemState::SET == rSet->GetItemState( FN_PARAM_TABLE_HEADLINE, false, &pItem ))
1585  {
1586  sal_uInt16 nRep = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1587  m_xHeadLineCB->set_active(nRep > 0);
1588  m_xHeadLineCB->save_state();
1589  m_xRepeatHeaderNF->set_value(nRep);
1590  m_xRepeatHeaderNF->set_min(1);
1591  m_xRepeatHeaderNF->save_value();
1592  }
1593  if ( rSet->GetItemState(FN_TABLE_BOX_TEXTORIENTATION) > SfxItemState::DEFAULT )
1594  {
1595  SvxFrameDirection nDirection =
1596  static_cast<const SvxFrameDirectionItem&>(rSet->Get(FN_TABLE_BOX_TEXTORIENTATION)).GetValue();
1597  m_xTextDirectionLB->set_active_id(OUString::number(static_cast<sal_uInt32>(nDirection)));
1598  }
1599 
1600  if ( rSet->GetItemState(FN_TABLE_SET_VERT_ALIGN) > SfxItemState::DEFAULT )
1601  {
1602  sal_uInt16 nVert = static_cast<const SfxUInt16Item&>(rSet->Get(FN_TABLE_SET_VERT_ALIGN)).GetValue();
1603  sal_uInt16 nPos = 0;
1604  switch(nVert)
1605  {
1606  case text::VertOrientation::NONE: nPos = 0; break;
1607  case text::VertOrientation::CENTER: nPos = 1; break;
1608  case text::VertOrientation::BOTTOM: nPos = 2; break;
1609  }
1610  m_xVertOrientLB->set_active(nPos);
1611  }
1612 
1613  m_xPageCollCB->save_state();
1614  m_xPageCollLB->save_value();
1615  m_xPgBrkCB->save_state();
1616  m_xPgBrkRB->save_state();
1617  m_xColBrkRB->save_state();
1618  m_xPgBrkBeforeRB->save_state();
1619  m_xPgBrkAfterRB->save_state();
1620  m_xPageNoCB->save_state();
1621  m_xPageNoNF->save_value();
1622  m_xTextDirectionLB->save_value();
1623  m_xVertOrientLB->save_value();
1624 
1625  HeadLineCBClickHdl(*m_xHeadLineCB);
1626 }
1627 
1629 {
1630  pShell = pSh;
1632  if(bHtmlMode)
1633  {
1634  m_xPageNoNF->set_sensitive(false);
1635  m_xPageNoCB->set_sensitive(false);
1636  }
1637 }
1638 
1640 {
1641  if (m_xPgBrkCB->get_active())
1642  {
1643  m_xPgBrkRB->set_sensitive(true);
1644  m_xColBrkRB->set_sensitive(true);
1645  m_xPgBrkBeforeRB->set_sensitive(true);
1646  m_xPgBrkAfterRB->set_sensitive(true);
1647 
1648  if (m_xPgBrkRB->get_active() && m_xPgBrkBeforeRB->get_active())
1649  {
1650  m_xPageCollCB->set_sensitive(true);
1651 
1652  bool bEnable = m_xPageCollCB->get_active() && m_xPageCollLB->get_count();
1653  m_xPageCollLB->set_sensitive(bEnable);
1654  if (!bHtmlMode)
1655  {
1656  m_xPageNoCB->set_sensitive(bEnable);
1657  m_xPageNoNF->set_sensitive(bEnable && m_xPageNoCB->get_active());
1658  }
1659  }
1660  }
1661  else
1662  {
1663  m_xPageCollCB->set_active(false);
1664  m_xPageCollCB->set_sensitive(false);
1665  m_xPageCollLB->set_sensitive(false);
1666  m_xPageNoCB->set_sensitive(false);
1667  m_xPageNoNF->set_sensitive(false);
1668  m_xPgBrkRB->set_sensitive(false);
1669  m_xColBrkRB->set_sensitive(false);
1670  m_xPgBrkBeforeRB->set_sensitive(false);
1671  m_xPgBrkAfterRB->set_sensitive(false);
1672  }
1673 }
1674 
1675 IMPL_LINK_NOARG(SwTextFlowPage, ApplyCollClickHdl_Impl, weld::ToggleButton&, void)
1676 {
1677  bool bEnable = false;
1678  if (m_xPageCollCB->get_active() && m_xPageCollLB->get_count())
1679  {
1680  bEnable = true;
1681  m_xPageCollLB->set_active(0);
1682  }
1683  else
1684  {
1685  m_xPageCollLB->set_active(-1);
1686  }
1687  m_xPageCollLB->set_sensitive(bEnable);
1688  if (!bHtmlMode)
1689  {
1690  m_xPageNoCB->set_sensitive(bEnable);
1691  m_xPageNoNF->set_sensitive(bEnable && m_xPageNoCB->get_active());
1692  }
1693 }
1694 
1695 IMPL_LINK_NOARG(SwTextFlowPage, PageBreakPosHdl_Impl, weld::ToggleButton&, void)
1696 {
1697  if (!m_xPgBrkCB->get_active())
1698  return;
1699 
1700  if (m_xPgBrkBeforeRB->get_active() && m_xPgBrkRB->get_active())
1701  {
1702  m_xPageCollCB->set_sensitive(true);
1703 
1704  bool bEnable = m_xPageCollCB->get_active() && m_xPageCollLB->get_count();
1705 
1706  m_xPageCollLB->set_sensitive(bEnable);
1707  if (!bHtmlMode)
1708  {
1709  m_xPageNoCB->set_sensitive(bEnable);
1710  m_xPageNoNF->set_sensitive(bEnable && m_xPageNoCB->get_active());
1711  }
1712  }
1713  else if (m_xPgBrkAfterRB->get_active())
1714  {
1715  m_xPageCollCB->set_active(false);
1716  m_xPageCollCB->set_sensitive(false);
1717  m_xPageCollLB->set_sensitive(false);
1718  m_xPageNoCB->set_sensitive(false);
1719  m_xPageNoNF->set_sensitive(false);
1720  }
1721 }
1722 
1723 IMPL_LINK_NOARG(SwTextFlowPage, PageBreakTypeHdl_Impl, weld::ToggleButton&, void)
1724 {
1725  if (m_xColBrkRB->get_active() || m_xPgBrkAfterRB->get_active())
1726  {
1727  m_xPageCollCB->set_active(false);
1728  m_xPageCollCB->set_sensitive(false);
1729  m_xPageCollLB->set_sensitive(false);
1730  m_xPageNoCB->set_sensitive(false);
1731  m_xPageNoNF->set_sensitive(false);
1732  }
1733  else if (m_xPgBrkBeforeRB->get_active())
1734  PageBreakPosHdl_Impl(*m_xPgBrkBeforeRB);
1735 }
1736 
1738 {
1739  m_xPageNoNF->set_sensitive(m_xPageNoCB->get_active());
1740 }
1741 
1742 IMPL_LINK(SwTextFlowPage, SplitHdl_Impl, weld::ToggleButton&, rBox, void)
1743 {
1744  m_xSplitRowCB->set_sensitive(rBox.get_active());
1745 }
1746 
1748 {
1749  m_xRepeatHeaderCombo->set_sensitive(m_xHeadLineCB->get_active());
1750 }
1751 
1753 {
1754  bPageBreak = false;
1755  m_xPgBrkCB->set_sensitive(false);
1756  m_xPgBrkRB->set_sensitive(false);
1757  m_xColBrkRB->set_sensitive(false);
1758  m_xPgBrkBeforeRB->set_sensitive(false);
1759  m_xPgBrkAfterRB->set_sensitive(false);
1760  m_xPageCollCB->set_sensitive(false);
1761  m_xPageCollLB->set_sensitive(false);
1762  m_xPageNoCB->set_sensitive(false);
1763  m_xPageNoNF->set_sensitive(false);
1764 }
1765 
1766 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxBreak
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
std::unique_ptr< weld::Label > m_xRightFT
Definition: tablepg.hxx:54
const ::std::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:64
std::unique_ptr< weld::Label > m_xSpaceFT
Definition: tablepg.hxx:113
bool IsPrintLayoutExtension() const
SwTwips nWidth
Definition: swtablerep.hxx:29
sal_uInt16 m_nNoOfVisibleCols
Definition: tablepg.hxx:102
std::unique_ptr< SwTableRep > m_xOrigTableData
Definition: tablepg.hxx:96
FieldUnit
std::unique_ptr< weld::ComboBox > m_xVertOrientLB
Definition: tablepg.hxx:163
SwFormatTablePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: tabledlg.cxx:66
void SetRefValue(int nValue)
Definition: prcntfld.cxx:39
SwTableColumnPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: tabledlg.cxx:729
void SetLeftSpace(SwTwips nSet)
Definition: swtablerep.hxx:61
void Init()
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
size_t GetPageDescCnt() const
Definition: fedesc.cxx:38
TColumn * GetColumns()
Definition: swtablerep.hxx:90
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:61
std::unique_ptr< weld::RadioButton > m_xFreeBtn
Definition: tablepg.hxx:50
SwTextFlowPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: tabledlg.cxx:1252
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
SwTwips GetLeftSpace() const
Definition: swtablerep.hxx:60
std::unique_ptr< weld::Label > m_xLeftFT
Definition: tablepg.hxx:52
std::string GetValue
sal_uInt16 m_aValueTable[MET_FIELDS]
Definition: tablepg.hxx:104
void UpdateCols(sal_uInt16 nCurrentPos)
Definition: tabledlg.cxx:973
bool HasWidthChanged() const
Definition: swtablerep.hxx:81
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: tabledlg.cxx:1121
SwTwips m_nMinWidth
Definition: tablepg.hxx:99
sal_uInt16 char char * pDesc
SvxBreak GetBreak() const
void SetAlign(sal_uInt16 nSet)
Definition: swtablerep.hxx:73
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
long Long
void ShowPercent(bool bPercent)
Definition: prcntfld.cxx:49
#define MINLAY
Definition: swtypes.hxx:66
SwWrtShell * pShell
Definition: tabledlg.hxx:30
void ModifyHdl(const weld::MetricSpinButton &rEdit, bool bAllowInconsistencies=false)
Definition: tabledlg.cxx:271
std::unique_ptr< weld::RadioButton > m_xFullBtn
Definition: tablepg.hxx:45
void SetColsChanged()
Definition: swtablerep.hxx:79
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
std::unique_ptr< weld::SpinButton > m_xRepeatHeaderNF
Definition: tablepg.hxx:161
SvxFrameDirection
SfxItemSet * GetInputSetImpl()
#define FN_PARAM_TABLE_NAME
Definition: cmdid.h:779
SwTwips GetRightSpace() const
Definition: swtablerep.hxx:63
std::unique_ptr< weld::Label > m_xBottomFT
Definition: tablepg.hxx:58
TRISTATE_TRUE
virtual void Reset(const SfxItemSet *rSet) override
Definition: tabledlg.cxx:1428
SwTwips GetWidth() const
Definition: swtablerep.hxx:66
void set_min(int nNewMin, FieldUnit eInUnit)
Definition: prcntfld.cxx:135
void SetRightSpace(SwTwips nSet)
Definition: swtablerep.hxx:64
const OUString & GetName() const
Definition: pagedesc.hxx:197
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
std::unique_ptr< weld::Button > m_xDownBtn
Definition: tablepg.hxx:117
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
#define FN_PARAM_TABLE_HEADLINE
Definition: cmdid.h:780
constexpr tools::Long Width() const
std::unique_ptr< weld::CheckButton > m_xSplitCB
Definition: tablepg.hxx:156
const SwView & GetView() const
Definition: wrtsh.hxx:429
std::unique_ptr< SwPercentField > m_xRightMF
Definition: tablepg.hxx:55
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
void set_value(int nNewValue, FieldUnit eInUnit=FieldUnit::NONE)
Definition: prcntfld.cxx:107
SvxBackgroundTabFlags
OUString SvxResId(const char *pId)
std::unique_ptr< SwPercentField > m_xWidthMF
Definition: tablepg.hxx:42
sal_uInt16 GetAlign() const
Definition: swtablerep.hxx:72
std::unique_ptr< weld::CheckButton > m_xPageNoCB
Definition: tablepg.hxx:154
std::unique_ptr< weld::Label > m_xTopFT
Definition: tablepg.hxx:56
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: tabledlg.cxx:589
void SetExchangeSupport()
int nCount
SwTableTabDlg(weld::Window *pParent, const SfxItemSet *pItemSet, SwWrtShell *pSh)
Definition: tabledlg.cxx:1217
void set_sensitive(bool bEnable)
Definition: prcntfld.hxx:51
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: tabledlg.cxx:930
void connect_value_changed(const Link< weld::MetricSpinButton &, void > &rLink)
Definition: prcntfld.hxx:49
std::unique_ptr< weld::Entry > m_xNameED
Definition: tablepg.hxx:40
std::unique_ptr< weld::CheckButton > m_xKeepCB
Definition: tablepg.hxx:158
sal_uInt16 GetAllColCount() const
Definition: swtablerep.hxx:76
std::unique_ptr< weld::Label > m_aTextArr[MET_FIELDS]
Definition: tablepg.hxx:110
sal_uInt16 GetColCount() const
Definition: swtablerep.hxx:75
std::unique_ptr< weld::Widget > m_xProperties
Definition: tablepg.hxx:62
void SetWidth(SwTwips nSet)
Definition: swtablerep.hxx:67
TRISTATE_INDET
std::unique_ptr< weld::ComboBox > m_xPageCollLB
Definition: tablepg.hxx:153
sal_uInt16 GetWidthPercent() const
Definition: swtablerep.hxx:69
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
std::unique_ptr< weld::CheckButton > m_xSplitRowCB
Definition: tablepg.hxx:157
const SfxItemSet & GetItemSet() const
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
static SvxHtmlOptions & Get()
DocumentType eType
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
void DisablePageBreak()
Definition: tabledlg.cxx:1752
#define SW_MOD()
Definition: swmodule.hxx:255
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:726
int i
void set_max(int nNewMax, FieldUnit eInUnit)
Definition: prcntfld.cxx:150
virtual ~SwFormatTablePage() override
Definition: tabledlg.cxx:121
std::unique_ptr< weld::RadioButton > m_xPgBrkBeforeRB
Definition: tablepg.hxx:150
int NormalizePercent(int nValue)
Definition: prcntfld.cxx:156
int get_value(FieldUnit eOutUnit=FieldUnit::NONE)
Definition: prcntfld.cxx:130
SwPercentField m_aFieldArr[MET_FIELDS]
Definition: tablepg.hxx:109
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:126
HTMLMODE_ON
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
SwTwips GetSpace() const
Definition: swtablerep.hxx:87
void SetWidthChanged()
Definition: swtablerep.hxx:82
sal_uInt16 m_nMetFields
Definition: tablepg.hxx:100
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: tabledlg.cxx:805
std::unique_ptr< SwPercentField > m_xLeftMF
Definition: tablepg.hxx:53
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
Returns the item set associated with a character/inet/auto style.
Definition: atrstck.cxx:132
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: tabledlg.cxx:384
std::unique_ptr< weld::ComboBox > m_xTextDirectionLB
Definition: tablepg.hxx:162
std::unique_ptr< weld::CheckButton > m_xPageCollCB
Definition: tablepg.hxx:152
OUString SwResId(const char *pId)
Definition: swmodule.cxx:166
std::unique_ptr< weld::MetricSpinButton > m_xSpaceED
Definition: tablepg.hxx:115
virtual Size get_preferred_size() const =0
IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::ToggleButton &, void)
Definition: tabledlg.cxx:183
tools::Long SwTwips
Definition: swtypes.hxx:49
static sal_uInt16 nPgNum
Definition: viewport.cxx:50
SwTwips nMinTableWidth
Definition: tablepg.hxx:35
SwDocShell * GetDocShell()
Definition: view.cxx:1126
std::unique_ptr< weld::RadioButton > m_xPgBrkRB
Definition: tablepg.hxx:148
SwTwips nSaveWidth
Definition: tablepg.hxx:34
#define MET_FIELDS
Definition: tablepg.hxx:91
void ModifyHdl(const weld::MetricSpinButton *pEdit)
Definition: tabledlg.cxx:948
virtual void Reset(const SfxItemSet *rSet) override
Definition: tabledlg.cxx:810
std::unique_ptr< weld::SpinButton > m_xPageNoNF
Definition: tablepg.hxx:155
std::unique_ptr< svx::FrameDirectionListBox > m_xTextDirectionLB
Definition: tablepg.hxx:61
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetWidthPercent(sal_uInt16 nSet)
Definition: swtablerep.hxx:70
weld::Window * GetFrameWeld() const
std::unique_ptr< weld::RadioButton > m_xLeftBtn
Definition: tablepg.hxx:46
void SetShell(SwWrtShell *pSh)
Definition: tabledlg.cxx:1628
weld::Entry & rEdit
std::unique_ptr< weld::CheckButton > m_xHeadLineCB
Definition: tablepg.hxx:159
std::unique_ptr< weld::MetricSpinButton > m_xBottomMF
Definition: tablepg.hxx:59
sal_uInt16 m_nNoOfCols
Definition: tablepg.hxx:101
SwWrtShell * pShell
Definition: tablepg.hxx:143
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::RadioButton > m_xFromLeftBtn
Definition: tablepg.hxx:47
#define FN_TABLE_REP
Definition: cmdid.h:345
void SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth)
Definition: tabledlg.cxx:1201
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
std::unique_ptr< weld::RadioButton > m_xColBrkRB
Definition: tablepg.hxx:149
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: tabledlg.cxx:1229
IMPL_LINK(SwFormatTablePage, RelWidthClickHdl, weld::ToggleButton &, rBtn, void)
Definition: tabledlg.cxx:149
virtual ~SwTableColumnPage() override
Definition: tabledlg.cxx:796
virtual ~SwTextFlowPage() override
Definition: tabledlg.cxx:1304
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
int DenormalizePercent(int nValue)
Definition: prcntfld.cxx:165
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
std::unique_ptr< weld::MetricSpinButton > m_xTopMF
Definition: tablepg.hxx:57
#define FN_TABLE_BOX_TEXTORIENTATION
Definition: cmdid.h:428
SwTwips GetVisibleWidth(sal_uInt16 nPos)
Definition: tabledlg.cxx:1183
DeactivateRC
SwPageDesc * FindPageDescByName(const OUString &rName, bool bGetFromPool=false, size_t *pPos=nullptr)
Definition: fedesc.cxx:131
std::unique_ptr< weld::Label > m_xSpaceSFT
Definition: tablepg.hxx:114
OUString sId
bool IsLineSelected() const
Definition: swtablerep.hxx:84
bool bVisible
Definition: swtablerep.hxx:30
std::unique_ptr< weld::Label > m_xWidthFT
Definition: tablepg.hxx:41
std::unique_ptr< weld::CheckButton > m_xProportionalCB
Definition: tablepg.hxx:112
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
void SetNumOffset(const ::std::optional< sal_uInt16 > &oNum)
Definition: fmtpdsc.hxx:65
void SetMetric(FieldUnit eUnit)
Definition: prcntfld.hxx:50
std::unique_ptr< SwTableRep > m_xOrigTableData
Definition: tablepg.hxx:33
std::unique_ptr< weld::RadioButton > m_xPgBrkAfterRB
Definition: tablepg.hxx:151
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: tabledlg.cxx:1077
void set_text(const OUString &rStr)
Definition: prcntfld.hxx:56
std::unique_ptr< weld::CheckButton > m_xPgBrkCB
Definition: tablepg.hxx:147
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: tabledlg.cxx:1308
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
SwTableRep * pTableData
Definition: tablepg.hxx:32
#define FN_TABLE_SET_VERT_ALIGN
Definition: cmdid.h:424
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: tabledlg.cxx:389
std::unique_ptr< weld::RadioButton > m_xCenterBtn
Definition: tablepg.hxx:49
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
std::unique_ptr< weld::RadioButton > m_xRightBtn
Definition: tablepg.hxx:48
const SwTwips lAutoWidth
Definition: tablemgr.hxx:40
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
virtual void Reset(const SfxItemSet *rSet) override
Definition: tabledlg.cxx:434
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: tabledlg.cxx:1314
std::unique_ptr< weld::CheckButton > m_xModifyTableCB
Definition: tablepg.hxx:111
SwTableRep * m_pTableData
Definition: tablepg.hxx:95
ImplSVEvent * m_pSizeHdlEvent
Definition: tablepg.hxx:97
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: tabledlg.cxx:614
sal_uInt16 nPos
void Init(bool bWeb)
Definition: tabledlg.cxx:860
std::unique_ptr< weld::CheckButton > m_xRelWidthCB
Definition: tablepg.hxx:43
SwTwips m_nTableWidth
Definition: tablepg.hxx:98
std::unique_ptr< weld::Button > m_xUpBtn
Definition: tablepg.hxx:116