Revert "tdf#158280 Replace usage of InputDialog with SvxNameDialog"
[LibreOffice.git] / sw / source / ui / table / tabledlg.cxx
blobc2908f22ee59fb0e03cfef6d01d2a927bd562ed6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
26 #include <editeng/formatbreakitem.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>
34 #include <fmtrowsplt.hxx>
35 #include <sfx2/htmlmode.hxx>
36 #include <sfx2/sfxdlg.hxx>
38 #include <strings.hrc>
39 #include <svx/strings.hrc>
40 #include <svx/dialmgr.hxx>
42 #include <wrtsh.hxx>
43 #include <view.hxx>
44 #include <viewopt.hxx>
45 #include <uitool.hxx>
46 #include <tabledlg.hxx>
47 #include "../../uibase/table/tablepg.hxx"
48 #include <tablemgr.hxx>
49 #include <pagedesc.hxx>
50 #include <uiitems.hxx>
51 #include <poolfmt.hxx>
52 #include <swtablerep.hxx>
53 #include <SwStyleNameMapper.hxx>
54 #include <names.hxx>
56 #include <cmdid.h>
57 #include <svx/dialogs.hrc>
58 #include <svx/flagsdef.hxx>
59 #include <osl/diagnose.h>
60 #include <officecfg/Office/Common.hxx>
62 #include <com/sun/star/text/HoriOrientation.hpp>
63 #include <com/sun/star/text/VertOrientation.hpp>
65 using namespace ::com::sun::star;
67 SwFormatTablePage::SwFormatTablePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
68 : SfxTabPage(pPage, pController, u"modules/swriter/ui/formattablepage.ui"_ustr, u"FormatTablePage"_ustr, &rSet)
69 , m_pTableData(nullptr)
70 , m_nSaveWidth(0)
71 , m_nMinTableWidth(MINLAY)
72 , m_bModified(false)
73 , m_bFull(false)
74 , m_bHtmlMode(false)
75 , m_xNameED(m_xBuilder->weld_entry(u"name"_ustr))
76 , m_xWidthFT(m_xBuilder->weld_label(u"widthft"_ustr))
77 , m_xWidthMF(new SwPercentField(m_xBuilder->weld_metric_spin_button(u"widthmf"_ustr, FieldUnit::CM)))
78 , m_xRelWidthCB(m_xBuilder->weld_check_button(u"relwidth"_ustr))
79 , m_xFullBtn(m_xBuilder->weld_radio_button(u"full"_ustr))
80 , m_xLeftBtn(m_xBuilder->weld_radio_button(u"left"_ustr))
81 , m_xFromLeftBtn(m_xBuilder->weld_radio_button(u"fromleft"_ustr))
82 , m_xRightBtn(m_xBuilder->weld_radio_button(u"right"_ustr))
83 , m_xCenterBtn(m_xBuilder->weld_radio_button(u"center"_ustr))
84 , m_xFreeBtn(m_xBuilder->weld_radio_button(u"free"_ustr))
85 , m_xLeftFT(m_xBuilder->weld_label(u"leftft"_ustr))
86 , m_xLeftMF(new SwPercentField(m_xBuilder->weld_metric_spin_button(u"leftmf"_ustr, FieldUnit::CM)))
87 , m_xRightFT(m_xBuilder->weld_label(u"rightft"_ustr))
88 , m_xRightMF(new SwPercentField(m_xBuilder->weld_metric_spin_button(u"rightmf"_ustr, FieldUnit::CM)))
89 , m_xTopFT(m_xBuilder->weld_label(u"aboveft"_ustr))
90 , m_xTopMF(m_xBuilder->weld_metric_spin_button(u"abovemf"_ustr, FieldUnit::CM))
91 , m_xBottomFT(m_xBuilder->weld_label(u"belowft"_ustr))
92 , m_xBottomMF(m_xBuilder->weld_metric_spin_button(u"belowmf"_ustr, FieldUnit::CM))
93 , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box(u"textdirection"_ustr)))
94 , m_xProperties(m_xBuilder->weld_widget(u"properties"_ustr))
96 m_xWidthMF->GetMetricFieldRange(m_nOrigWidthMin, m_nOrigWidthMax);
97 m_xLeftMF->GetMetricFieldRange(m_nOrigLeftMin, m_nOrigLeftMax);
98 m_xRightMF->GetMetricFieldRange(m_nOrigRightMin, m_nOrigRightMax);
100 //lock these to initial sizes so they don't change on percent to non percent change
101 Size aPrefSize(m_xLeftMF->get()->get_preferred_size());
102 m_xLeftMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
103 m_xRightMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
104 m_xWidthMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
106 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
107 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
108 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
110 SetExchangeSupport();
112 if(const SfxUInt16Item* pModeItem = rSet.GetItemIfSet(SID_HTML_MODE, false))
113 m_bHtmlMode = 0 != (pModeItem->GetValue() & HTMLMODE_ON);
115 bool bCTL = SvtCTLOptions::IsCTLFontEnabled();
116 m_xProperties->set_visible(!m_bHtmlMode && bCTL);
118 Init();
121 SwFormatTablePage::~SwFormatTablePage()
125 void SwFormatTablePage::Init()
127 m_xLeftMF->SetMetricFieldMin(-999999);
128 m_xRightMF->SetMetricFieldMin(-999999);
130 //handler
131 Link<weld::Toggleable&,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 );
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);
146 m_xRelWidthCB->connect_toggled(LINK( this, SwFormatTablePage, RelWidthClickHdl ));
149 IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, weld::Toggleable&, rBtn, void )
151 OSL_ENSURE(m_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);
159 if (bIsChecked)
161 m_xWidthMF->SetRefValue(m_pTableData->GetSpace());
162 m_xLeftMF->SetRefValue(m_pTableData->GetSpace());
163 m_xRightMF->SetRefValue(m_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 );
171 else
172 ModifyHdl(*m_xLeftMF->get()); //correct values again
174 if (m_xFreeBtn->get_active())
176 bool bEnable = !rBtn.get_active();
177 m_xRightMF->set_sensitive(bEnable);
178 m_xRightFT->set_sensitive(bEnable);
180 m_bModified = true;
183 IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::Toggleable&, void)
185 bool bRestore = true,
186 bLeftEnable = false,
187 bRightEnable= false,
188 bWidthEnable= false,
189 bOthers = true;
190 if (m_xFullBtn->get_active())
192 m_xLeftMF->set_value(0);
193 m_xRightMF->set_value(0);
194 m_nSaveWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
195 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(m_pTableData->GetSpace()), FieldUnit::TWIP);
196 m_bFull = true;
197 bRestore = false;
199 else if (m_xLeftBtn->get_active())
201 bRightEnable = bWidthEnable = true;
202 m_xLeftMF->set_value(0);
204 else if (m_xFromLeftBtn->get_active())
206 bLeftEnable = bWidthEnable = true;
207 m_xRightMF->set_value(0);
209 else if (m_xRightBtn->get_active())
211 bLeftEnable = bWidthEnable = true;
212 m_xRightMF->set_value(0);
214 else if (m_xCenterBtn->get_active())
216 bLeftEnable = bWidthEnable = true;
218 else if (m_xFreeBtn->get_active())
220 RightModify();
221 bLeftEnable = true;
222 bWidthEnable = true;
223 bOthers = false;
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 )
231 m_xRightMF->set_sensitive(bRightEnable);
232 m_xRightFT->set_sensitive(bRightEnable);
233 m_xRelWidthCB->set_sensitive(bWidthEnable);
236 if(m_bFull && bRestore)
238 //After being switched on automatic, the width was pinned
239 //in order to restore the width while switching back to.
240 m_bFull = false;
241 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(m_nSaveWidth ), FieldUnit::TWIP );
243 ModifyHdl(*m_xWidthMF->get());
244 m_bModified = true;
247 void SwFormatTablePage::RightModify()
249 if (!m_xFreeBtn->get_active())
250 return;
252 bool bEnable = m_xRightMF->get_value() == 0;
253 m_xRelWidthCB->set_sensitive(bEnable);
254 if ( !bEnable )
256 m_xRelWidthCB->set_active(false);
257 RelWidthClickHdl(*m_xRelWidthCB);
259 bEnable = m_xRelWidthCB->get_active();
260 m_xRightMF->set_sensitive(!bEnable);
261 m_xRightFT->set_sensitive(!bEnable);
264 IMPL_LINK( SwFormatTablePage, ValueChangedHdl, weld::MetricSpinButton&, rEdit, void )
266 if (m_xRightMF->get() == &rEdit)
267 RightModify();
268 ModifyHdl(rEdit);
271 void SwFormatTablePage::ModifyHdl(const weld::MetricSpinButton& rEdit, bool bAllowInconsistencies)
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;
279 if (&rEdit == m_xWidthMF->get())
281 if( nCurWidth < MINLAY )
282 nCurWidth = MINLAY;
283 nDiff = nRight + nLeft + nCurWidth - m_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())
293 if( nRight >= nDiff )
294 nRight -= nDiff;
295 else
297 nDiff -= nRight;
298 nRight = 0;
299 if(nLeft >= nDiff)
300 nLeft -= nDiff;
301 else
303 nRight += nLeft - nDiff;
304 nLeft = 0;
305 nCurWidth = m_pTableData->GetSpace();
309 //centered: change both sides equally
310 else if (m_xCenterBtn->get_active())
312 if(nLeft != nRight)
314 nDiff += nLeft + nRight;
315 nLeft = nDiff/2;
316 nRight = nDiff/2;
318 else
320 nLeft -= nDiff/2;
321 nRight -= nDiff/2;
324 //free alignment: decrease both margins
325 else if (m_xFreeBtn->get_active())
327 nLeft -= nDiff/2;
328 nRight -= nDiff/2;
331 if (&rEdit == m_xRightMF->get())
334 if( nRight + nLeft > m_pTableData->GetSpace() - MINLAY )
335 nRight = m_pTableData->GetSpace() -nLeft - MINLAY;
337 nCurWidth = m_pTableData->GetSpace() - nLeft - nRight;
339 if (&rEdit == m_xLeftMF->get())
341 if(!m_xFromLeftBtn->get_active())
343 bool bCenter = m_xCenterBtn->get_active();
344 if( bCenter )
345 nRight = nLeft;
346 if(nRight + nLeft > m_pTableData->GetSpace() - MINLAY )
348 nLeft = bCenter ? (m_pTableData->GetSpace() - MINLAY) /2 :
349 (m_pTableData->GetSpace() - MINLAY) - nRight;
350 nRight = bCenter ? (m_pTableData->GetSpace() - MINLAY) /2 : nRight;
352 nCurWidth = m_pTableData->GetSpace() - nLeft - nRight;
354 else
356 //Upon changes on the left side the right margin will be changed at first,
357 //thereafter the width.
358 nDiff = nRight + nLeft + nCurWidth - m_pTableData->GetSpace() ;
360 nRight -= nDiff;
361 nCurWidth = m_pTableData->GetSpace() - nLeft - nRight;
365 m_xRightMF->set_value( m_xRightMF->NormalizePercent( nRight ), FieldUnit::TWIP );
366 m_xLeftMF->set_value( m_xLeftMF->NormalizePercent( nLeft ), FieldUnit::TWIP );
368 if (nCurWidth != nPrevWidth )
370 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(nCurWidth), FieldUnit::TWIP);
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);
381 m_bModified = true;
384 std::unique_ptr<SfxTabPage> SwFormatTablePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
386 return std::make_unique<SwFormatTablePage>(pPage, pController, *rAttrSet);
389 bool SwFormatTablePage::FillItemSet( SfxItemSet* rCoreSet )
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())
399 ModifyHdl(*m_xTopMF);
400 else if (m_xBottomMF->has_focus())
401 ModifyHdl(*m_xBottomMF);
403 if (m_bModified)
405 if (m_xBottomMF->get_value_changed_from_saved() ||
406 m_xTopMF->get_value_changed_from_saved() )
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);
415 if (m_xNameED->get_value_changed_from_saved())
417 rCoreSet->Put(SfxStringItem(FN_PARAM_TABLE_NAME, m_xNameED->get_text()));
418 m_bModified = true;
421 if (m_xTextDirectionLB->get_visible())
423 if (m_xTextDirectionLB->get_value_changed_from_saved())
425 SvxFrameDirection nDirection = m_xTextDirectionLB->get_active_id();
426 rCoreSet->Put(SvxFrameDirectionItem(nDirection, RES_FRAMEDIR));
427 m_bModified = true;
431 return m_bModified;
434 void SwFormatTablePage::Reset( const SfxItemSet* )
436 const SfxItemSet& rSet = GetItemSet();
438 if(m_bHtmlMode)
440 m_xNameED->set_sensitive(false);
441 m_xTopFT->hide();
442 m_xTopMF->hide();
443 m_xBottomFT->hide();
444 m_xBottomMF->hide();
445 m_xFreeBtn->set_sensitive(false);
448 // set back to original state
449 m_xRelWidthCB->set_active(false);
450 m_xWidthMF->ShowPercent(false);
451 m_xLeftMF->ShowPercent(false);
452 m_xRightMF->ShowPercent(false);
453 m_xWidthMF->SetMetricFieldRange(m_nOrigWidthMin, m_nOrigWidthMax);
454 m_xLeftMF->SetMetricFieldRange(m_nOrigLeftMin, m_nOrigLeftMax);
455 m_xRightMF->SetMetricFieldRange(m_nOrigRightMin, m_nOrigRightMax);
457 FieldUnit aMetric = ::GetDfltMetric(m_bHtmlMode);
458 m_xWidthMF->SetMetric(aMetric);
459 m_xRightMF->SetMetric(aMetric);
460 m_xLeftMF->SetMetric(aMetric);
461 SetFieldUnit(*m_xTopMF, aMetric);
462 SetFieldUnit(*m_xBottomMF, aMetric);
464 //Name
465 if(const SfxStringItem* pNameItem = rSet.GetItemIfSet( FN_PARAM_TABLE_NAME, false ))
467 m_xNameED->set_text(pNameItem->GetValue());
468 m_xNameED->save_value();
471 if(const SwPtrItem* pRepItem = rSet.GetItemIfSet( FN_TABLE_REP, false ))
473 m_pTableData = static_cast<SwTableRep*>( pRepItem->GetValue());
474 if (!m_xOrigTableData)
475 m_xOrigTableData.reset(new SwTableRep(*m_pTableData));
476 else // tdf#134925 and tdf#134913, reset back to the original data seen on dialog creation
477 *m_pTableData = *m_xOrigTableData;
479 m_nMinTableWidth = m_pTableData->GetColCount() * MINLAY;
481 if(m_pTableData->GetWidthPercent())
483 m_xRelWidthCB->set_active(true);
484 RelWidthClickHdl(*m_xRelWidthCB);
485 m_xWidthMF->set_value(m_pTableData->GetWidthPercent(), FieldUnit::PERCENT);
487 m_xWidthMF->save_value();
488 m_nSaveWidth = static_cast< SwTwips >(m_xWidthMF->get_value(FieldUnit::PERCENT));
490 else
492 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
493 m_pTableData->GetWidth()), FieldUnit::TWIP);
494 m_xWidthMF->save_value();
495 m_nSaveWidth = m_pTableData->GetWidth();
496 m_nMinTableWidth = std::min( m_nSaveWidth, m_nMinTableWidth );
499 m_xWidthMF->SetRefValue(m_pTableData->GetSpace());
501 m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
502 m_pTableData->GetLeftSpace()), FieldUnit::TWIP);
503 m_xRightMF->set_value(m_xRightMF->NormalizePercent(
504 m_pTableData->GetRightSpace()), FieldUnit::TWIP);
505 m_xLeftMF->save_value();
506 m_xRightMF->save_value();
508 bool bSetRight = false, bSetLeft = false;
509 switch( m_pTableData->GetAlign() )
511 case text::HoriOrientation::NONE:
512 m_xFreeBtn->set_active(true);
513 if (m_xRelWidthCB->get_active())
514 bSetRight = true;
515 break;
516 case text::HoriOrientation::FULL:
518 bSetRight = bSetLeft = true;
519 m_xFullBtn->set_active(true);
520 m_xWidthMF->set_sensitive(false);
521 m_xRelWidthCB->set_sensitive(false);
522 m_xWidthFT->set_sensitive(false);
524 break;
525 case text::HoriOrientation::LEFT:
527 bSetLeft = true;
528 m_xLeftBtn->set_active(true);
530 break;
531 case text::HoriOrientation::LEFT_AND_WIDTH :
533 bSetRight = true;
534 m_xFromLeftBtn->set_active(true);
536 break;
537 case text::HoriOrientation::RIGHT:
539 bSetRight = true;
540 m_xRightBtn->set_active(true);
542 break;
543 case text::HoriOrientation::CENTER:
545 bSetRight = true;
546 m_xCenterBtn->set_active(true);
548 break;
550 if ( bSetRight )
552 m_xRightMF->set_sensitive(false);
553 m_xRightFT->set_sensitive(false);
555 if ( bSetLeft )
557 m_xLeftMF->set_sensitive(false);
558 m_xLeftFT->set_sensitive(false);
563 //Margins
564 if(const SvxULSpaceItem* pSpaceItem = rSet.GetItemIfSet( RES_UL_SPACE, false ))
566 m_xTopMF->set_value(m_xTopMF->normalize(
567 pSpaceItem->GetUpper()), FieldUnit::TWIP);
568 m_xBottomMF->set_value(m_xBottomMF->normalize(
569 pSpaceItem->GetLower()), FieldUnit::TWIP);
570 m_xTopMF->save_value();
571 m_xBottomMF->save_value();
574 //Text direction
575 if( const SvxFrameDirectionItem* pDirectionItem = rSet.GetItemIfSet( RES_FRAMEDIR ) )
577 SvxFrameDirection nVal = pDirectionItem->GetValue();
578 m_xTextDirectionLB->set_active_id(nVal);
579 m_xTextDirectionLB->save_value();
582 m_xWidthMF->set_max( 2*m_xWidthMF->NormalizePercent( m_pTableData->GetSpace() ), FieldUnit::TWIP );
583 m_xRightMF->set_max( m_xRightMF->NormalizePercent( m_pTableData->GetSpace() ), FieldUnit::TWIP );
584 m_xLeftMF->set_max( m_xLeftMF->NormalizePercent( m_pTableData->GetSpace() ), FieldUnit::TWIP );
585 m_xWidthMF->set_min( m_xWidthMF->NormalizePercent( m_nMinTableWidth ), FieldUnit::TWIP );
588 void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
590 if(SfxItemState::SET != rSet.GetItemState( FN_TABLE_REP ))
591 return;
593 assert(m_pTableData && "table data not available?");
595 SwTwips nCurWidth = text::HoriOrientation::FULL != m_pTableData->GetAlign() ?
596 m_pTableData->GetWidth() :
597 m_pTableData->GetSpace();
598 if(m_pTableData->GetWidthPercent() != 0 ||
599 nCurWidth == m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)))
600 return;
602 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
603 nCurWidth), FieldUnit::TWIP);
604 m_xWidthMF->save_value();
605 m_nSaveWidth = nCurWidth;
606 m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
607 m_pTableData->GetLeftSpace()), FieldUnit::TWIP);
608 m_xLeftMF->save_value();
609 m_xRightMF->set_value(m_xRightMF->NormalizePercent(
610 m_pTableData->GetRightSpace()), FieldUnit::TWIP);
611 m_xRightMF->save_value();
614 DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
616 //test the table name for spaces
617 OUString sTableName = m_xNameED->get_text();
618 if(sTableName.indexOf(' ') != -1)
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;
627 if(_pSet)
629 FillItemSet(_pSet);
630 if(m_bModified)
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)));
635 if( m_xLeftMF->get_value_changed_from_saved() ||
636 m_xRightMF->get_value_changed_from_saved() )
638 m_pTableData->SetWidthChanged();
639 m_pTableData->SetLeftSpace( lLeft);
640 m_pTableData->SetRightSpace( lRight);
643 SwTwips lWidth;
644 if (m_xRelWidthCB->get_active() && m_xRelWidthCB->get_sensitive())
646 lWidth = m_pTableData->GetSpace() - lRight - lLeft;
647 const sal_uInt16 nPercentWidth = m_xWidthMF->get_value(FieldUnit::PERCENT);
648 if(m_pTableData->GetWidthPercent() != nPercentWidth)
650 m_pTableData->SetWidthPercent(nPercentWidth);
651 m_pTableData->SetWidthChanged();
654 else
656 m_pTableData->SetWidthPercent(0);
657 lWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
659 m_pTableData->SetWidth(lWidth);
661 SwTwips nColSum = 0;
663 for( sal_uInt16 i = 0; i < m_pTableData->GetColCount(); i++)
665 nColSum += m_pTableData->GetColumns()[i].nWidth;
667 if(nColSum != m_pTableData->GetWidth())
669 SwTwips nMinWidth = std::min( tools::Long(MINLAY),
670 static_cast<tools::Long>(m_pTableData->GetWidth() /
671 m_pTableData->GetColCount() - 1));
672 SwTwips nDiff = nColSum - m_pTableData->GetWidth();
673 while ( std::abs(nDiff) > m_pTableData->GetColCount() + 1 )
675 SwTwips nSub = nDiff / m_pTableData->GetColCount();
676 for( sal_uInt16 i = 0; i < m_pTableData->GetColCount(); i++)
678 if(m_pTableData->GetColumns()[i].nWidth - nMinWidth > nSub)
680 m_pTableData->GetColumns()[i].nWidth -= nSub;
681 nDiff -= nSub;
683 else
685 nDiff -= m_pTableData->GetColumns()[i].nWidth - nMinWidth;
686 m_pTableData->GetColumns()[i].nWidth = nMinWidth;
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())
703 nAlign = text::HoriOrientation::NONE;
704 else if(m_xFullBtn->get_active())
706 nAlign = text::HoriOrientation::FULL;
707 lWidth = lAutoWidth;
709 if(nAlign != m_pTableData->GetAlign())
711 m_pTableData->SetWidthChanged();
712 m_pTableData->SetAlign(nAlign);
715 if(m_pTableData->GetWidth() != lWidth )
717 m_pTableData->SetWidthChanged();
718 m_pTableData->SetWidth(
719 nAlign == text::HoriOrientation::FULL ? m_pTableData->GetSpace() : lWidth );
721 if(m_pTableData->HasWidthChanged())
722 _pSet->Put(SwPtrItem(FN_TABLE_REP, m_pTableData));
725 return DeactivateRC::LeavePage;
728 //Description: Page column configuration
729 SwTableColumnPage::SwTableColumnPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
730 : SfxTabPage(pPage, pController, u"modules/swriter/ui/tablecolumnpage.ui"_ustr, u"TableColumnPage"_ustr, &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(u"width1"_ustr, FieldUnit::CM),
742 m_xBuilder->weld_metric_spin_button(u"width2"_ustr, FieldUnit::CM),
743 m_xBuilder->weld_metric_spin_button(u"width3"_ustr, FieldUnit::CM),
744 m_xBuilder->weld_metric_spin_button(u"width4"_ustr, FieldUnit::CM),
745 m_xBuilder->weld_metric_spin_button(u"width5"_ustr, FieldUnit::CM)}
746 , m_aTextArr { m_xBuilder->weld_label(u"1"_ustr),
747 m_xBuilder->weld_label(u"2"_ustr),
748 m_xBuilder->weld_label(u"3"_ustr),
749 m_xBuilder->weld_label(u"4"_ustr),
750 m_xBuilder->weld_label(u"5"_ustr)}
751 , m_xColumnWidthsGrid(m_xBuilder->weld_grid(u"columnwidthsgrid"_ustr))
752 , m_xModifyTableCB(m_xBuilder->weld_check_button(u"adaptwidth"_ustr))
753 , m_xProportionalCB(m_xBuilder->weld_check_button(u"adaptcolumns"_ustr))
754 , m_xSpaceFT(m_xBuilder->weld_label(u"spaceft"_ustr))
755 , m_xSpaceSFT(m_xBuilder->weld_label(u"space"_ustr))
756 , m_xSpaceED(m_xBuilder->weld_metric_spin_button(u"spacefmt"_ustr, FieldUnit::CM))
757 , m_xUpBtn(m_xBuilder->weld_button(u"next"_ustr))
758 , m_xDownBtn(m_xBuilder->weld_button(u"back"_ustr))
760 SetExchangeSupport();
762 // fire off this handler to happen on next event loop when all the rest of
763 // the pages are instantiated and the dialog preferred size is that of the
764 // all the pages that currently exist and the rest to come after this one
765 m_pSizeHdlEvent = Application::PostUserEvent(LINK(this, SwTableColumnPage, SizeHdl));
767 const SfxUInt16Item* pModeItem = GetItemSet().GetItemIfSet(SID_HTML_MODE, false);
768 Init(pModeItem && pModeItem->GetValue() & HTMLMODE_ON);
771 IMPL_LINK_NOARG(SwTableColumnPage, SizeHdl, void*, void)
773 m_pSizeHdlEvent = nullptr;
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)
781 m_aFieldArr[i].show();
782 m_aTextArr[i]->show();
784 if (pTopLevel->get_preferred_size().Width() > aOrigSize.Width())
786 m_nMetFields = i + 1;
787 m_xColumnWidthsGrid->set_child_column_span(*m_aTextArr[i], 1);
788 m_xColumnWidthsGrid->set_child_left_attach(*m_xUpBtn, m_nMetFields * 2 - 1);
789 break;
793 // tdf#143142 m_nMetFields has been updated and we need to re-check whether to show right button or not.
794 if (m_nNoOfVisibleCols > m_nMetFields)
796 m_xUpBtn->set_sensitive(true);
801 SwTableColumnPage::~SwTableColumnPage()
803 if (m_pSizeHdlEvent)
805 Application::RemoveUserEvent(m_pSizeHdlEvent);
806 m_pSizeHdlEvent = nullptr;
810 std::unique_ptr<SfxTabPage> SwTableColumnPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
812 return std::make_unique<SwTableColumnPage>(pPage, pController, *rAttrSet);
815 void SwTableColumnPage::Reset( const SfxItemSet* )
817 const SfxItemSet& rSet = GetItemSet();
819 if(const SwPtrItem* pRepItem = rSet.GetItemIfSet( FN_TABLE_REP, false ))
821 m_pTableData = static_cast<SwTableRep*>( pRepItem->GetValue());
822 if (!m_xOrigTableData)
823 m_xOrigTableData.reset(new SwTableRep(*m_pTableData));
824 else // tdf#134925 and tdf#134913, reset back to the original data seen on dialog creation
825 *m_pTableData = *m_xOrigTableData;
827 m_nNoOfVisibleCols = m_pTableData->GetColCount();
828 m_nNoOfCols = m_pTableData->GetAllColCount();
829 m_nTableWidth = m_pTableData->GetAlign() != text::HoriOrientation::FULL &&
830 m_pTableData->GetAlign() != text::HoriOrientation::LEFT_AND_WIDTH?
831 m_pTableData->GetWidth() : m_pTableData->GetSpace();
833 for( sal_uInt16 i = 0; i < m_nNoOfCols; i++ )
835 if (m_pTableData->GetColumns()[i].nWidth < m_nMinWidth)
836 m_nMinWidth = m_pTableData->GetColumns()[i].nWidth;
838 sal_Int64 nMinTwips = m_aFieldArr[0].NormalizePercent( m_nMinWidth );
839 sal_Int64 nMaxTwips = m_aFieldArr[0].NormalizePercent( m_nTableWidth );
840 for( sal_uInt16 i = 0; (i < m_nMetFields) && (i < m_nNoOfVisibleCols); i++ )
842 m_aFieldArr[i].set_value( m_aFieldArr[i].NormalizePercent(
843 GetVisibleWidth(i) ), FieldUnit::TWIP );
844 m_aFieldArr[i].set_min(nMinTwips, FieldUnit::TWIP);
845 m_aFieldArr[i].set_max(nMaxTwips, FieldUnit::TWIP);
846 m_aFieldArr[i].set_sensitive(true);
847 m_aTextArr[i]->set_sensitive(true);
850 if (m_nNoOfVisibleCols > m_nMetFields)
852 m_xUpBtn->set_sensitive(true);
855 for( sal_uInt16 i = m_nNoOfVisibleCols; i < m_nMetFields; ++i )
857 m_aFieldArr[i].set_text(OUString());
858 m_aTextArr[i]->set_sensitive(false);
861 ActivatePage(rSet);
864 void SwTableColumnPage::Init(bool bWeb)
866 FieldUnit aMetric = ::GetDfltMetric(bWeb);
867 Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwTableColumnPage, ValueChangedHdl);
868 for (sal_uInt16 i = 0; i < MET_FIELDS; ++i)
870 m_aValueTable[i] = i;
871 m_aFieldArr[i].SetMetric(aMetric);
872 m_aFieldArr[i].connect_value_changed(aLk);
874 SetFieldUnit(*m_xSpaceED, aMetric);
876 Link<weld::Button&,void> aClickLk = LINK(this, SwTableColumnPage, AutoClickHdl);
877 m_xUpBtn->connect_clicked(aClickLk);
878 m_xDownBtn->connect_clicked(aClickLk);
880 Link<weld::Toggleable&,void> aToggleLk = LINK(this, SwTableColumnPage, ModeHdl);
881 m_xModifyTableCB->connect_toggled(aToggleLk);
882 m_xProportionalCB->connect_toggled(aToggleLk);
885 IMPL_LINK(SwTableColumnPage, AutoClickHdl, weld::Button&, rControl, void)
887 //move display window
888 if (&rControl == m_xDownBtn.get())
890 if(m_aValueTable[0] > 0)
892 for(sal_uInt16 & rn : m_aValueTable)
893 rn -= 1;
896 if (&rControl == m_xUpBtn.get())
898 if( m_aValueTable[ m_nMetFields -1 ] < m_nNoOfVisibleCols -1 )
900 for(sal_uInt16 & rn : m_aValueTable)
901 rn += 1;
904 for( sal_uInt16 i = 0; (i < m_nNoOfVisibleCols ) && ( i < m_nMetFields); i++ )
906 OUString sEntry('~');
907 OUString sIndex = OUString::number( m_aValueTable[i] + 1 );
908 sEntry += sIndex;
909 m_aTextArr[i]->set_label(sEntry);
912 m_xDownBtn->set_sensitive(m_aValueTable[0] > 0);
913 m_xUpBtn->set_sensitive(m_aValueTable[ m_nMetFields -1 ] < m_nNoOfVisibleCols -1 );
914 UpdateCols(0);
917 IMPL_LINK(SwTableColumnPage, ValueChangedHdl, weld::MetricSpinButton&, rEdit, void)
919 m_bModified = true;
920 ModifyHdl(&rEdit);
923 IMPL_LINK(SwTableColumnPage, ModeHdl, weld::Toggleable&, rBox, void)
925 const bool bCheck = rBox.get_active();
926 if (&rBox == m_xProportionalCB.get())
928 if (bCheck)
929 m_xModifyTableCB->set_active(true);
930 m_xModifyTableCB->set_sensitive(!bCheck && m_bModifyTable);
934 bool SwTableColumnPage::FillItemSet( SfxItemSet* )
936 for (SwPercentField & i : m_aFieldArr)
938 if (i.has_focus())
940 ModifyHdl(i.get());
941 break;
945 if (m_bModified)
947 m_pTableData->SetColsChanged();
949 return m_bModified;
952 void SwTableColumnPage::ModifyHdl(const weld::MetricSpinButton* pField)
954 SwPercentField *pEdit = nullptr;
955 sal_uInt16 i;
957 for( i = 0; i < m_nMetFields; i++)
959 if (pField == m_aFieldArr[i].get())
961 pEdit = &m_aFieldArr[i];
962 break;
966 if (m_nMetFields <= i || !pEdit)
968 OSL_ENSURE(false, "cannot happen.");
969 return;
972 SetVisibleWidth(m_aValueTable[i], pEdit->DenormalizePercent(pEdit->get_value(FieldUnit::TWIP)));
974 UpdateCols( m_aValueTable[i] );
977 void SwTableColumnPage::UpdateCols( sal_uInt16 nCurrentPos )
979 SwTwips nSum = 0;
981 for( sal_uInt16 i = 0; i < m_nNoOfCols; i++ )
983 nSum += (m_pTableData->GetColumns())[i].nWidth;
985 SwTwips nDiff = nSum - m_nTableWidth;
987 bool bModifyTableChecked = m_xModifyTableCB->get_active();
988 bool bProp = m_xProportionalCB->get_active();
990 if (!bModifyTableChecked && !bProp)
992 //The table width is constant, the difference is balanced with the other columns
993 sal_uInt16 nLoopCount = 0;
994 while( nDiff )
996 if( ++nCurrentPos == m_nNoOfVisibleCols)
998 nCurrentPos = 0;
999 ++nLoopCount;
1000 //#i101353# in small tables it might not be possible to balance column width
1001 if( nLoopCount > 1 )
1002 break;
1004 if( nDiff < 0 )
1006 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1007 nDiff = 0;
1009 else if( GetVisibleWidth(nCurrentPos) >= nDiff + m_nMinWidth )
1011 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1012 nDiff = 0;
1014 if( nDiff > 0 && GetVisibleWidth(nCurrentPos) > m_nMinWidth )
1016 if( nDiff >= (GetVisibleWidth(nCurrentPos) - m_nMinWidth) )
1018 nDiff -= (GetVisibleWidth(nCurrentPos) - m_nMinWidth);
1019 SetVisibleWidth(nCurrentPos, m_nMinWidth);
1021 else
1023 nDiff = 0;
1024 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1026 OSL_ENSURE(nDiff >= 0, "nDiff < 0 cannot be here!");
1030 else if (bModifyTableChecked && !bProp)
1032 //Difference is balanced by the width of the table,
1033 //other columns remain unchanged.
1034 OSL_ENSURE(nDiff <= m_pTableData->GetSpace() - m_nTableWidth, "wrong maximum" );
1035 SwTwips nActSpace = m_pTableData->GetSpace() - m_nTableWidth;
1036 if(nDiff > nActSpace)
1038 m_nTableWidth = m_pTableData->GetSpace();
1039 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) - nDiff + nActSpace );
1041 else
1043 m_nTableWidth += nDiff;
1046 else if (bModifyTableChecked && bProp)
1048 //All columns will be changed proportionally with,
1049 //the table width is adjusted accordingly.
1050 const double fOrigColWidth = std::max(SwTwips(1), GetVisibleWidth(nCurrentPos) - nDiff);
1051 const double fMaxWidth = std::max(m_pTableData->GetSpace(), m_nTableWidth);
1052 const double fMaxPercent = fMaxWidth / m_nTableWidth;
1053 const double fPercentChange = std::min(fMaxPercent, GetVisibleWidth(nCurrentPos)/fOrigColWidth);
1054 SwTwips nNewTableSize = 0;
1055 for( sal_uInt16 i = 0; i < m_nNoOfVisibleCols; i++ )
1057 SwTwips nNewColWidth = round( fPercentChange * (i == nCurrentPos ? fOrigColWidth : GetVisibleWidth(i)) );
1058 if ( nNewColWidth < MINLAY )
1059 nNewColWidth = MINLAY;
1060 SetVisibleWidth(i, nNewColWidth);
1061 nNewTableSize += nNewColWidth;
1063 m_nTableWidth = nNewTableSize;
1066 if (!m_bPercentMode)
1068 m_xSpaceED->set_value(m_xSpaceED->normalize(m_pTableData->GetSpace() - m_nTableWidth), FieldUnit::TWIP);
1069 m_xSpaceSFT->set_label(m_xSpaceED->get_text());
1071 else
1072 m_xSpaceSFT->set_label(OUString());
1074 for( sal_uInt16 i = 0; ( i < m_nNoOfVisibleCols ) && ( i < m_nMetFields ); i++)
1076 m_aFieldArr[i].set_value(m_aFieldArr[i].NormalizePercent(
1077 GetVisibleWidth(m_aValueTable[i]) ), FieldUnit::TWIP);
1081 void SwTableColumnPage::ActivatePage( const SfxItemSet& )
1083 m_bPercentMode = m_pTableData->GetWidthPercent() != 0;
1084 for( sal_uInt16 i = 0; (i < m_nMetFields) && (i < m_nNoOfVisibleCols); i++ )
1086 m_aFieldArr[i].SetRefValue(m_pTableData->GetWidth());
1087 m_aFieldArr[i].ShowPercent( m_bPercentMode );
1090 const sal_uInt16 nTableAlign = m_pTableData->GetAlign();
1091 if((text::HoriOrientation::FULL != nTableAlign && m_nTableWidth != m_pTableData->GetWidth()) ||
1092 (text::HoriOrientation::FULL == nTableAlign && m_nTableWidth != m_pTableData->GetSpace()))
1094 m_nTableWidth = text::HoriOrientation::FULL == nTableAlign ?
1095 m_pTableData->GetSpace() :
1096 m_pTableData->GetWidth();
1097 UpdateCols(0);
1099 m_bModifyTable = true;
1100 if (m_pTableData->GetWidthPercent() ||
1101 text::HoriOrientation::FULL == nTableAlign ||
1102 m_pTableData->IsLineSelected() )
1103 m_bModifyTable = false;
1104 if (m_bPercentMode)
1106 m_xModifyTableCB->set_active(false);
1107 m_xProportionalCB->set_active(false);
1109 else if (!m_bModifyTable)
1111 m_xProportionalCB->set_active(false);
1112 m_xModifyTableCB->set_active(false);
1114 m_xSpaceFT->set_sensitive(!m_bPercentMode);
1115 m_xSpaceSFT->set_sensitive(!m_bPercentMode);
1116 m_xModifyTableCB->set_sensitive( !m_bPercentMode && m_bModifyTable );
1117 m_xProportionalCB->set_sensitive(!m_bPercentMode && m_bModifyTable );
1119 m_xSpaceED->set_value(m_xSpaceED->normalize(
1120 m_pTableData->GetSpace() - m_nTableWidth), FieldUnit::TWIP);
1121 m_xSpaceSFT->set_label(m_xSpaceED->get_text());
1125 DeactivateRC SwTableColumnPage::DeactivatePage( SfxItemSet* _pSet )
1127 if(_pSet)
1129 FillItemSet(_pSet);
1130 if(text::HoriOrientation::FULL != m_pTableData->GetAlign() && m_pTableData->GetWidth() != m_nTableWidth)
1132 m_pTableData->SetWidth(m_nTableWidth);
1133 SwTwips nDiff = m_pTableData->GetSpace() - m_pTableData->GetWidth() -
1134 m_pTableData->GetLeftSpace() - m_pTableData->GetRightSpace();
1135 switch( m_pTableData->GetAlign() )
1137 case text::HoriOrientation::RIGHT:
1138 m_pTableData->SetLeftSpace(m_pTableData->GetLeftSpace() + nDiff);
1139 break;
1140 case text::HoriOrientation::LEFT:
1141 m_pTableData->SetRightSpace(m_pTableData->GetRightSpace() + nDiff);
1142 break;
1143 case text::HoriOrientation::NONE:
1145 SwTwips nDiff2 = nDiff/2;
1146 if( nDiff > 0 ||
1147 (-nDiff2 < m_pTableData->GetRightSpace() && - nDiff2 < m_pTableData->GetLeftSpace()))
1149 m_pTableData->SetRightSpace(m_pTableData->GetRightSpace() + nDiff2);
1150 m_pTableData->SetLeftSpace(m_pTableData->GetLeftSpace() + nDiff2);
1152 else
1154 if(m_pTableData->GetRightSpace() > m_pTableData->GetLeftSpace())
1156 m_pTableData->SetLeftSpace(0);
1157 m_pTableData->SetRightSpace(m_pTableData->GetSpace() - m_pTableData->GetWidth());
1159 else
1161 m_pTableData->SetRightSpace(0);
1162 m_pTableData->SetLeftSpace(m_pTableData->GetSpace() - m_pTableData->GetWidth());
1166 break;
1167 case text::HoriOrientation::CENTER:
1168 m_pTableData->SetRightSpace(m_pTableData->GetRightSpace() + nDiff/2);
1169 m_pTableData->SetLeftSpace(m_pTableData->GetLeftSpace() + nDiff/2);
1170 break;
1171 case text::HoriOrientation::LEFT_AND_WIDTH :
1172 if(nDiff > m_pTableData->GetRightSpace())
1174 m_pTableData->SetLeftSpace(m_pTableData->GetSpace() - m_pTableData->GetWidth());
1176 m_pTableData->SetRightSpace(
1177 m_pTableData->GetSpace() - m_pTableData->GetWidth() - m_pTableData->GetLeftSpace());
1178 break;
1180 m_pTableData->SetWidthChanged();
1182 _pSet->Put(SwPtrItem( FN_TABLE_REP, m_pTableData ));
1184 return DeactivateRC::LeavePage;
1187 SwTwips SwTableColumnPage::GetVisibleWidth(sal_uInt16 nPos)
1189 sal_uInt16 i=0;
1191 while( nPos )
1193 if(m_pTableData->GetColumns()[i].bVisible)
1194 nPos--;
1195 i++;
1197 SwTwips nReturn = m_pTableData->GetColumns()[i].nWidth;
1198 OSL_ENSURE(i < m_nNoOfCols, "Array index out of range");
1199 while(!m_pTableData->GetColumns()[i].bVisible && (i + 1) < m_nNoOfCols)
1200 nReturn += m_pTableData->GetColumns()[++i].nWidth;
1202 return nReturn;
1205 void SwTableColumnPage::SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth)
1207 sal_uInt16 i=0;
1208 while( nPos )
1210 if(m_pTableData->GetColumns()[i].bVisible)
1211 nPos--;
1212 i++;
1214 OSL_ENSURE(i < m_nNoOfCols, "Array index out of range");
1215 m_pTableData->GetColumns()[i].nWidth = nNewWidth;
1216 while(!m_pTableData->GetColumns()[i].bVisible && (i + 1) < m_nNoOfCols)
1217 m_pTableData->GetColumns()[++i].nWidth = 0;
1221 SwTableTabDlg::SwTableTabDlg(weld::Window* pParent, const SfxItemSet* pItemSet, SwWrtShell* pSh)
1222 : SfxTabDialogController(pParent, u"modules/swriter/ui/tableproperties.ui"_ustr, u"TablePropertiesDialog"_ustr, pItemSet)
1223 , m_pShell(pSh)
1225 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1226 AddTabPage(u"table"_ustr, &SwFormatTablePage::Create, nullptr);
1227 AddTabPage(u"textflow"_ustr, &SwTextFlowPage::Create, nullptr);
1228 AddTabPage(u"columns"_ustr, &SwTableColumnPage::Create, nullptr);
1229 AddTabPage(u"background"_ustr, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1230 AddTabPage(u"borders"_ustr, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BORDER), nullptr);
1233 void SwTableTabDlg::PageCreated(const OUString& rId, SfxTabPage& rPage)
1235 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1236 if (rId == "background")
1238 SvxBackgroundTabFlags const nFlagType = SvxBackgroundTabFlags::SHOW_TBLCTL;
1239 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(nFlagType)));
1240 rPage.PageCreated(aSet);
1242 else if (rId == "borders")
1244 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE, static_cast<sal_uInt16>(SwBorderModes::TABLE)));
1245 rPage.PageCreated(aSet);
1247 else if (rId == "textflow")
1249 static_cast<SwTextFlowPage&>(rPage).SetShell(m_pShell);
1250 const FrameTypeFlags eType = m_pShell->GetFrameType(nullptr,true);
1251 if( !(FrameTypeFlags::BODY & eType) )
1252 static_cast<SwTextFlowPage&>(rPage).DisablePageBreak();
1256 SwTextFlowPage::SwTextFlowPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1257 : SfxTabPage(pPage, pController, u"modules/swriter/ui/tabletextflowpage.ui"_ustr, u"TableTextFlowPage"_ustr, &rSet)
1258 , m_pShell(nullptr)
1259 , m_bPageBreak(true)
1260 , m_bHtmlMode(false)
1261 , m_xPgBrkCB(m_xBuilder->weld_check_button(u"break"_ustr))
1262 , m_xPgBrkRB(m_xBuilder->weld_radio_button(u"page"_ustr))
1263 , m_xColBrkRB(m_xBuilder->weld_radio_button(u"column"_ustr))
1264 , m_xPgBrkBeforeRB(m_xBuilder->weld_radio_button(u"before"_ustr))
1265 , m_xPgBrkAfterRB(m_xBuilder->weld_radio_button(u"after"_ustr))
1266 , m_xPageCollCB(m_xBuilder->weld_check_button(u"pagestyle"_ustr))
1267 , m_xPageCollLB(m_xBuilder->weld_combo_box(u"pagestylelb"_ustr))
1268 , m_xPageNoCB(m_xBuilder->weld_check_button(u"pagenoft"_ustr))
1269 , m_xPageNoNF(m_xBuilder->weld_spin_button(u"pagenonf"_ustr))
1270 , m_xSplitCB(m_xBuilder->weld_check_button(u"split"_ustr))
1271 , m_xSplitRowCB(m_xBuilder->weld_check_button(u"splitrow"_ustr))
1272 , m_xKeepCB(m_xBuilder->weld_check_button(u"keep"_ustr))
1273 , m_xHeadLineCB(m_xBuilder->weld_check_button(u"headline"_ustr))
1274 , m_xRepeatHeaderCombo(m_xBuilder->weld_widget(u"repeatheader"_ustr))
1275 , m_xRepeatHeaderNF(m_xBuilder->weld_spin_button(u"repeatheadernf"_ustr))
1276 , m_xTextDirectionLB(m_xBuilder->weld_combo_box(u"textorientation"_ustr))
1277 , m_xVertOrientLB(m_xBuilder->weld_combo_box(u"vertorient"_ustr))
1279 m_xPgBrkCB->connect_toggled(LINK(this, SwTextFlowPage, PageBreakHdl_Impl));
1280 m_xPgBrkBeforeRB->connect_toggled(
1281 LINK(this, SwTextFlowPage, PageBreakPosHdl_Impl));
1282 m_xPgBrkAfterRB->connect_toggled(
1283 LINK(this, SwTextFlowPage, PageBreakPosHdl_Impl));
1284 m_xPageCollCB->connect_toggled(
1285 LINK(this, SwTextFlowPage, ApplyCollClickHdl_Impl));
1286 m_xColBrkRB->connect_toggled(
1287 LINK(this, SwTextFlowPage, PageBreakTypeHdl_Impl));
1288 m_xPgBrkRB->connect_toggled(
1289 LINK(this, SwTextFlowPage, PageBreakTypeHdl_Impl));
1290 m_xPageNoCB->connect_toggled(
1291 LINK(this, SwTextFlowPage, PageNoClickHdl_Impl));
1292 m_xSplitCB->connect_toggled(
1293 LINK(this, SwTextFlowPage, SplitHdl_Impl));
1294 m_xHeadLineCB->connect_toggled(LINK(this, SwTextFlowPage, HeadLineCBClickHdl));
1296 const SfxUInt16Item *pModeItem = rSet.GetItemIfSet( SID_HTML_MODE, false );
1297 if(pModeItem && pModeItem->GetValue() & HTMLMODE_ON)
1299 m_xKeepCB->hide();
1300 m_xSplitCB->hide();
1301 m_xSplitRowCB->hide();
1304 HeadLineCBClickHdl(*m_xHeadLineCB);
1307 SwTextFlowPage::~SwTextFlowPage()
1311 std::unique_ptr<SfxTabPage> SwTextFlowPage::Create(weld::Container* pPage, weld::DialogController* pController,
1312 const SfxItemSet* rAttrSet)
1314 return std::make_unique<SwTextFlowPage>(pPage, pController, *rAttrSet);
1317 bool SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
1319 bool bModified = false;
1321 //Repeat Heading
1322 if (m_xHeadLineCB->get_state_changed_from_saved() ||
1323 m_xRepeatHeaderNF->get_value_changed_from_saved() )
1325 bModified |= nullptr != rSet->Put(
1326 SfxUInt16Item(FN_PARAM_TABLE_HEADLINE, m_xHeadLineCB->get_active() ? sal_uInt16(m_xRepeatHeaderNF->get_value()) : 0));
1328 if (m_xKeepCB->get_state_changed_from_saved())
1329 bModified |= nullptr != rSet->Put( SvxFormatKeepItem( m_xKeepCB->get_active(), RES_KEEP));
1331 if (m_xSplitCB->get_state_changed_from_saved())
1332 bModified |= nullptr != rSet->Put( SwFormatLayoutSplit( m_xSplitCB->get_active()));
1334 if (m_xSplitRowCB->get_state_changed_from_saved())
1335 bModified |= nullptr != rSet->Put( SwFormatRowSplit( m_xSplitRowCB->get_active()));
1337 const SvxFormatBreakItem* pBreak = GetOldItem( *rSet, RES_BREAK );
1338 const SwFormatPageDesc* pDesc = GetOldItem( *rSet, RES_PAGEDESC );
1340 bool bState = m_xPageCollCB->get_active();
1342 //If we have a page style, then there's no break
1343 bool bPageItemPut = false;
1344 if ( bState != (m_xPageCollCB->get_saved_state() == TRISTATE_TRUE)
1345 || (bState && m_xPageCollLB->get_value_changed_from_saved())
1346 || (m_xPageNoCB->get_sensitive() && m_xPageNoCB->get_state_changed_from_saved())
1347 || (m_xPageNoNF->get_sensitive() && m_xPageNoNF->get_value_changed_from_saved()))
1349 OUString sPage;
1351 if ( bState )
1353 sPage = m_xPageCollLB->get_active_text();
1355 sal_uInt16 nPgNum = o3tl::narrowing<sal_uInt16>(m_xPageNoNF->get_value());
1356 bool const usePageNo(bState && m_xPageNoCB->get_active());
1357 std::optional<sal_uInt16> const oPageNum(
1358 usePageNo ? nPgNum : std::optional<sal_Int16>());
1359 if (!pDesc || !pDesc->GetPageDesc()
1360 || (pDesc->GetPageDesc()->GetName() != sPage)
1361 || (pDesc->GetNumOffset() != oPageNum))
1363 SwFormatPageDesc aFormat( m_pShell->FindPageDescByName( sPage, true ) );
1364 aFormat.SetNumOffset(oPageNum);
1365 bModified |= nullptr != rSet->Put( aFormat );
1366 bPageItemPut = bState;
1369 bool bIsChecked = m_xPgBrkCB->get_active();
1370 if ( !bPageItemPut &&
1371 ( bState != (m_xPageCollCB->get_saved_state() == TRISTATE_TRUE) ||
1372 bIsChecked != (m_xPgBrkCB->get_saved_state() == TRISTATE_TRUE) ||
1373 m_xPgBrkBeforeRB->get_state_changed_from_saved() ||
1374 m_xPgBrkRB->get_state_changed_from_saved() ))
1376 SvxFormatBreakItem aBreak( GetItemSet().Get( RES_BREAK ) );
1378 if(bIsChecked)
1380 bool bBefore = m_xPgBrkBeforeRB->get_active();
1382 if (m_xPgBrkRB->get_active())
1384 if ( bBefore )
1385 aBreak.SetValue( SvxBreak::PageBefore );
1386 else
1387 aBreak.SetValue( SvxBreak::PageAfter );
1389 else
1391 if ( bBefore )
1392 aBreak.SetValue( SvxBreak::ColumnBefore );
1393 else
1394 aBreak.SetValue( SvxBreak::ColumnAfter );
1397 else
1399 aBreak.SetValue( SvxBreak::NONE );
1402 if ( !pBreak || !( *pBreak == aBreak ) )
1404 bModified |= nullptr != rSet->Put( aBreak );
1408 if (m_xTextDirectionLB->get_value_changed_from_saved())
1410 OUString sId = m_xTextDirectionLB->get_active_id();
1411 bModified |= nullptr != rSet->Put(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(sId.toUInt32()), FN_TABLE_BOX_TEXTORIENTATION));
1414 if (m_xVertOrientLB->get_value_changed_from_saved())
1416 sal_uInt16 nOrient = USHRT_MAX;
1417 switch (m_xVertOrientLB->get_active())
1419 case 0 : nOrient = text::VertOrientation::NONE; break;
1420 case 1 : nOrient = text::VertOrientation::CENTER; break;
1421 case 2 : nOrient = text::VertOrientation::BOTTOM; break;
1423 if (nOrient != USHRT_MAX)
1424 bModified |= nullptr != rSet->Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, nOrient));
1427 return bModified;
1431 void SwTextFlowPage::Reset( const SfxItemSet* rSet )
1433 bool bFlowAllowed = !m_bHtmlMode || officecfg::Office::Common::Filter::HTML::Export::PrintLayout::get();
1434 if(bFlowAllowed)
1436 //Inserting of the existing page templates in the list box
1437 const size_t nCount = m_pShell->GetPageDescCnt();
1439 for( size_t i = 0; i < nCount; ++i)
1441 const SwPageDesc &rPageDesc = m_pShell->GetPageDesc(i);
1442 m_xPageCollLB->append_text(rPageDesc.GetName());
1445 OUString aFormatName;
1446 for (sal_uInt16 i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i)
1448 aFormatName = SwStyleNameMapper::GetUIName(i, ProgName());
1449 if (m_xPageCollLB->find_text(aFormatName) == -1)
1450 m_xPageCollLB->append_text(aFormatName);
1453 if(const SvxFormatKeepItem* pKeepItem = rSet->GetItemIfSet( RES_KEEP, false ))
1455 m_xKeepCB->set_active( pKeepItem->GetValue() );
1456 m_xKeepCB->save_state();
1458 if(const SwFormatLayoutSplit* pSplitItem = rSet->GetItemIfSet( RES_LAYOUT_SPLIT, false ))
1460 m_xSplitCB->set_active( pSplitItem->GetValue() );
1462 else
1463 m_xSplitCB->set_active(true);
1465 m_xSplitCB->save_state();
1466 SplitHdl_Impl(*m_xSplitCB);
1468 if(const SwFormatRowSplit* pSplitItem = rSet->GetItemIfSet( RES_ROW_SPLIT, false ))
1470 m_xSplitRowCB->set_active( pSplitItem->GetValue() );
1472 else
1473 m_xSplitRowCB->set_state(TRISTATE_INDET);
1474 m_xSplitRowCB->save_state();
1476 if(m_bPageBreak)
1478 if(const SwFormatPageDesc* pPageDescItem = rSet->GetItemIfSet( RES_PAGEDESC, false ))
1480 OUString sPageDesc;
1481 const SwPageDesc* pDesc = pPageDescItem->GetPageDesc();
1483 ::std::optional<sal_uInt16> oNumOffset = pPageDescItem->GetNumOffset();
1484 if (oNumOffset)
1486 m_xPageNoCB->set_active(true);
1487 m_xPageNoNF->set_sensitive(true);
1488 m_xPageNoNF->set_value(*oNumOffset);
1490 else
1492 m_xPageNoCB->set_active(false);
1493 m_xPageNoNF->set_sensitive(false);
1496 if(pDesc)
1497 sPageDesc = pDesc->GetName();
1498 if (!sPageDesc.isEmpty() && m_xPageCollLB->find_text(sPageDesc) != -1)
1500 m_xPageCollLB->set_active_text(sPageDesc);
1501 m_xPageCollCB->set_active(true);
1503 m_xPgBrkCB->set_sensitive(true);
1504 m_xPgBrkRB->set_sensitive(true);
1505 m_xColBrkRB->set_sensitive(true);
1506 m_xPgBrkBeforeRB->set_sensitive(true);
1507 m_xPgBrkAfterRB->set_sensitive(true);
1508 m_xPageCollCB->set_sensitive(true);
1510 m_xPgBrkCB->set_active(true);
1511 m_xColBrkRB->set_active( false );
1512 m_xPgBrkBeforeRB->set_active(true);
1513 m_xPgBrkAfterRB->set_active( false );
1515 else
1517 m_xPageCollLB->set_active(-1);
1518 m_xPageCollCB->set_active(false);
1522 if(const SvxFormatBreakItem* pPageBreak = rSet->GetItemIfSet( RES_BREAK, false ))
1524 SvxBreak eBreak = pPageBreak->GetBreak();
1526 if ( eBreak != SvxBreak::NONE )
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);
1534 switch ( eBreak )
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
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);
1571 else
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);
1584 if(const SfxUInt16Item* pHeadlineItem = rSet->GetItemIfSet( FN_PARAM_TABLE_HEADLINE, false ))
1586 sal_uInt16 nRep = pHeadlineItem->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();
1593 if ( rSet->GetItemState(FN_TABLE_BOX_TEXTORIENTATION) > SfxItemState::DEFAULT )
1595 SvxFrameDirection nDirection = rSet->Get(FN_TABLE_BOX_TEXTORIENTATION).GetValue();
1596 m_xTextDirectionLB->set_active_id(OUString::number(static_cast<sal_uInt32>(nDirection)));
1599 if ( rSet->GetItemState(FN_TABLE_SET_VERT_ALIGN) > SfxItemState::DEFAULT )
1601 sal_uInt16 nVert = rSet->Get(FN_TABLE_SET_VERT_ALIGN).GetValue();
1602 sal_uInt16 nPos = 0;
1603 switch(nVert)
1605 case text::VertOrientation::NONE: nPos = 0; break;
1606 case text::VertOrientation::CENTER: nPos = 1; break;
1607 case text::VertOrientation::BOTTOM: nPos = 2; break;
1609 m_xVertOrientLB->set_active(nPos);
1612 m_xPageCollCB->save_state();
1613 m_xPageCollLB->save_value();
1614 m_xPgBrkCB->save_state();
1615 m_xPgBrkRB->save_state();
1616 m_xColBrkRB->save_state();
1617 m_xPgBrkBeforeRB->save_state();
1618 m_xPgBrkAfterRB->save_state();
1619 m_xPageNoCB->save_state();
1620 m_xPageNoNF->save_value();
1621 m_xTextDirectionLB->save_value();
1622 m_xVertOrientLB->save_value();
1624 HeadLineCBClickHdl(*m_xHeadLineCB);
1627 void SwTextFlowPage::SetShell(SwWrtShell* pSh)
1629 m_pShell = pSh;
1630 m_bHtmlMode = 0 != (::GetHtmlMode(m_pShell->GetView().GetDocShell()) & HTMLMODE_ON);
1631 if(m_bHtmlMode)
1633 m_xPageNoNF->set_sensitive(false);
1634 m_xPageNoCB->set_sensitive(false);
1638 IMPL_LINK_NOARG(SwTextFlowPage, PageBreakHdl_Impl, weld::Toggleable&, void)
1640 if (m_xPgBrkCB->get_active())
1642 m_xPgBrkRB->set_sensitive(true);
1643 m_xColBrkRB->set_sensitive(true);
1644 m_xPgBrkBeforeRB->set_sensitive(true);
1645 m_xPgBrkAfterRB->set_sensitive(true);
1647 if (m_xPgBrkRB->get_active() && m_xPgBrkBeforeRB->get_active())
1649 m_xPageCollCB->set_sensitive(true);
1651 bool bEnable = m_xPageCollCB->get_active() && m_xPageCollLB->get_count();
1652 m_xPageCollLB->set_sensitive(bEnable);
1653 if (!m_bHtmlMode)
1655 m_xPageNoCB->set_sensitive(bEnable);
1656 m_xPageNoNF->set_sensitive(bEnable && m_xPageNoCB->get_active());
1660 else
1662 m_xPageCollCB->set_active(false);
1663 m_xPageCollCB->set_sensitive(false);
1664 m_xPageCollLB->set_sensitive(false);
1665 m_xPageNoCB->set_sensitive(false);
1666 m_xPageNoNF->set_sensitive(false);
1667 m_xPgBrkRB->set_sensitive(false);
1668 m_xColBrkRB->set_sensitive(false);
1669 m_xPgBrkBeforeRB->set_sensitive(false);
1670 m_xPgBrkAfterRB->set_sensitive(false);
1674 IMPL_LINK_NOARG(SwTextFlowPage, ApplyCollClickHdl_Impl, weld::Toggleable&, void)
1676 bool bEnable = false;
1677 if (m_xPageCollCB->get_active() && m_xPageCollLB->get_count())
1679 bEnable = true;
1680 m_xPageCollLB->set_active(0);
1682 else
1684 m_xPageCollLB->set_active(-1);
1686 m_xPageCollLB->set_sensitive(bEnable);
1687 if (!m_bHtmlMode)
1689 m_xPageNoCB->set_sensitive(bEnable);
1690 m_xPageNoNF->set_sensitive(bEnable && m_xPageNoCB->get_active());
1694 IMPL_LINK_NOARG(SwTextFlowPage, PageBreakPosHdl_Impl, weld::Toggleable&, void)
1696 if (!m_xPgBrkCB->get_active())
1697 return;
1699 if (m_xPgBrkBeforeRB->get_active() && m_xPgBrkRB->get_active())
1701 m_xPageCollCB->set_sensitive(true);
1703 bool bEnable = m_xPageCollCB->get_active() && m_xPageCollLB->get_count();
1705 m_xPageCollLB->set_sensitive(bEnable);
1706 if (!m_bHtmlMode)
1708 m_xPageNoCB->set_sensitive(bEnable);
1709 m_xPageNoNF->set_sensitive(bEnable && m_xPageNoCB->get_active());
1712 else if (m_xPgBrkAfterRB->get_active())
1714 m_xPageCollCB->set_active(false);
1715 m_xPageCollCB->set_sensitive(false);
1716 m_xPageCollLB->set_sensitive(false);
1717 m_xPageNoCB->set_sensitive(false);
1718 m_xPageNoNF->set_sensitive(false);
1722 IMPL_LINK_NOARG(SwTextFlowPage, PageBreakTypeHdl_Impl, weld::Toggleable&, void)
1724 if (m_xColBrkRB->get_active() || m_xPgBrkAfterRB->get_active())
1726 m_xPageCollCB->set_active(false);
1727 m_xPageCollCB->set_sensitive(false);
1728 m_xPageCollLB->set_sensitive(false);
1729 m_xPageNoCB->set_sensitive(false);
1730 m_xPageNoNF->set_sensitive(false);
1732 else if (m_xPgBrkBeforeRB->get_active())
1733 PageBreakPosHdl_Impl(*m_xPgBrkBeforeRB);
1736 IMPL_LINK_NOARG(SwTextFlowPage, PageNoClickHdl_Impl, weld::Toggleable&, void)
1738 m_xPageNoNF->set_sensitive(m_xPageNoCB->get_active());
1741 IMPL_LINK(SwTextFlowPage, SplitHdl_Impl, weld::Toggleable&, rBox, void)
1743 m_xSplitRowCB->set_sensitive(rBox.get_active());
1746 IMPL_LINK_NOARG(SwTextFlowPage, HeadLineCBClickHdl, weld::Toggleable&, void)
1748 m_xRepeatHeaderCombo->set_sensitive(m_xHeadLineCB->get_active());
1751 void SwTextFlowPage::DisablePageBreak()
1753 m_bPageBreak = false;
1754 m_xPgBrkCB->set_sensitive(false);
1755 m_xPgBrkRB->set_sensitive(false);
1756 m_xColBrkRB->set_sensitive(false);
1757 m_xPgBrkBeforeRB->set_sensitive(false);
1758 m_xPgBrkAfterRB->set_sensitive(false);
1759 m_xPageCollCB->set_sensitive(false);
1760 m_xPageCollLB->set_sensitive(false);
1761 m_xPageNoCB->set_sensitive(false);
1762 m_xPageNoNF->set_sensitive(false);
1765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */