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