Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx
Warning:line 669, column 78
Division by zero

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name tabledlg.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sw/inc -I /home/maarten/src/libreoffice/core/sw/source/uibase/inc -I /home/maarten/src/libreoffice/core/sw/source/ui/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sw/sdi -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/oovbaapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx

/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx

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>
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>
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
63using namespace ::com::sun::star;
64
65SwFormatTablePage::SwFormatTablePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
66 : SfxTabPage(pPage, pController, "modules/swriter/ui/formattablepage.ui", "FormatTablePage", &rSet)
67 , pTableData(nullptr)
68 , nSaveWidth(0)
69 , nMinTableWidth(MINLAY23)
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_LTRreinterpret_cast<char const *>("RID_SVXSTR_FRAMEDIR_LTR"
"\004" u8"Left-to-right (LTR)")
));
105 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTLreinterpret_cast<char const *>("RID_SVXSTR_FRAMEDIR_RTL"
"\004" u8"Right-to-left (RTL)")
));
106 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPERreinterpret_cast<char const *>("RID_SVXSTR_FRAMEDIR_SUPER"
"\004" u8"Use superordinate object settings")
));
107
108 SetExchangeSupport();
109
110 const SfxPoolItem* pItem;
111 if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE(10000 + 414), false, &pItem))
112 bHtmlMode = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
113
114 bool bCTL = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetCTLOptions().IsCTLFontEnabled();
115 m_xProperties->set_visible(!bHtmlMode && bCTL);
116
117 Init();
118}
119
120SwFormatTablePage::~SwFormatTablePage()
121{
122}
123
124void SwFormatTablePage::Init()
125{
126 m_xLeftMF->SetMetricFieldMin(-999999);
127 m_xRightMF->SetMetricFieldMin(-999999);
128
129 //handler
130 Link<weld::ToggleButton&,void> aLk2 = LINK( this, SwFormatTablePage, AutoClickHdl )::tools::detail::makeLink( ::tools::detail::castTo<SwFormatTablePage
*>(this), &SwFormatTablePage::LinkStubAutoClickHdl)
;
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)::tools::detail::makeLink( ::tools::detail::castTo<SwFormatTablePage
*>(this), &SwFormatTablePage::LinkStubValueChangedHdl
)
;
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 )::tools::detail::makeLink( ::tools::detail::castTo<SwFormatTablePage
*>(this), &SwFormatTablePage::LinkStubRelWidthClickHdl
)
);
146}
147
148IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, weld::ToggleButton&, rBtn, void )void SwFormatTablePage::LinkStubRelWidthClickHdl(void * instance
, weld::ToggleButton& data) { return static_cast<SwFormatTablePage
*>(instance)->RelWidthClickHdl(data); } void SwFormatTablePage
::RelWidthClickHdl(weld::ToggleButton& rBtn)
149{
150 OSL_ENSURE(pTableData, "table data not available?")do { if (true && (!(pTableData))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "150" ": "), "%s", "table data not available?"); } } while
(false)
;
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
182IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::ToggleButton&, void)void SwFormatTablePage::LinkStubAutoClickHdl(void * instance,
weld::ToggleButton& data) { return static_cast<SwFormatTablePage
*>(instance)->AutoClickHdl(data); } void SwFormatTablePage
::AutoClickHdl(__attribute__ ((unused)) weld::ToggleButton&
)
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
246void SwFormatTablePage::RightModify()
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
263IMPL_LINK( SwFormatTablePage, ValueChangedHdl, weld::MetricSpinButton&, rEdit, void )void SwFormatTablePage::LinkStubValueChangedHdl(void * instance
, weld::MetricSpinButton& data) { return static_cast<SwFormatTablePage
*>(instance)->ValueChangedHdl(data); } void SwFormatTablePage
::ValueChangedHdl(weld::MetricSpinButton& rEdit)
264{
265 if (m_xRightMF->get() == &rEdit)
266 RightModify();
267 ModifyHdl(rEdit);
268}
269
270void SwFormatTablePage::ModifyHdl(const weld::MetricSpinButton& rEdit, bool bAllowInconsistencies)
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 < MINLAY23 )
281 nCurWidth = MINLAY23;
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() - MINLAY23 )
334 nRight = pTableData->GetSpace() -nLeft - MINLAY23;
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() - MINLAY23 )
346 {
347 nLeft = bCenter ? (pTableData->GetSpace() - MINLAY23) /2 :
348 (pTableData->GetSpace() - MINLAY23) - nRight;
349 nRight = bCenter ? (pTableData->GetSpace() - MINLAY23) /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 // But (tdf#135693) only make one effort of rectifying the inconsistency
376 if (&rEdit == m_xWidthMF->get() && !bAllowInconsistencies)
377 ModifyHdl(rEdit, true);
378 }
379
380 bModified = true;
381}
382
383std::unique_ptr<SfxTabPage> SwFormatTablePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
384{
385 return std::make_unique<SwFormatTablePage>(pPage, pController, *rAttrSet);
386}
387
388bool SwFormatTablePage::FillItemSet( SfxItemSet* rCoreSet )
389{
390 //Test if one of the controls still has the focus
391 if (m_xWidthMF->has_focus())
392 ModifyHdl(*m_xWidthMF->get());
393 else if (m_xLeftMF->has_focus())
394 ModifyHdl(*m_xLeftMF->get());
395 else if (m_xRightMF->has_focus())
396 ModifyHdl(*m_xRightMF->get());
397 else if (m_xTopMF->has_focus())
398 ModifyHdl(*m_xTopMF);
399 else if (m_xBottomMF->has_focus())
400 ModifyHdl(*m_xBottomMF);
401
402 if (bModified)
403 {
404 if (m_xBottomMF->get_value_changed_from_saved() ||
405 m_xTopMF->get_value_changed_from_saved() )
406 {
407 SvxULSpaceItem aULSpace(RES_UL_SPACE);
408 aULSpace.SetUpper(m_xTopMF->denormalize(m_xTopMF->get_value(FieldUnit::TWIP)));
409 aULSpace.SetLower(m_xBottomMF->denormalize(m_xBottomMF->get_value(FieldUnit::TWIP)));
410 rCoreSet->Put(aULSpace);
411 }
412
413 }
414 if (m_xNameED->get_value_changed_from_saved())
415 {
416 rCoreSet->Put(SfxStringItem(FN_PARAM_TABLE_NAME((20000 + 1100)+44), m_xNameED->get_text()));
417 bModified = true;
418 }
419
420 if (m_xTextDirectionLB->get_visible())
421 {
422 if (m_xTextDirectionLB->get_value_changed_from_saved())
423 {
424 SvxFrameDirection nDirection = m_xTextDirectionLB->get_active_id();
425 rCoreSet->Put(SvxFrameDirectionItem(nDirection, RES_FRAMEDIR));
426 bModified = true;
427 }
428 }
429
430 return bModified;
431}
432
433void SwFormatTablePage::Reset( const SfxItemSet* )
434{
435 const SfxItemSet& rSet = GetItemSet();
436 const SfxPoolItem* pItem;
437
438 if(bHtmlMode)
439 {
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);
446 }
447
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);
456
457 FieldUnit aMetric = ::GetDfltMetric(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);
463
464 //Name
465 if(SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_NAME((20000 + 1100)+44), false, &pItem ))
466 {
467 m_xNameED->set_text(static_cast<const SfxStringItem*>(pItem)->GetValue());
468 m_xNameED->save_value();
469 }
470
471 if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP((20000 + 400) + 99), false, &pItem ))
472 {
473 pTableData = static_cast<SwTableRep*>(static_cast<const SwPtrItem*>( pItem)->GetValue());
474 if (!m_xOrigTableData)
475 m_xOrigTableData.reset(new SwTableRep(*pTableData));
476 else // tdf#134925 and tdf#134913, reset back to the original data seen on dialog creation
477 *pTableData = *m_xOrigTableData;
478
479 nMinTableWidth = pTableData->GetColCount() * MINLAY23;
480
481 if(pTableData->GetWidthPercent())
482 {
483 m_xRelWidthCB->set_active(true);
484 RelWidthClickHdl(*m_xRelWidthCB);
485 m_xWidthMF->set_value(pTableData->GetWidthPercent(), FieldUnit::PERCENT);
486
487 m_xWidthMF->save_value();
488 nSaveWidth = static_cast< SwTwips >(m_xWidthMF->get_value(FieldUnit::PERCENT));
489 }
490 else
491 {
492 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
493 pTableData->GetWidth()), FieldUnit::TWIP);
494 m_xWidthMF->save_value();
495 nSaveWidth = pTableData->GetWidth();
496 nMinTableWidth = std::min( nSaveWidth, nMinTableWidth );
497 }
498
499 m_xWidthMF->SetRefValue(pTableData->GetSpace());
500
501 m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
502 pTableData->GetLeftSpace()), FieldUnit::TWIP);
503 m_xRightMF->set_value(m_xRightMF->NormalizePercent(
504 pTableData->GetRightSpace()), FieldUnit::TWIP);
505 m_xLeftMF->save_value();
506 m_xRightMF->save_value();
507
508 bool bSetRight = false, bSetLeft = false;
509 switch( pTableData->GetAlign() )
510 {
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:
517 {
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);
523 }
524 break;
525 case text::HoriOrientation::LEFT:
526 {
527 bSetLeft = true;
528 m_xLeftBtn->set_active(true);
529 }
530 break;
531 case text::HoriOrientation::LEFT_AND_WIDTH :
532 {
533 bSetRight = true;
534 m_xFromLeftBtn->set_active(true);
535 }
536 break;
537 case text::HoriOrientation::RIGHT:
538 {
539 bSetRight = true;
540 m_xRightBtn->set_active(true);
541 }
542 break;
543 case text::HoriOrientation::CENTER:
544 {
545 bSetRight = true;
546 m_xCenterBtn->set_active(true);
547 }
548 break;
549 }
550 if ( bSetRight )
551 {
552 m_xRightMF->set_sensitive(false);
553 m_xRightFT->set_sensitive(false);
554 }
555 if ( bSetLeft )
556 {
557 m_xLeftMF->set_sensitive(false);
558 m_xLeftFT->set_sensitive(false);
559 }
560
561 }
562
563 //Margins
564 if(SfxItemState::SET == rSet.GetItemState( RES_UL_SPACE, false,&pItem ))
565 {
566 m_xTopMF->set_value(m_xTopMF->normalize(
567 static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()), FieldUnit::TWIP);
568 m_xBottomMF->set_value(m_xBottomMF->normalize(
569 static_cast<const SvxULSpaceItem*>(pItem)->GetLower()), FieldUnit::TWIP);
570 m_xTopMF->save_value();
571 m_xBottomMF->save_value();
572 }
573
574 //Text direction
575 if( SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, true, &pItem ) )
576 {
577 SvxFrameDirection nVal = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
578 m_xTextDirectionLB->set_active_id(nVal);
579 m_xTextDirectionLB->save_value();
580 }
581
582 m_xWidthMF->set_max( 2*m_xWidthMF->NormalizePercent( pTableData->GetSpace() ), FieldUnit::TWIP );
583 m_xRightMF->set_max( m_xRightMF->NormalizePercent( pTableData->GetSpace() ), FieldUnit::TWIP );
584 m_xLeftMF->set_max( m_xLeftMF->NormalizePercent( pTableData->GetSpace() ), FieldUnit::TWIP );
585 m_xWidthMF->set_min( m_xWidthMF->NormalizePercent( nMinTableWidth ), FieldUnit::TWIP );
586}
587
588void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
589{
590 OSL_ENSURE(pTableData, "table data not available?")do { if (true && (!(pTableData))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "590" ": "), "%s", "table data not available?"); } } while
(false)
;
591 if(SfxItemState::SET != rSet.GetItemState( FN_TABLE_REP((20000 + 400) + 99) ))
592 return;
593
594 SwTwips nCurWidth = text::HoriOrientation::FULL != pTableData->GetAlign() ?
595 pTableData->GetWidth() :
596 pTableData->GetSpace();
597 if(pTableData->GetWidthPercent() != 0 ||
598 nCurWidth == m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)))
599 return;
600
601 m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
602 nCurWidth), FieldUnit::TWIP);
603 m_xWidthMF->save_value();
604 nSaveWidth = nCurWidth;
605 m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
606 pTableData->GetLeftSpace()), FieldUnit::TWIP);
607 m_xLeftMF->save_value();
608 m_xRightMF->set_value(m_xRightMF->NormalizePercent(
609 pTableData->GetRightSpace()), FieldUnit::TWIP);
610 m_xRightMF->save_value();
611}
612
613DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
614{
615 //test the table name for spaces
616 OUString sTableName = m_xNameED->get_text();
617 if(sTableName.indexOf(' ') != -1)
1
Assuming the condition is false
2
Taking false branch
618 {
619 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
620 VclMessageType::Info, VclButtonsType::Ok,
621 SwResId(STR_WRONG_TABLENAMEreinterpret_cast<char const *>("STR_WRONG_TABLENAME" "\004"
u8"The name of the table must not contain spaces.")
)));
622 xInfoBox->run();
623 m_xNameED->grab_focus();
624 return DeactivateRC::KeepPage;
625 }
626 if(_pSet)
3
Assuming '_pSet' is non-null
4
Taking true branch
627 {
628 FillItemSet(_pSet);
629 if(bModified)
5
Assuming field 'bModified' is true
6
Taking true branch
630 {
631 SwTwips lLeft = static_cast< SwTwips >(m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FieldUnit::TWIP)));
632 SwTwips lRight = static_cast< SwTwips >(m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FieldUnit::TWIP)));
633
634 if( m_xLeftMF->get_value_changed_from_saved() ||
635 m_xRightMF->get_value_changed_from_saved() )
636 {
637 pTableData->SetWidthChanged();
638 pTableData->SetLeftSpace( lLeft);
639 pTableData->SetRightSpace( lRight);
640 }
641
642 SwTwips lWidth;
643 if (m_xRelWidthCB->get_active() && m_xRelWidthCB->get_sensitive())
7
Assuming the condition is false
644 {
645 lWidth = pTableData->GetSpace() - lRight - lLeft;
646 const sal_uInt16 nPercentWidth = m_xWidthMF->get_value(FieldUnit::PERCENT);
647 if(pTableData->GetWidthPercent() != nPercentWidth)
648 {
649 pTableData->SetWidthPercent(nPercentWidth);
650 pTableData->SetWidthChanged();
651 }
652 }
653 else
654 {
655 pTableData->SetWidthPercent(0);
656 lWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
657 }
658 pTableData->SetWidth(lWidth);
659
660 SwTwips nColSum = 0;
661
662 for( sal_uInt16 i = 0; i < pTableData->GetColCount(); i++)
8
Assuming the condition is false
9
Loop condition is false. Execution continues on line 666
663 {
664 nColSum += pTableData->GetColumns()[i].nWidth;
665 }
666 if(nColSum != pTableData->GetWidth())
10
Assuming the condition is true
11
Taking true branch
667 {
668 SwTwips nMinWidth = std::min( long(MINLAY23),
669 static_cast<long>(pTableData->GetWidth() /
15
Division by zero
670 pTableData->GetColCount() - 1));
12
Calling 'SwTableRep::GetColCount'
14
Returning from 'SwTableRep::GetColCount'
671 SwTwips nDiff = nColSum - pTableData->GetWidth();
672 while ( std::abs(nDiff) > pTableData->GetColCount() + 1 )
673 {
674 SwTwips nSub = nDiff / pTableData->GetColCount();
675 for( sal_uInt16 i = 0; i < pTableData->GetColCount(); i++)
676 {
677 if(pTableData->GetColumns()[i].nWidth - nMinWidth > nSub)
678 {
679 pTableData->GetColumns()[i].nWidth -= nSub;
680 nDiff -= nSub;
681 }
682 else
683 {
684 nDiff -= pTableData->GetColumns()[i].nWidth - nMinWidth;
685 pTableData->GetColumns()[i].nWidth = nMinWidth;
686 }
687
688 }
689 }
690 }
691
692 sal_Int16 nAlign = 0;
693 if (m_xRightBtn->get_active())
694 nAlign = text::HoriOrientation::RIGHT;
695 else if(m_xLeftBtn->get_active())
696 nAlign = text::HoriOrientation::LEFT;
697 else if(m_xFromLeftBtn->get_active())
698 nAlign = text::HoriOrientation::LEFT_AND_WIDTH;
699 else if(m_xCenterBtn->get_active())
700 nAlign = text::HoriOrientation::CENTER;
701 else if(m_xFreeBtn->get_active())
702 nAlign = text::HoriOrientation::NONE;
703 else if(m_xFullBtn->get_active())
704 {
705 nAlign = text::HoriOrientation::FULL;
706 lWidth = lAutoWidth;
707 }
708 if(nAlign != pTableData->GetAlign())
709 {
710 pTableData->SetWidthChanged();
711 pTableData->SetAlign(nAlign);
712 }
713
714 if(pTableData->GetWidth() != lWidth )
715 {
716 pTableData->SetWidthChanged();
717 pTableData->SetWidth(
718 nAlign == text::HoriOrientation::FULL ? pTableData->GetSpace() : lWidth );
719 }
720 if(pTableData->HasWidthChanged())
721 _pSet->Put(SwPtrItem(FN_TABLE_REP((20000 + 400) + 99), pTableData));
722 }
723 }
724 return DeactivateRC::LeavePage;
725}
726
727//Description: Page column configuration
728SwTableColumnPage::SwTableColumnPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
729 : SfxTabPage(pPage, pController, "modules/swriter/ui/tablecolumnpage.ui", "TableColumnPage", &rSet)
730 , m_pTableData(nullptr)
731 , m_pSizeHdlEvent(nullptr)
732 , m_nTableWidth(0)
733 , m_nMinWidth(MINLAY23)
734 , m_nMetFields(MET_FIELDS6)
735 , m_nNoOfCols(0)
736 , m_nNoOfVisibleCols(0)
737 , m_bModified(false)
738 , m_bModifyTable(false)
739 , m_bPercentMode(false)
740 , m_aFieldArr { m_xBuilder->weld_metric_spin_button("width1", FieldUnit::CM),
741 m_xBuilder->weld_metric_spin_button("width2", FieldUnit::CM),
742 m_xBuilder->weld_metric_spin_button("width3", FieldUnit::CM),
743 m_xBuilder->weld_metric_spin_button("width4", FieldUnit::CM),
744 m_xBuilder->weld_metric_spin_button("width5", FieldUnit::CM),
745 m_xBuilder->weld_metric_spin_button("width6", FieldUnit::CM) }
746 , m_aTextArr { m_xBuilder->weld_label("1"),
747 m_xBuilder->weld_label("2"),
748 m_xBuilder->weld_label("3"),
749 m_xBuilder->weld_label("4"),
750 m_xBuilder->weld_label("5"),
751 m_xBuilder->weld_label("6") }
752 , m_xModifyTableCB(m_xBuilder->weld_check_button("adaptwidth"))
753 , m_xProportionalCB(m_xBuilder->weld_check_button("adaptcolumns"))
754 , m_xSpaceFT(m_xBuilder->weld_label("spaceft"))
755 , m_xSpaceSFT(m_xBuilder->weld_label("space"))
756 , m_xSpaceED(m_xBuilder->weld_metric_spin_button("spacefmt", FieldUnit::CM))
757 , m_xUpBtn(m_xBuilder->weld_button("next"))
758 , m_xDownBtn(m_xBuilder->weld_button("back"))
759{
760 SetExchangeSupport();
761
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)::tools::detail::makeLink( ::tools::detail::castTo<SwTableColumnPage
*>(this), &SwTableColumnPage::LinkStubSizeHdl)
);
766
767 const SfxPoolItem* pItem;
768 Init(SfxItemState::SET == GetItemSet().GetItemState(SID_HTML_MODE(10000 + 414), false, &pItem)
769 && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
770}
771
772IMPL_LINK_NOARG(SwTableColumnPage, SizeHdl, void*, void)void SwTableColumnPage::LinkStubSizeHdl(void * instance, void
* data) { return static_cast<SwTableColumnPage *>(instance
)->SizeHdl(data); } void SwTableColumnPage::SizeHdl(__attribute__
((unused)) void*)
773{
774 m_pSizeHdlEvent = nullptr;
775
776 //tdf#120420 keeping showing column width fields unless
777 //the dialog begins to grow, then stop adding them
778 weld::Window* pTopLevel = GetFrameWeld();
779 Size aOrigSize = pTopLevel->get_preferred_size();
780 for (sal_uInt16 i = 0; i < MET_FIELDS6; ++i)
781 {
782 m_aFieldArr[i].show();
783 m_aTextArr[i]->show();
784
785 if (pTopLevel->get_preferred_size().Width() > aOrigSize.Width())
786 {
787 m_nMetFields = i + 1;
788 m_aTextArr[i]->set_grid_width(1);
789 m_xUpBtn->set_grid_left_attach(m_nMetFields * 2 - 1);
790 break;
791 }
792 }
793}
794
795SwTableColumnPage::~SwTableColumnPage()
796{
797 if (m_pSizeHdlEvent)
798 {
799 Application::RemoveUserEvent(m_pSizeHdlEvent);
800 m_pSizeHdlEvent = nullptr;
801 }
802}
803
804std::unique_ptr<SfxTabPage> SwTableColumnPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
805{
806 return std::make_unique<SwTableColumnPage>(pPage, pController, *rAttrSet);
807}
808
809void SwTableColumnPage::Reset( const SfxItemSet* )
810{
811 const SfxItemSet& rSet = GetItemSet();
812
813 const SfxPoolItem* pItem;
814 if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP((20000 + 400) + 99), false, &pItem ))
815 {
816 m_pTableData = static_cast<SwTableRep*>(static_cast<const SwPtrItem*>( pItem)->GetValue());
817 if (!m_xOrigTableData)
818 m_xOrigTableData.reset(new SwTableRep(*m_pTableData));
819 else // tdf#134925 and tdf#134913, reset back to the original data seen on dialog creation
820 *m_pTableData = *m_xOrigTableData;
821
822 m_nNoOfVisibleCols = m_pTableData->GetColCount();
823 m_nNoOfCols = m_pTableData->GetAllColCount();
824 m_nTableWidth = m_pTableData->GetAlign() != text::HoriOrientation::FULL &&
825 m_pTableData->GetAlign() != text::HoriOrientation::LEFT_AND_WIDTH?
826 m_pTableData->GetWidth() : m_pTableData->GetSpace();
827
828 for( sal_uInt16 i = 0; i < m_nNoOfCols; i++ )
829 {
830 if (m_pTableData->GetColumns()[i].nWidth < m_nMinWidth)
831 m_nMinWidth = m_pTableData->GetColumns()[i].nWidth;
832 }
833 sal_Int64 nMinTwips = m_aFieldArr[0].NormalizePercent( m_nMinWidth );
834 sal_Int64 nMaxTwips = m_aFieldArr[0].NormalizePercent( m_nTableWidth );
835 for( sal_uInt16 i = 0; (i < m_nMetFields) && (i < m_nNoOfVisibleCols); i++ )
836 {
837 m_aFieldArr[i].set_value( m_aFieldArr[i].NormalizePercent(
838 GetVisibleWidth(i) ), FieldUnit::TWIP );
839 m_aFieldArr[i].set_min(nMinTwips, FieldUnit::TWIP);
840 m_aFieldArr[i].set_max(nMaxTwips, FieldUnit::TWIP);
841 m_aFieldArr[i].set_sensitive(true);
842 m_aTextArr[i]->set_sensitive(true);
843 }
844
845 if (m_nNoOfVisibleCols > m_nMetFields)
846 {
847 m_xUpBtn->set_sensitive(true);
848 }
849
850 for( sal_uInt16 i = m_nNoOfVisibleCols; i < m_nMetFields; ++i )
851 {
852 m_aFieldArr[i].set_text(OUString());
853 m_aTextArr[i]->set_sensitive(false);
854 }
855 }
856 ActivatePage(rSet);
857}
858
859void SwTableColumnPage::Init(bool bWeb)
860{
861 FieldUnit aMetric = ::GetDfltMetric(bWeb);
862 Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwTableColumnPage, ValueChangedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwTableColumnPage
*>(this), &SwTableColumnPage::LinkStubValueChangedHdl
)
;
863 for (sal_uInt16 i = 0; i < MET_FIELDS6; ++i)
864 {
865 m_aValueTable[i] = i;
866 m_aFieldArr[i].SetMetric(aMetric);
867 m_aFieldArr[i].connect_value_changed(aLk);
868 }
869 SetFieldUnit(*m_xSpaceED, aMetric);
870
871 Link<weld::Button&,void> aClickLk = LINK(this, SwTableColumnPage, AutoClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwTableColumnPage
*>(this), &SwTableColumnPage::LinkStubAutoClickHdl)
;
872 m_xUpBtn->connect_clicked(aClickLk);
873 m_xDownBtn->connect_clicked(aClickLk);
874
875 Link<weld::ToggleButton&,void> aToggleLk = LINK(this, SwTableColumnPage, ModeHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwTableColumnPage
*>(this), &SwTableColumnPage::LinkStubModeHdl)
;
876 m_xModifyTableCB->connect_toggled(aToggleLk);
877 m_xProportionalCB->connect_toggled(aToggleLk);
878}
879
880IMPL_LINK(SwTableColumnPage, AutoClickHdl, weld::Button&, rControl, void)void SwTableColumnPage::LinkStubAutoClickHdl(void * instance,
weld::Button& data) { return static_cast<SwTableColumnPage
*>(instance)->AutoClickHdl(data); } void SwTableColumnPage
::AutoClickHdl(weld::Button& rControl)
881{
882 //move display window
883 if (&rControl == m_xDownBtn.get())
884 {
885 if(m_aValueTable[0] > 0)
886 {
887 for(sal_uInt16 & rn : m_aValueTable)
888 rn -= 1;
889 }
890 }
891 if (&rControl == m_xUpBtn.get())
892 {
893 if( m_aValueTable[ m_nMetFields -1 ] < m_nNoOfVisibleCols -1 )
894 {
895 for(sal_uInt16 & rn : m_aValueTable)
896 rn += 1;
897 }
898 }
899 for( sal_uInt16 i = 0; (i < m_nNoOfVisibleCols ) && ( i < m_nMetFields); i++ )
900 {
901 OUString sEntry('~');
902 OUString sIndex = OUString::number( m_aValueTable[i] + 1 );
903 sEntry += sIndex;
904 m_aTextArr[i]->set_label(sEntry);
905 }
906
907 m_xDownBtn->set_sensitive(m_aValueTable[0] > 0);
908 m_xUpBtn->set_sensitive(m_aValueTable[ m_nMetFields -1 ] < m_nNoOfVisibleCols -1 );
909 UpdateCols(0);
910}
911
912IMPL_LINK(SwTableColumnPage, ValueChangedHdl, weld::MetricSpinButton&, rEdit, void)void SwTableColumnPage::LinkStubValueChangedHdl(void * instance
, weld::MetricSpinButton& data) { return static_cast<SwTableColumnPage
*>(instance)->ValueChangedHdl(data); } void SwTableColumnPage
::ValueChangedHdl(weld::MetricSpinButton& rEdit)
913{
914 m_bModified = true;
915 ModifyHdl(&rEdit);
916}
917
918IMPL_LINK(SwTableColumnPage, ModeHdl, weld::ToggleButton&, rBox, void)void SwTableColumnPage::LinkStubModeHdl(void * instance, weld
::ToggleButton& data) { return static_cast<SwTableColumnPage
*>(instance)->ModeHdl(data); } void SwTableColumnPage::
ModeHdl(weld::ToggleButton& rBox)
919{
920 const bool bCheck = rBox.get_active();
921 if (&rBox == m_xProportionalCB.get())
922 {
923 if (bCheck)
924 m_xModifyTableCB->set_active(true);
925 m_xModifyTableCB->set_sensitive(!bCheck && m_bModifyTable);
926 }
927}
928
929bool SwTableColumnPage::FillItemSet( SfxItemSet* )
930{
931 for (SwPercentField & i : m_aFieldArr)
932 {
933 if (i.has_focus())
934 {
935 ModifyHdl(i.get());
936 break;
937 }
938 }
939
940 if (m_bModified)
941 {
942 m_pTableData->SetColsChanged();
943 }
944 return m_bModified;
945}
946
947void SwTableColumnPage::ModifyHdl(const weld::MetricSpinButton* pField)
948{
949 SwPercentField *pEdit = nullptr;
950 sal_uInt16 i;
951
952 for( i = 0; i < m_nMetFields; i++)
953 {
954 if (pField == m_aFieldArr[i].get())
955 {
956 pEdit = &m_aFieldArr[i];
957 break;
958 }
959 }
960
961 if (m_nMetFields <= i || !pEdit)
962 {
963 OSL_ENSURE(false, "cannot happen.")do { if (true && (!(false))) { sal_detail_logFormat((
SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "963" ": "), "%s", "cannot happen."); } } while (false)
;
964 return;
965 }
966
967 SetVisibleWidth(m_aValueTable[i], pEdit->DenormalizePercent(pEdit->get_value(FieldUnit::TWIP)));
968
969 UpdateCols( m_aValueTable[i] );
970}
971
972void SwTableColumnPage::UpdateCols( sal_uInt16 nCurrentPos )
973{
974 SwTwips nSum = 0;
975
976 for( sal_uInt16 i = 0; i < m_nNoOfCols; i++ )
977 {
978 nSum += (m_pTableData->GetColumns())[i].nWidth;
979 }
980 SwTwips nDiff = nSum - m_nTableWidth;
981
982 bool bModifyTableChecked = m_xModifyTableCB->get_active();
983 bool bProp = m_xProportionalCB->get_active();
984
985 if (!bModifyTableChecked && !bProp)
986 {
987 //The table width is constant, the difference is balanced with the other columns
988 sal_uInt16 nLoopCount = 0;
989 while( nDiff )
990 {
991 if( ++nCurrentPos == m_nNoOfVisibleCols)
992 {
993 nCurrentPos = 0;
994 ++nLoopCount;
995 //#i101353# in small tables it might not be possible to balance column width
996 if( nLoopCount > 1 )
997 break;
998 }
999 if( nDiff < 0 )
1000 {
1001 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1002 nDiff = 0;
1003 }
1004 else if( GetVisibleWidth(nCurrentPos) >= nDiff + m_nMinWidth )
1005 {
1006 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1007 nDiff = 0;
1008 }
1009 if( nDiff > 0 && GetVisibleWidth(nCurrentPos) > m_nMinWidth )
1010 {
1011 if( nDiff >= (GetVisibleWidth(nCurrentPos) - m_nMinWidth) )
1012 {
1013 nDiff -= (GetVisibleWidth(nCurrentPos) - m_nMinWidth);
1014 SetVisibleWidth(nCurrentPos, m_nMinWidth);
1015 }
1016 else
1017 {
1018 nDiff = 0;
1019 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) -nDiff);
1020 }
1021 OSL_ENSURE(nDiff >= 0, "nDiff < 0 cannot be here!")do { if (true && (!(nDiff >= 0))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "1021" ": "), "%s", "nDiff < 0 cannot be here!"); } }
while (false)
;
1022 }
1023 }
1024 }
1025 else if (bModifyTableChecked && !bProp)
1026 {
1027 //Difference is balanced by the width of the table,
1028 //other columns remain unchanged.
1029 OSL_ENSURE(nDiff <= m_pTableData->GetSpace() - m_nTableWidth, "wrong maximum" )do { if (true && (!(nDiff <= m_pTableData->GetSpace
() - m_nTableWidth))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "1029" ": "), "%s", "wrong maximum"); } } while (false)
;
1030 SwTwips nActSpace = m_pTableData->GetSpace() - m_nTableWidth;
1031 if(nDiff > nActSpace)
1032 {
1033 m_nTableWidth = m_pTableData->GetSpace();
1034 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) - nDiff + nActSpace );
1035 }
1036 else
1037 {
1038 m_nTableWidth += nDiff;
1039 }
1040 }
1041 else if (bModifyTableChecked && bProp)
1042 {
1043 //All columns will be changed proportionally with,
1044 //the table width is adjusted accordingly.
1045 OSL_ENSURE(nDiff * m_nNoOfVisibleCols <= m_pTableData->GetSpace() - m_nTableWidth, "wrong maximum" )do { if (true && (!(nDiff * m_nNoOfVisibleCols <= m_pTableData
->GetSpace() - m_nTableWidth))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "1045" ": "), "%s", "wrong maximum"); } } while (false)
;
1046 long nAdd = nDiff;
1047 if(nDiff * m_nNoOfVisibleCols > m_pTableData->GetSpace() - m_nTableWidth)
1048 {
1049 nAdd = (m_pTableData->GetSpace() - m_nTableWidth) / m_nNoOfVisibleCols;
1050 SetVisibleWidth(nCurrentPos, GetVisibleWidth(nCurrentPos) - nDiff + nAdd );
1051 nDiff = nAdd;
1052 }
1053 if(nAdd)
1054 for( sal_uInt16 i = 0; i < m_nNoOfVisibleCols; i++ )
1055 {
1056 if(i == nCurrentPos)
1057 continue;
1058 SwTwips nVisWidth;
1059 if((nVisWidth = GetVisibleWidth(i)) + nDiff < MINLAY23)
1060 {
1061 nAdd += nVisWidth - MINLAY23;
1062 SetVisibleWidth(i, MINLAY23);
1063 }
1064 else
1065 {
1066 SetVisibleWidth(i, nVisWidth + nDiff);
1067 nAdd += nDiff;
1068 }
1069
1070 }
1071 m_nTableWidth += nAdd;
1072 }
1073
1074 if (!m_bPercentMode)
1075 {
1076 m_xSpaceED->set_value(m_xSpaceED->normalize(m_pTableData->GetSpace() - m_nTableWidth), FieldUnit::TWIP);
1077 m_xSpaceSFT->set_label(m_xSpaceED->get_text());
1078 }
1079 else
1080 m_xSpaceSFT->set_label(OUString());
1081
1082 for( sal_uInt16 i = 0; ( i < m_nNoOfVisibleCols ) && ( i < m_nMetFields ); i++)
1083 {
1084 m_aFieldArr[i].set_value(m_aFieldArr[i].NormalizePercent(
1085 GetVisibleWidth(m_aValueTable[i]) ), FieldUnit::TWIP);
1086 }
1087}
1088
1089void SwTableColumnPage::ActivatePage( const SfxItemSet& )
1090{
1091 m_bPercentMode = m_pTableData->GetWidthPercent() != 0;
1092 for( sal_uInt16 i = 0; (i < m_nMetFields) && (i < m_nNoOfVisibleCols); i++ )
1093 {
1094 m_aFieldArr[i].SetRefValue(m_pTableData->GetWidth());
1095 m_aFieldArr[i].ShowPercent( m_bPercentMode );
1096 }
1097
1098 const sal_uInt16 nTableAlign = m_pTableData->GetAlign();
1099 if((text::HoriOrientation::FULL != nTableAlign && m_nTableWidth != m_pTableData->GetWidth()) ||
1100 (text::HoriOrientation::FULL == nTableAlign && m_nTableWidth != m_pTableData->GetSpace()))
1101 {
1102 m_nTableWidth = text::HoriOrientation::FULL == nTableAlign ?
1103 m_pTableData->GetSpace() :
1104 m_pTableData->GetWidth();
1105 UpdateCols(0);
1106 }
1107 m_bModifyTable = true;
1108 if (m_pTableData->GetWidthPercent() ||
1109 text::HoriOrientation::FULL == nTableAlign ||
1110 m_pTableData->IsLineSelected() )
1111 m_bModifyTable = false;
1112 if (m_bPercentMode)
1113 {
1114 m_xModifyTableCB->set_active(false);
1115 m_xProportionalCB->set_active(false);
1116 }
1117 else if (!m_bModifyTable)
1118 {
1119 m_xProportionalCB->set_active(false);
1120 m_xModifyTableCB->set_active(false);
1121 }
1122 m_xSpaceFT->set_sensitive(!m_bPercentMode);
1123 m_xSpaceSFT->set_sensitive(!m_bPercentMode);
1124 m_xModifyTableCB->set_sensitive( !m_bPercentMode && m_bModifyTable );
1125 m_xProportionalCB->set_sensitive(!m_bPercentMode && m_bModifyTable );
1126
1127 m_xSpaceED->set_value(m_xSpaceED->normalize(
1128 m_pTableData->GetSpace() - m_nTableWidth), FieldUnit::TWIP);
1129 m_xSpaceSFT->set_label(m_xSpaceED->get_text());
1130
1131}
1132
1133DeactivateRC SwTableColumnPage::DeactivatePage( SfxItemSet* _pSet )
1134{
1135 if(_pSet)
1136 {
1137 FillItemSet(_pSet);
1138 if(text::HoriOrientation::FULL != m_pTableData->GetAlign() && m_pTableData->GetWidth() != m_nTableWidth)
1139 {
1140 m_pTableData->SetWidth(m_nTableWidth);
1141 SwTwips nDiff = m_pTableData->GetSpace() - m_pTableData->GetWidth() -
1142 m_pTableData->GetLeftSpace() - m_pTableData->GetRightSpace();
1143 switch( m_pTableData->GetAlign() )
1144 {
1145 case text::HoriOrientation::RIGHT:
1146 m_pTableData->SetLeftSpace(m_pTableData->GetLeftSpace() + nDiff);
1147 break;
1148 case text::HoriOrientation::LEFT:
1149 m_pTableData->SetRightSpace(m_pTableData->GetRightSpace() + nDiff);
1150 break;
1151 case text::HoriOrientation::NONE:
1152 {
1153 SwTwips nDiff2 = nDiff/2;
1154 if( nDiff > 0 ||
1155 (-nDiff2 < m_pTableData->GetRightSpace() && - nDiff2 < m_pTableData->GetLeftSpace()))
1156 {
1157 m_pTableData->SetRightSpace(m_pTableData->GetRightSpace() + nDiff2);
1158 m_pTableData->SetLeftSpace(m_pTableData->GetLeftSpace() + nDiff2);
1159 }
1160 else
1161 {
1162 if(m_pTableData->GetRightSpace() > m_pTableData->GetLeftSpace())
1163 {
1164 m_pTableData->SetLeftSpace(0);
1165 m_pTableData->SetRightSpace(m_pTableData->GetSpace() - m_pTableData->GetWidth());
1166 }
1167 else
1168 {
1169 m_pTableData->SetRightSpace(0);
1170 m_pTableData->SetLeftSpace(m_pTableData->GetSpace() - m_pTableData->GetWidth());
1171 }
1172 }
1173 }
1174 break;
1175 case text::HoriOrientation::CENTER:
1176 m_pTableData->SetRightSpace(m_pTableData->GetRightSpace() + nDiff/2);
1177 m_pTableData->SetLeftSpace(m_pTableData->GetLeftSpace() + nDiff/2);
1178 break;
1179 case text::HoriOrientation::LEFT_AND_WIDTH :
1180 if(nDiff > m_pTableData->GetRightSpace())
1181 {
1182 m_pTableData->SetLeftSpace(m_pTableData->GetSpace() - m_pTableData->GetWidth());
1183 }
1184 m_pTableData->SetRightSpace(
1185 m_pTableData->GetSpace() - m_pTableData->GetWidth() - m_pTableData->GetLeftSpace());
1186 break;
1187 }
1188 m_pTableData->SetWidthChanged();
1189 }
1190 _pSet->Put(SwPtrItem( FN_TABLE_REP((20000 + 400) + 99), m_pTableData ));
1191 }
1192 return DeactivateRC::LeavePage;
1193}
1194
1195SwTwips SwTableColumnPage::GetVisibleWidth(sal_uInt16 nPos)
1196{
1197 sal_uInt16 i=0;
1198
1199 while( nPos )
1200 {
1201 if(m_pTableData->GetColumns()[i].bVisible)
1202 nPos--;
1203 i++;
1204 }
1205 SwTwips nReturn = m_pTableData->GetColumns()[i].nWidth;
1206 OSL_ENSURE(i < m_nNoOfCols, "Array index out of range")do { if (true && (!(i < m_nNoOfCols))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "1206" ": "), "%s", "Array index out of range"); } } while
(false)
;
1207 while(!m_pTableData->GetColumns()[i].bVisible && (i + 1) < m_nNoOfCols)
1208 nReturn += m_pTableData->GetColumns()[++i].nWidth;
1209
1210 return nReturn;
1211}
1212
1213void SwTableColumnPage::SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth)
1214{
1215 sal_uInt16 i=0;
1216 while( nPos )
1217 {
1218 if(m_pTableData->GetColumns()[i].bVisible)
1219 nPos--;
1220 i++;
1221 }
1222 OSL_ENSURE(i < m_nNoOfCols, "Array index out of range")do { if (true && (!(i < m_nNoOfCols))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/ui/table/tabledlg.cxx"
":" "1222" ": "), "%s", "Array index out of range"); } } while
(false)
;
1223 m_pTableData->GetColumns()[i].nWidth = nNewWidth;
1224 while(!m_pTableData->GetColumns()[i].bVisible && (i + 1) < m_nNoOfCols)
1225 m_pTableData->GetColumns()[++i].nWidth = 0;
1226
1227}
1228
1229SwTableTabDlg::SwTableTabDlg(weld::Window* pParent, const SfxItemSet* pItemSet, SwWrtShell* pSh)
1230 : SfxTabDialogController(pParent, "modules/swriter/ui/tableproperties.ui", "TablePropertiesDialog", pItemSet)
1231 , pShell(pSh)
1232{
1233 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1234 AddTabPage("table", &SwFormatTablePage::Create, nullptr);
1235 AddTabPage("textflow", &SwTextFlowPage::Create, nullptr);
1236 AddTabPage("columns", &SwTableColumnPage::Create, nullptr);
1237 AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG((10000) + 57)), nullptr);
1238 AddTabPage("borders", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BORDER((10000) + 5)), nullptr);
1239}
1240
1241void SwTableTabDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
1242{
1243 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1244 if (rId == "background")
1245 {
1246 SvxBackgroundTabFlags const nFlagType = SvxBackgroundTabFlags::SHOW_TBLCTL;
1247 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE( 10000 + 1034 ), static_cast<sal_uInt32>(nFlagType)));
1248 rPage.PageCreated(aSet);
1249 }
1250 else if (rId == "borders")
1251 {
1252 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE( 10000 + 1035 ), static_cast<sal_uInt16>(SwBorderModes::TABLE)));
1253 rPage.PageCreated(aSet);
1254 }
1255 else if (rId == "textflow")
1256 {
1257 static_cast<SwTextFlowPage&>(rPage).SetShell(pShell);
1258 const FrameTypeFlags eType = pShell->GetFrameType(nullptr,true);
1259 if( !(FrameTypeFlags::BODY & eType) )
1260 static_cast<SwTextFlowPage&>(rPage).DisablePageBreak();
1261 }
1262}
1263
1264SwTextFlowPage::SwTextFlowPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1265 : SfxTabPage(pPage, pController, "modules/swriter/ui/tabletextflowpage.ui", "TableTextFlowPage", &rSet)
1266 , pShell(nullptr)
1267 , bPageBreak(true)
1268 , bHtmlMode(false)
1269 , m_xPgBrkCB(m_xBuilder->weld_check_button("break"))
1270 , m_xPgBrkRB(m_xBuilder->weld_radio_button("page"))
1271 , m_xColBrkRB(m_xBuilder->weld_radio_button("column"))
1272 , m_xPgBrkBeforeRB(m_xBuilder->weld_radio_button("before"))
1273 , m_xPgBrkAfterRB(m_xBuilder->weld_radio_button("after"))
1274 , m_xPageCollCB(m_xBuilder->weld_check_button("pagestyle"))
1275 , m_xPageCollLB(m_xBuilder->weld_combo_box("pagestylelb"))
1276 , m_xPageNoCB(m_xBuilder->weld_check_button("pagenoft"))
1277 , m_xPageNoNF(m_xBuilder->weld_spin_button("pagenonf"))
1278 , m_xSplitCB(m_xBuilder->weld_check_button("split"))
1279 , m_xSplitRowCB(m_xBuilder->weld_check_button("splitrow"))
1280 , m_xKeepCB(m_xBuilder->weld_check_button("keep"))
1281 , m_xHeadLineCB(m_xBuilder->weld_check_button("headline"))
1282 , m_xRepeatHeaderCombo(m_xBuilder->weld_widget("repeatheader"))
1283 , m_xRepeatHeaderNF(m_xBuilder->weld_spin_button("repeatheadernf"))
1284 , m_xTextDirectionLB(m_xBuilder->weld_combo_box("textorientation"))
1285 , m_xVertOrientLB(m_xBuilder->weld_combo_box("vertorient"))
1286{
1287 m_xPgBrkCB->connect_toggled(LINK(this, SwTextFlowPage, PageBreakHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubPageBreakHdl_Impl)
);
1288 m_xPgBrkBeforeRB->connect_toggled(
1289 LINK(this, SwTextFlowPage, PageBreakPosHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubPageBreakPosHdl_Impl
)
);
1290 m_xPgBrkAfterRB->connect_toggled(
1291 LINK(this, SwTextFlowPage, PageBreakPosHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubPageBreakPosHdl_Impl
)
);
1292 m_xPageCollCB->connect_toggled(
1293 LINK(this, SwTextFlowPage, ApplyCollClickHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubApplyCollClickHdl_Impl
)
);
1294 m_xColBrkRB->connect_toggled(
1295 LINK(this, SwTextFlowPage, PageBreakTypeHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubPageBreakTypeHdl_Impl
)
);
1296 m_xPgBrkRB->connect_toggled(
1297 LINK(this, SwTextFlowPage, PageBreakTypeHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubPageBreakTypeHdl_Impl
)
);
1298 m_xPageNoCB->connect_toggled(
1299 LINK(this, SwTextFlowPage, PageNoClickHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubPageNoClickHdl_Impl
)
);
1300 m_xSplitCB->connect_toggled(
1301 LINK(this, SwTextFlowPage, SplitHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubSplitHdl_Impl)
);
1302 m_xHeadLineCB->connect_toggled(LINK(this, SwTextFlowPage, HeadLineCBClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwTextFlowPage
*>(this), &SwTextFlowPage::LinkStubHeadLineCBClickHdl
)
);
1303
1304 const SfxPoolItem *pItem;
1305 if(SfxItemState::SET == rSet.GetItemState( SID_HTML_MODE(10000 + 414), false,&pItem )
1306 && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
1307 {
1308 m_xKeepCB->hide();
1309 m_xSplitCB->hide();
1310 m_xSplitRowCB->hide();
1311 }
1312
1313 HeadLineCBClickHdl(*m_xHeadLineCB);
1314}
1315
1316SwTextFlowPage::~SwTextFlowPage()
1317{
1318}
1319
1320std::unique_ptr<SfxTabPage> SwTextFlowPage::Create(weld::Container* pPage, weld::DialogController* pController,
1321 const SfxItemSet* rAttrSet)
1322{
1323 return std::make_unique<SwTextFlowPage>(pPage, pController, *rAttrSet);
1324}
1325
1326bool SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
1327{
1328 bool bModified = false;
1329
1330 //Repeat Heading
1331 if (m_xHeadLineCB->get_state_changed_from_saved() ||
1332 m_xRepeatHeaderNF->get_value_changed_from_saved() )
1333 {
1334 bModified |= nullptr != rSet->Put(
1335 SfxUInt16Item(FN_PARAM_TABLE_HEADLINE((20000 + 1100)+50), m_xHeadLineCB->get_active() ? sal_uInt16(m_xRepeatHeaderNF->get_value()) : 0));
1336 }
1337 if (m_xKeepCB->get_state_changed_from_saved())
1338 bModified |= nullptr != rSet->Put( SvxFormatKeepItem( m_xKeepCB->get_active(), RES_KEEP));
1339
1340 if (m_xSplitCB->get_state_changed_from_saved())
1341 bModified |= nullptr != rSet->Put( SwFormatLayoutSplit( m_xSplitCB->get_active()));
1342
1343 if (m_xSplitRowCB->get_state_changed_from_saved())
1344 bModified |= nullptr != rSet->Put( SwFormatRowSplit( m_xSplitRowCB->get_active()));
1345
1346 const SvxFormatBreakItem* pBreak = GetOldItem( *rSet, RES_BREAK );
1347 const SwFormatPageDesc* pDesc = GetOldItem( *rSet, RES_PAGEDESC );
1348
1349 bool bState = m_xPageCollCB->get_active();
1350
1351 //If we have a page style, then there's no break
1352 bool bPageItemPut = false;
1353 if ( bState != (m_xPageCollCB->get_saved_state() == TRISTATE_TRUE)
1354 || (bState && m_xPageCollLB->get_value_changed_from_saved())
1355 || (m_xPageNoCB->get_sensitive() && m_xPageNoCB->get_state_changed_from_saved())
1356 || (m_xPageNoNF->get_sensitive() && m_xPageNoNF->get_value_changed_from_saved()))
1357 {
1358 OUString sPage;
1359
1360 if ( bState )
1361 {
1362 sPage = m_xPageCollLB->get_active_text();
1363 }
1364 sal_uInt16 nPgNum = static_cast<sal_uInt16>(m_xPageNoNF->get_value());
1365 bool const usePageNo(bState && m_xPageNoCB->get_active());
1366 std::optional<sal_uInt16> const oPageNum(
1367 usePageNo ? nPgNum : std::optional<sal_Int16>());
1368 if (!pDesc || !pDesc->GetPageDesc()
1369 || (pDesc->GetPageDesc()->GetName() != sPage)
1370 || (pDesc->GetNumOffset() != oPageNum))
1371 {
1372 SwFormatPageDesc aFormat( pShell->FindPageDescByName( sPage, true ) );
1373 aFormat.SetNumOffset(oPageNum);
1374 bModified |= nullptr != rSet->Put( aFormat );
1375 bPageItemPut = bState;
1376 }
1377 }
1378 bool bIsChecked = m_xPgBrkCB->get_active();
1379 if ( !bPageItemPut &&
1380 ( bState != (m_xPageCollCB->get_saved_state() == TRISTATE_TRUE) ||
1381 bIsChecked != (m_xPgBrkCB->get_saved_state() == TRISTATE_TRUE) ||
1382 m_xPgBrkBeforeRB->get_state_changed_from_saved() ||
1383 m_xPgBrkRB->get_state_changed_from_saved() ))
1384 {
1385 SvxFormatBreakItem aBreak( GetItemSet().Get( RES_BREAK ) );
1386
1387 if(bIsChecked)
1388 {
1389 bool bBefore = m_xPgBrkBeforeRB->get_active();
1390
1391 if (m_xPgBrkRB->get_active())
1392 {
1393 if ( bBefore )
1394 aBreak.SetValue( SvxBreak::PageBefore );
1395 else
1396 aBreak.SetValue( SvxBreak::PageAfter );
1397 }
1398 else
1399 {
1400 if ( bBefore )
1401 aBreak.SetValue( SvxBreak::ColumnBefore );
1402 else
1403 aBreak.SetValue( SvxBreak::ColumnAfter );
1404 }
1405 }
1406 else
1407 {
1408 aBreak.SetValue( SvxBreak::NONE );
1409 }
1410
1411 if ( !pBreak || !( *pBreak == aBreak ) )
1412 {
1413 bModified |= nullptr != rSet->Put( aBreak );
1414 }
1415 }
1416
1417 if (m_xTextDirectionLB->get_value_changed_from_saved())
1418 {
1419 OUString sId = m_xTextDirectionLB->get_active_id();
1420 bModified |= nullptr != rSet->Put(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(sId.toUInt32()), FN_TABLE_BOX_TEXTORIENTATION((20000 + 400) + 192)));
1421 }
1422
1423 if (m_xVertOrientLB->get_value_changed_from_saved())
1424 {
1425 sal_uInt16 nOrient = USHRT_MAX(32767 *2 +1);
1426 switch (m_xVertOrientLB->get_active())
1427 {
1428 case 0 : nOrient = text::VertOrientation::NONE; break;
1429 case 1 : nOrient = text::VertOrientation::CENTER; break;
1430 case 2 : nOrient = text::VertOrientation::BOTTOM; break;
1431 }
1432 if (nOrient != USHRT_MAX(32767 *2 +1))
1433 bModified |= nullptr != rSet->Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN((20000 + 400) + 188), nOrient));
1434 }
1435
1436 return bModified;
1437
1438}
1439
1440void SwTextFlowPage::Reset( const SfxItemSet* rSet )
1441{
1442 const SfxPoolItem* pItem;
1443 SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1444 bool bFlowAllowed = !bHtmlMode || rHtmlOpt.IsPrintLayoutExtension();
1445 if(bFlowAllowed)
1446 {
1447 //Inserting of the existing page templates in the list box
1448 const size_t nCount = pShell->GetPageDescCnt();
1449
1450 for( size_t i = 0; i < nCount; ++i)
1451 {
1452 const SwPageDesc &rPageDesc = pShell->GetPageDesc(i);
1453 m_xPageCollLB->append_text(rPageDesc.GetName());
1454 }
1455
1456 OUString aFormatName;
1457 for (sal_uInt16 i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i)
1458 {
1459 aFormatName = SwStyleNameMapper::GetUIName(i, aFormatName);
1460 if (m_xPageCollLB->find_text(aFormatName) == -1)
1461 m_xPageCollLB->append_text(aFormatName);
1462 }
1463
1464 if(SfxItemState::SET == rSet->GetItemState( RES_KEEP, false, &pItem ))
1465 {
1466 m_xKeepCB->set_active( static_cast<const SvxFormatKeepItem*>(pItem)->GetValue() );
1467 m_xKeepCB->save_state();
1468 }
1469 if(SfxItemState::SET == rSet->GetItemState( RES_LAYOUT_SPLIT, false, &pItem ))
1470 {
1471 m_xSplitCB->set_active( static_cast<const SwFormatLayoutSplit*>(pItem)->GetValue() );
1472 }
1473 else
1474 m_xSplitCB->set_active(true);
1475
1476 m_xSplitCB->save_state();
1477 SplitHdl_Impl(*m_xSplitCB);
1478
1479 if(SfxItemState::SET == rSet->GetItemState( RES_ROW_SPLIT, false, &pItem ))
1480 {
1481 m_xSplitRowCB->set_active( static_cast<const SwFormatRowSplit*>(pItem)->GetValue() );
1482 }
1483 else
1484 m_xSplitRowCB->set_state(TRISTATE_INDET);
1485 m_xSplitRowCB->save_state();
1486
1487 if(bPageBreak)
1488 {
1489 if(SfxItemState::SET == rSet->GetItemState( RES_PAGEDESC, false, &pItem ))
1490 {
1491 OUString sPageDesc;
1492 const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
1493
1494 ::std::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset();
1495 if (oNumOffset)
1496 {
1497 m_xPageNoCB->set_active(true);
1498 m_xPageNoNF->set_sensitive(true);
1499 m_xPageNoNF->set_value(*oNumOffset);
1500 }
1501 else
1502 {
1503 m_xPageNoCB->set_active(false);
1504 m_xPageNoNF->set_sensitive(false);
1505 }
1506
1507 if(pDesc)
1508 sPageDesc = pDesc->GetName();
1509 if (!sPageDesc.isEmpty() && m_xPageCollLB->find_text(sPageDesc) != -1)
1510 {
1511 m_xPageCollLB->set_active_text(sPageDesc);
1512 m_xPageCollCB->set_active(true);
1513
1514 m_xPgBrkCB->set_sensitive(true);
1515 m_xPgBrkRB->set_sensitive(true);
1516 m_xColBrkRB->set_sensitive(true);
1517 m_xPgBrkBeforeRB->set_sensitive(true);
1518 m_xPgBrkAfterRB->set_sensitive(true);
1519 m_xPageCollCB->set_sensitive(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((20000 + 1100)+50), 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((20000 + 400) + 192)) > SfxItemState::DEFAULT )
1606 {
1607 SvxFrameDirection nDirection =
1608 static_cast<const SvxFrameDirectionItem&>(rSet->Get(FN_TABLE_BOX_TEXTORIENTATION((20000 + 400) + 192))).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((20000 + 400) + 188)) > SfxItemState::DEFAULT )
1613 {
1614 sal_uInt16 nVert = static_cast<const SfxUInt16Item&>(rSet->Get(FN_TABLE_SET_VERT_ALIGN((20000 + 400) + 188))).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
1640void SwTextFlowPage::SetShell(SwWrtShell* pSh)
1641{
1642 pShell = pSh;
1643 bHtmlMode = 0 != (::GetHtmlMode(pShell->GetView().GetDocShell()) & HTMLMODE_ON);
1644 if(bHtmlMode)
1645 {
1646 m_xPageNoNF->set_sensitive(false);
1647 m_xPageNoCB->set_sensitive(false);
1648 }
1649}
1650
1651IMPL_LINK_NOARG(SwTextFlowPage, PageBreakHdl_Impl, weld::ToggleButton&, void)void SwTextFlowPage::LinkStubPageBreakHdl_Impl(void * instance
, weld::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->PageBreakHdl_Impl(data); } void SwTextFlowPage
::PageBreakHdl_Impl(__attribute__ ((unused)) weld::ToggleButton
&)
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
1687IMPL_LINK_NOARG(SwTextFlowPage, ApplyCollClickHdl_Impl, weld::ToggleButton&, void)void SwTextFlowPage::LinkStubApplyCollClickHdl_Impl(void * instance
, weld::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->ApplyCollClickHdl_Impl(data); } void SwTextFlowPage
::ApplyCollClickHdl_Impl(__attribute__ ((unused)) weld::ToggleButton
&)
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
1707IMPL_LINK_NOARG(SwTextFlowPage, PageBreakPosHdl_Impl, weld::ToggleButton&, void)void SwTextFlowPage::LinkStubPageBreakPosHdl_Impl(void * instance
, weld::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->PageBreakPosHdl_Impl(data); } void SwTextFlowPage
::PageBreakPosHdl_Impl(__attribute__ ((unused)) weld::ToggleButton
&)
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
1735IMPL_LINK_NOARG(SwTextFlowPage, PageBreakTypeHdl_Impl, weld::ToggleButton&, void)void SwTextFlowPage::LinkStubPageBreakTypeHdl_Impl(void * instance
, weld::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->PageBreakTypeHdl_Impl(data); } void SwTextFlowPage
::PageBreakTypeHdl_Impl(__attribute__ ((unused)) weld::ToggleButton
&)
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
1749IMPL_LINK_NOARG(SwTextFlowPage, PageNoClickHdl_Impl, weld::ToggleButton&, void)void SwTextFlowPage::LinkStubPageNoClickHdl_Impl(void * instance
, weld::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->PageNoClickHdl_Impl(data); } void SwTextFlowPage
::PageNoClickHdl_Impl(__attribute__ ((unused)) weld::ToggleButton
&)
1750{
1751 m_xPageNoNF->set_sensitive(m_xPageNoCB->get_active());
1752}
1753
1754IMPL_LINK(SwTextFlowPage, SplitHdl_Impl, weld::ToggleButton&, rBox, void)void SwTextFlowPage::LinkStubSplitHdl_Impl(void * instance, weld
::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->SplitHdl_Impl(data); } void SwTextFlowPage
::SplitHdl_Impl(weld::ToggleButton& rBox)
1755{
1756 m_xSplitRowCB->set_sensitive(rBox.get_active());
1757}
1758
1759IMPL_LINK_NOARG(SwTextFlowPage, HeadLineCBClickHdl, weld::ToggleButton&, void)void SwTextFlowPage::LinkStubHeadLineCBClickHdl(void * instance
, weld::ToggleButton& data) { return static_cast<SwTextFlowPage
*>(instance)->HeadLineCBClickHdl(data); } void SwTextFlowPage
::HeadLineCBClickHdl(__attribute__ ((unused)) weld::ToggleButton
&)
1760{
1761 m_xRepeatHeaderCombo->set_sensitive(m_xHeadLineCB->get_active());
1762}
1763
1764void SwTextFlowPage::DisablePageBreak()
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: */

/home/maarten/src/libreoffice/core/sw/source/uibase/inc/swtablerep.hxx

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#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWTABLEREP_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_SWTABLEREP_HXX
21
22#include <memory>
23#include <swdllapi.h>
24#include <swtypes.hxx>
25
26class SwTabCols;
27
28struct TColumn
29{
30 SwTwips nWidth;
31 bool bVisible;
32};
33
34class SW_DLLPUBLIC__attribute__ ((visibility("default"))) SwTableRep
35{
36 std::vector<TColumn> m_aTColumns;
37
38 SwTwips m_nTableWidth;
39 SwTwips m_nSpace;
40 SwTwips m_nLeftSpace;
41 SwTwips m_nRightSpace;
42 sal_uInt16 m_nAlign;
43 sal_uInt16 m_nColCount;
44 sal_uInt16 m_nAllCols;
45 sal_uInt16 m_nWidthPercent;
46 bool m_bLineSelected : 1;
47 bool m_bWidthChanged : 1;
48 bool m_bColsChanged : 1;
49
50public:
51 SwTableRep( const SwTabCols& rTabCol );
52 ~SwTableRep();
53
54 SwTableRep( const SwTableRep& rCopy ) = default;
55 SwTableRep( SwTableRep&& rCopy ) = default;
56 SwTableRep& operator=(const SwTableRep& rCopy) = default;
57 SwTableRep& operator=(SwTableRep&& rCopy) = default;
58
59 bool FillTabCols( SwTabCols& rTabCol ) const;
60
61 SwTwips GetLeftSpace() const {return m_nLeftSpace;}
62 void SetLeftSpace(SwTwips nSet) {m_nLeftSpace = nSet;}
63
64 SwTwips GetRightSpace() const {return m_nRightSpace;}
65 void SetRightSpace(SwTwips nSet) {m_nRightSpace = nSet;}
66
67 SwTwips GetWidth() const {return m_nTableWidth;}
68 void SetWidth(SwTwips nSet) {m_nTableWidth = nSet;}
69
70 sal_uInt16 GetWidthPercent() const {return m_nWidthPercent;}
71 void SetWidthPercent(sal_uInt16 nSet) {m_nWidthPercent = nSet;}
72
73 sal_uInt16 GetAlign() const {return m_nAlign;}
74 void SetAlign(sal_uInt16 nSet) {m_nAlign = nSet;}
75
76 sal_uInt16 GetColCount() const {return m_nColCount;}
13
Returning zero
77 sal_uInt16 GetAllColCount() const {return m_nAllCols;}
78
79 bool HasColsChanged() const {return m_bColsChanged;}
80 void SetColsChanged() {m_bColsChanged = true;}
81
82 bool HasWidthChanged() const {return m_bWidthChanged;}
83 void SetWidthChanged() {m_bWidthChanged = true;}
84
85 bool IsLineSelected() const {return m_bLineSelected;}
86 void SetLineSelected(bool bSet) {m_bLineSelected = bSet;}
87
88 SwTwips GetSpace() const { return m_nSpace;}
89 void SetSpace(SwTwips nSet) {m_nSpace = nSet;}
90
91 TColumn* GetColumns() {return m_aTColumns.data();}
92};
93#endif
94
95/* vim:set shiftwidth=4 softtabstop=4 expandtab: */