Bump version to 6.4.7.2.M8
[LibreOffice.git] / cui / source / tabpages / tabstpge.cxx
blob9e7001c44404f2627b5b4dddb2d036fb022e4165
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 <svtools/ruler.hxx>
21 #include <svtools/unitconv.hxx>
22 #include <svx/svxids.hrc>
23 #include <vcl/settings.hxx>
24 #include <vcl/svapp.hxx>
26 #include <editeng/lrspitem.hxx>
27 #include <tabstpge.hxx>
28 #include <svx/dlgutil.hxx>
29 #include <svl/cjkoptions.hxx>
30 #include <unotools/localedatawrapper.hxx>
31 #include <svl/intitem.hxx>
33 constexpr FieldUnit eDefUnit = FieldUnit::MM_100TH;
35 const sal_uInt16 SvxTabulatorTabPage::pRanges[] =
37 SID_ATTR_TABSTOP,
38 SID_ATTR_TABSTOP_OFFSET,
42 static void FillUpWithDefTabs_Impl( long nDefDist, SvxTabStopItem& rTabs )
44 if( rTabs.Count() )
45 return;
47 SvxTabStop aSwTabStop( nDefDist, SvxTabAdjust::Default );
48 rTabs.Insert( aSwTabStop );
52 void TabWin_Impl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&)
54 // Paint tabulators
55 Point aPoint;
56 Size aSize(GetOutputSizePixel());
57 aPoint.setX( aSize.Width() / 2 );
58 aPoint.setY( aSize.Height() / 2 );
59 Ruler::DrawTab(rRenderContext, rRenderContext.GetSettings().GetStyleSettings().GetFontColor(), aPoint, nTabStyle);
62 SvxTabulatorTabPage::SvxTabulatorTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
63 : SfxTabPage(pPage, pController, "cui/ui/paratabspage.ui", "ParagraphTabsPage", &rAttr)
64 , aCurrentTab(0)
65 , aNewTabs(std::make_unique<SvxTabStopItem>(0, 0, SvxTabAdjust::Left, GetWhich(SID_ATTR_TABSTOP)))
66 , nDefDist(0)
67 , m_xTabSpin(m_xBuilder->weld_metric_spin_button("SP_TABPOS", FieldUnit::CM))
68 , m_xTabBox(m_xBuilder->weld_entry_tree_view("tabgrid", "ED_TABPOS", "LB_TABPOS"))
69 , m_xCenterTab(m_xBuilder->weld_radio_button("radiobuttonBTN_TABTYPE_CENTER"))
70 , m_xDezTab(m_xBuilder->weld_radio_button("radiobuttonBTN_TABTYPE_DECIMAL"))
71 , m_xDezChar(m_xBuilder->weld_entry("entryED_TABTYPE_DECCHAR"))
72 , m_xDezCharLabel(m_xBuilder->weld_label("labelFT_TABTYPE_DECCHAR"))
73 // lower radio buttons
74 , m_xNoFillChar(m_xBuilder->weld_radio_button("radiobuttonBTN_FILLCHAR_NO"))
75 , m_xFillPoints(m_xBuilder->weld_radio_button("radiobuttonBTN_FILLCHAR_POINTS"))
76 , m_xFillDashLine(m_xBuilder->weld_radio_button("radiobuttonBTN_FILLCHAR_DASHLINE"))
77 , m_xFillSolidLine(m_xBuilder->weld_radio_button("radiobuttonBTN_FILLCHAR_UNDERSCORE"))
78 , m_xFillSpecial(m_xBuilder->weld_radio_button("radiobuttonBTN_FILLCHAR_OTHER"))
79 , m_xFillChar(m_xBuilder->weld_entry("entryED_FILLCHAR_OTHER"))
80 // button bar
81 , m_xNewBtn(m_xBuilder->weld_button("buttonBTN_NEW"))
82 , m_xDelAllBtn(m_xBuilder->weld_button("buttonBTN_DELALL"))
83 , m_xDelBtn(m_xBuilder->weld_button("buttonBTN_DEL"))
84 , m_xTypeFrame(m_xBuilder->weld_container("frameFL_TABTYPE"))
85 , m_xFillFrame(m_xBuilder->weld_container("frameFL_FILLCHAR"))
86 // the tab images
87 , m_xLeftWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWIN_TABLEFT", m_aLeftWin))
88 , m_xRightWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWIN_TABRIGHT", m_aRightWin))
89 , m_xCenterWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWIN_TABCENTER", m_aCenterWin))
90 , m_xDezWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWIN_TABDECIMAL", m_aDezWin))
92 m_aLeftWin.SetTabStyle(sal_uInt16(RULER_TAB_LEFT|WB_HORZ));
93 m_aRightWin.SetTabStyle(sal_uInt16(RULER_TAB_RIGHT|WB_HORZ));
94 m_aCenterWin.SetTabStyle(sal_uInt16(RULER_TAB_CENTER|WB_HORZ));
95 m_aDezWin.SetTabStyle(sal_uInt16(RULER_TAB_DECIMAL|WB_HORZ));
96 //upper radiobuttons
97 SvtCJKOptions aCJKOptions;
98 m_xLeftTab = m_xBuilder->weld_radio_button(aCJKOptions.IsAsianTypographyEnabled() ? "radiobuttonST_LEFTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_LEFT");
99 m_xRightTab = m_xBuilder->weld_radio_button(aCJKOptions.IsAsianTypographyEnabled() ? "radiobuttonST_RIGHTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_RIGHT");
100 m_xLeftTab->show();
101 m_xRightTab->show();
103 // This page needs ExchangeSupport
104 SetExchangeSupport();
106 // Set metric
107 FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
108 SetFieldUnit(*m_xTabSpin, eFUnit);
110 // Initialize buttons
111 m_xNewBtn->connect_clicked(LINK(this,SvxTabulatorTabPage, NewHdl_Impl));
112 m_xDelBtn->connect_clicked(LINK(this,SvxTabulatorTabPage, DelHdl_Impl));
113 m_xDelAllBtn->connect_clicked(LINK(this,SvxTabulatorTabPage, DelAllHdl_Impl));
115 Link<weld::ToggleButton&,void> aLink = LINK(this, SvxTabulatorTabPage, TabTypeCheckHdl_Impl);
116 m_xLeftTab->connect_toggled(aLink);
117 m_xRightTab->connect_toggled(aLink);
118 m_xDezTab->connect_toggled(aLink);
119 m_xCenterTab->connect_toggled(aLink);
121 m_xDezChar->connect_focus_out(LINK(this, SvxTabulatorTabPage, GetDezCharHdl_Impl));
122 m_xDezChar->set_sensitive(false);
123 m_xDezCharLabel->set_sensitive(false);
125 aLink = LINK(this, SvxTabulatorTabPage, FillTypeCheckHdl_Impl);
126 m_xNoFillChar->connect_toggled(aLink);
127 m_xFillPoints->connect_toggled(aLink);
128 m_xFillDashLine->connect_toggled(aLink);
129 m_xFillSolidLine->connect_toggled(aLink);
130 m_xFillSpecial->connect_toggled(aLink);
131 m_xFillChar->connect_focus_out(LINK(this, SvxTabulatorTabPage, GetFillCharHdl_Impl));
132 m_xFillChar->set_sensitive(false);
134 m_xTabBox->connect_row_activated(LINK(this, SvxTabulatorTabPage, SelectHdl_Impl));
135 m_xTabBox->connect_changed(LINK(this, SvxTabulatorTabPage, ModifyHdl_Impl));
136 m_xTabBox->connect_focus_out(LINK(this, SvxTabulatorTabPage, ReformatHdl_Impl));
138 // Get the default decimal char from the system
139 const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
140 aCurrentTab.GetDecimal() = rLocaleWrapper.getNumDecimalSep()[0];
143 SvxTabulatorTabPage::~SvxTabulatorTabPage()
145 m_xDezWin.reset();
146 m_xCenterWin.reset();
147 m_xRightWin.reset();
148 m_xLeftWin.reset();
149 m_xFillChar.reset();
150 m_xDezChar.reset();
151 m_xTabBox.reset();
154 bool SvxTabulatorTabPage::FillItemSet(SfxItemSet* rSet)
156 bool bModified = false;
158 // Put the controls' values in here
159 if (m_xNewBtn->get_sensitive())
160 NewHdl_Impl(nullptr);
162 // Call the LoseFocus-Handler first
163 GetDezCharHdl_Impl(*m_xDezChar);
164 GetFillCharHdl_Impl(*m_xFillChar);
166 FillUpWithDefTabs_Impl(nDefDist, *aNewTabs);
167 SfxItemPool* pPool = rSet->GetPool();
168 MapUnit eUnit = pPool->GetMetric(GetWhich(SID_ATTR_TABSTOP));
169 const SfxPoolItem* pOld = GetOldItem(*rSet, SID_ATTR_TABSTOP);
171 if (MapUnit::Map100thMM != eUnit)
173 // If the ItemSet contains a LRSpaceItem with negative first line indent,
174 // the TabStopItem needs to have a DefTab at position 0.
175 const SfxPoolItem* pLRSpace;
176 // If not in the new set, then maybe in the old one
177 if (SfxItemState::SET != rSet->GetItemState(GetWhich(SID_ATTR_LRSPACE), true, &pLRSpace))
178 pLRSpace = GetOldItem(*rSet, SID_ATTR_LRSPACE);
180 if (pLRSpace && static_cast<const SvxLRSpaceItem*>(pLRSpace)->GetTextFirstLineOfst() < 0)
182 SvxTabStop aNull(0, SvxTabAdjust::Default);
183 aNewTabs->Insert(aNull);
186 std::unique_ptr<SvxTabStopItem> aTmp(static_cast<SvxTabStopItem*>(aNewTabs->Clone()));
187 aTmp->Remove(0, aTmp->Count());
189 for (sal_uInt16 i = 0; i < aNewTabs->Count(); ++i)
191 SvxTabStop aTmpStop = (*aNewTabs)[i];
192 aTmpStop.GetTabPos() = OutputDevice::LogicToLogic(aTmpStop.GetTabPos(), MapUnit::Map100thMM, eUnit);
193 aTmp->Insert(aTmpStop);
196 if (!pOld || *static_cast<const SvxTabStopItem*>(pOld) != *aTmp)
198 rSet->Put(*aTmp);
199 bModified = true;
202 else if (!pOld || *static_cast<const SvxTabStopItem*>(pOld) != *aNewTabs)
204 rSet->Put(*aNewTabs);
205 bModified = true;
208 return bModified;
211 std::unique_ptr<SfxTabPage> SvxTabulatorTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
213 return std::make_unique<SvxTabulatorTabPage>(pPage, pController, *rSet);
216 void SvxTabulatorTabPage::Reset(const SfxItemSet* rSet)
218 SfxItemPool* pPool = rSet->GetPool();
219 MapUnit eUnit = pPool->GetMetric(GetWhich(SID_ATTR_TABSTOP));
221 // Current tabs
222 const SfxPoolItem* pItem = GetItem(*rSet, SID_ATTR_TABSTOP);
224 if (pItem)
226 if (MapUnit::Map100thMM != eUnit)
228 std::unique_ptr<SvxTabStopItem> aTmp(static_cast<SvxTabStopItem*>(pItem->Clone()));
229 aNewTabs->Remove(0, aNewTabs->Count());
231 for (sal_uInt16 i = 0; i < aTmp->Count(); ++i)
233 SvxTabStop aTmpStop = (*aTmp)[i];
234 aTmpStop.GetTabPos() = OutputDevice::LogicToLogic(aTmpStop.GetTabPos(), eUnit, MapUnit::Map100thMM);
235 aNewTabs->Insert(aTmpStop);
238 else
240 aNewTabs.reset(static_cast<SvxTabStopItem*>(pItem->Clone()));
243 else
245 aNewTabs->Remove(0, aNewTabs->Count());
248 // Default tab distance
249 nDefDist = SVX_TAB_DEFDIST;
250 pItem = GetItem(*rSet, SID_ATTR_TABSTOP_DEFAULTS);
252 if (pItem)
253 nDefDist = OutputDevice::LogicToLogic(long(static_cast<const SfxUInt16Item*>(pItem)->GetValue()), eUnit, MapUnit::Map100thMM);
255 // Tab pos currently selected
256 sal_uInt16 nTabPos = 0;
257 pItem = GetItem(*rSet, SID_ATTR_TABSTOP_POS);
259 if (pItem)
260 nTabPos = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
262 InitTabPos_Impl(nTabPos);
265 void SvxTabulatorTabPage::DisableControls(const TabulatorDisableFlags nFlag)
267 if (TabulatorDisableFlags::TypeLeft & nFlag)
269 m_xLeftTab->set_sensitive(false);
270 m_xLeftWin->set_sensitive(false);
272 if (TabulatorDisableFlags::TypeRight & nFlag)
274 m_xRightTab->set_sensitive(false);
275 m_xRightWin->set_sensitive(false);
277 if (TabulatorDisableFlags::TypeCenter & nFlag)
279 m_xCenterTab->set_sensitive(false);
280 m_xCenterWin->set_sensitive(false);
282 if (TabulatorDisableFlags::TypeDecimal & nFlag)
284 m_xDezTab->set_sensitive(false);
285 m_xDezWin->set_sensitive(false);
286 m_xDezCharLabel->set_sensitive(false);
287 m_xDezChar->set_sensitive(false);
289 if (TabulatorDisableFlags::TypeMask & nFlag)
290 m_xTypeFrame->set_sensitive(false);
291 if (TabulatorDisableFlags::FillNone & nFlag)
292 m_xNoFillChar->set_sensitive(false);
293 if (TabulatorDisableFlags::FillPoint & nFlag)
294 m_xFillPoints->set_sensitive(false);
295 if (TabulatorDisableFlags::FillDashLine & nFlag)
296 m_xFillDashLine->set_sensitive(false);
297 if (TabulatorDisableFlags::FillSolidLine & nFlag)
298 m_xFillSolidLine->set_sensitive(false);
299 if (TabulatorDisableFlags::FillSpecial & nFlag)
301 m_xFillSpecial->set_sensitive(false);
302 m_xFillChar->set_sensitive(false);
304 if (TabulatorDisableFlags::FillMask & nFlag)
305 m_xFillFrame->set_sensitive(false);
308 DeactivateRC SvxTabulatorTabPage::DeactivatePage( SfxItemSet* _pSet )
310 if ( _pSet )
311 FillItemSet( _pSet );
312 return DeactivateRC::LeavePage;
315 void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos )
317 m_xTabBox->clear();
319 long nOffset = 0;
320 const SfxPoolItem* pItem = nullptr;
321 if (GetItemSet().GetItemState(SID_ATTR_TABSTOP_OFFSET, true, &pItem) == SfxItemState::SET)
323 nOffset = static_cast<const SfxInt32Item*>(pItem)->GetValue();
324 MapUnit eUnit = GetItemSet().GetPool()->GetMetric(GetWhich(SID_ATTR_TABSTOP));
325 nOffset = OutputDevice::LogicToLogic(nOffset, eUnit, MapUnit::Map100thMM);
328 // Correct current TabPos and default tabs
329 for ( sal_uInt16 i = 0; i < aNewTabs->Count(); i++ )
331 if ( (*aNewTabs)[i].GetAdjustment() != SvxTabAdjust::Default )
333 m_xTabSpin->set_value(m_xTabSpin->normalize((*aNewTabs)[i].GetTabPos() + nOffset ), eDefUnit);
334 m_xTabBox->append_text(m_xTabSpin->get_text());
336 else
338 aNewTabs->Remove( i-- );
342 // Select current tabulator
343 const sal_uInt16 nSize = aNewTabs->Count();
345 if ( nTabPos >= nSize )
346 nTabPos = 0;
348 // Switch off all RadioButtons for a start
349 m_xLeftTab->set_active(true);
350 m_xNoFillChar->set_active(true);
352 if (m_xTabBox->get_count() > 0)
354 m_xTabBox->set_active(nTabPos);
355 aCurrentTab = (*aNewTabs)[nTabPos];
357 SetFillAndTabType_Impl();
358 m_xNewBtn->set_sensitive(false);
359 m_xDelBtn->set_sensitive(true);
361 else
362 { // If no entry, 0 is the default value
363 m_xTabSpin->set_value(0, eDefUnit);
364 m_xTabBox->set_entry_text(m_xTabSpin->get_text());
366 m_xNewBtn->set_sensitive(true);
367 m_xDelBtn->set_sensitive(false);
371 void SvxTabulatorTabPage::SetFillAndTabType_Impl()
373 weld::RadioButton* pTypeBtn = nullptr;
374 weld::RadioButton* pFillBtn = nullptr;
376 m_xDezChar->set_sensitive(false);
377 m_xDezCharLabel->set_sensitive(false);
379 if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Left )
380 pTypeBtn = m_xLeftTab.get();
381 else if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Right )
382 pTypeBtn = m_xRightTab.get();
383 else if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Decimal )
385 pTypeBtn = m_xDezTab.get();
386 m_xDezChar->set_sensitive(true);
387 m_xDezCharLabel->set_sensitive(true);
388 m_xDezChar->set_text(OUString(aCurrentTab.GetDecimal()));
390 else if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Center )
391 pTypeBtn = m_xCenterTab.get();
393 if (pTypeBtn)
394 pTypeBtn->set_active(true);
396 m_xFillChar->set_sensitive(false);
397 m_xFillChar->set_text("");
399 if ( aCurrentTab.GetFill() == ' ' )
400 pFillBtn = m_xNoFillChar.get();
401 else if ( aCurrentTab.GetFill() == '-' )
402 pFillBtn = m_xFillDashLine.get();
403 else if ( aCurrentTab.GetFill() == '_' )
404 pFillBtn = m_xFillSolidLine.get();
405 else if ( aCurrentTab.GetFill() == '.' )
406 pFillBtn = m_xFillPoints.get();
407 else
409 pFillBtn = m_xFillSpecial.get();
410 m_xFillChar->set_sensitive(true);
411 m_xFillChar->set_text(OUString(aCurrentTab.GetFill()));
413 pFillBtn->set_active(true);
416 IMPL_LINK(SvxTabulatorTabPage, NewHdl_Impl, weld::Button&, rBtn, void)
418 NewHdl_Impl(&rBtn);
421 void SvxTabulatorTabPage::NewHdl_Impl(const weld::Button* pBtn)
423 // Add a new one and select it
424 // Get the value from the display
425 ReformatHdl_Impl(*m_xTabBox);
426 m_xTabSpin->set_text(m_xTabBox->get_active_text());
427 auto nVal = m_xTabSpin->denormalize(m_xTabSpin->get_value(eDefUnit));
429 // If the pBtn == 0 && the value == 0 then do not create a tab, because we create via OK
430 if (nVal == 0 && pBtn == nullptr)
431 return;
433 long nOffset = 0;
434 const SfxPoolItem* pItem = nullptr;
436 if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, true, &pItem ) ==
437 SfxItemState::SET )
439 nOffset = static_cast<const SfxInt32Item*>(pItem)->GetValue();
440 MapUnit eUnit = GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
441 nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MapUnit::Map100thMM );
443 const long nReal = nVal - nOffset;
444 sal_Int32 nSize = m_xTabBox->get_count();
446 sal_Int32 i;
447 for( i = 0; i < nSize; i++ )
449 if ( nReal < (*aNewTabs)[i].GetTabPos() )
450 break;
453 // Make ListBox entry
454 m_xTabSpin->set_value(m_xTabSpin->normalize(nVal), eDefUnit);
455 m_xTabBox->insert_text(i, m_xTabSpin->get_text());
457 aCurrentTab.GetTabPos() = nReal;
458 SvxTabAdjust eAdj = SvxTabAdjust::Left;
460 if (m_xRightTab->get_active())
461 eAdj = SvxTabAdjust::Right;
462 else if (m_xCenterTab->get_active())
463 eAdj = SvxTabAdjust::Center;
464 else if (m_xDezTab->get_active())
465 eAdj = SvxTabAdjust::Decimal;
467 aCurrentTab.GetAdjustment() = eAdj;
468 aNewTabs->Insert( aCurrentTab );
470 m_xNewBtn->set_sensitive(false);
471 m_xDelBtn->set_sensitive(true);
472 m_xTabBox->grab_focus();
474 // Set the selection into the position Edit
475 m_xTabBox->select_entry_region(0, -1);
478 int SvxTabulatorTabPage::FindCurrentTab()
480 return m_xTabBox->find_text(FormatTab());
483 IMPL_LINK_NOARG(SvxTabulatorTabPage, DelHdl_Impl, weld::Button&, void)
485 int nPos = FindCurrentTab();
486 if (nPos == -1)
487 return;
489 if (m_xTabBox->get_count() == 1)
491 DelAllHdl_Impl(*m_xDelAllBtn);
492 return;
495 // Delete Tab
496 m_xTabBox->remove(nPos);
497 aNewTabs->Remove( nPos );
499 // Reset aCurrentTab
500 const sal_uInt16 nSize = aNewTabs->Count();
502 if ( nSize > 0 )
504 // Correct Pos
505 nPos = ( ( nSize - 1 ) >= nPos) ? nPos : nPos - 1;
506 m_xTabBox->set_active(nPos);
507 aCurrentTab = (*aNewTabs)[nPos];
510 // If no Tabs Enable Disable Controls
511 if (m_xTabBox->get_count() == 0)
513 m_xDelBtn->set_sensitive(false);
514 m_xNewBtn->set_sensitive(true);
515 m_xTabBox->grab_focus();
519 IMPL_LINK_NOARG(SvxTabulatorTabPage, DelAllHdl_Impl, weld::Button&, void)
521 if ( aNewTabs->Count() )
523 aNewTabs = std::make_unique<SvxTabStopItem>(GetWhich(SID_ATTR_TABSTOP));
524 InitTabPos_Impl();
528 IMPL_LINK(SvxTabulatorTabPage, TabTypeCheckHdl_Impl, weld::ToggleButton&, rBox, void)
530 if (!rBox.get_active())
531 return;
533 SvxTabAdjust eAdj;
534 m_xDezChar->set_sensitive(false);
535 m_xDezCharLabel->set_sensitive(false);
536 m_xDezChar->set_text("");
538 if (&rBox == m_xLeftTab.get())
539 eAdj = SvxTabAdjust::Left;
540 else if (&rBox == m_xRightTab.get())
541 eAdj = SvxTabAdjust::Right;
542 else if (&rBox == m_xCenterTab.get())
543 eAdj = SvxTabAdjust::Center;
544 else
546 eAdj = SvxTabAdjust::Decimal;
547 m_xDezChar->set_sensitive(true);
548 m_xDezCharLabel->set_sensitive(true);
549 m_xDezChar->set_text(OUString(aCurrentTab.GetDecimal()));
552 aCurrentTab.GetAdjustment() = eAdj;
553 int nPos = FindCurrentTab();
554 if (nPos != -1)
556 aNewTabs->Remove( nPos );
557 aNewTabs->Insert( aCurrentTab );
561 IMPL_LINK(SvxTabulatorTabPage, FillTypeCheckHdl_Impl, weld::ToggleButton&, rBox, void)
563 if (!rBox.get_active())
564 return;
566 sal_uInt8 cFill = ' ';
567 m_xFillChar->set_text( "" );
568 m_xFillChar->set_sensitive(false);
570 if (&rBox == m_xFillSpecial.get())
571 m_xFillChar->set_sensitive(true);
572 else if (&rBox == m_xNoFillChar.get())
573 cFill = ' ';
574 else if (&rBox == m_xFillSolidLine.get())
575 cFill = '_';
576 else if (&rBox == m_xFillPoints.get())
577 cFill = '.';
578 else if (&rBox == m_xFillDashLine.get())
579 cFill = '-';
581 aCurrentTab.GetFill() = cFill;
582 int nPos = FindCurrentTab();
583 if (nPos != -1)
585 aNewTabs->Remove( nPos );
586 aNewTabs->Insert( aCurrentTab );
590 IMPL_LINK_NOARG(SvxTabulatorTabPage, GetFillCharHdl_Impl, weld::Widget&, void)
592 OUString aChar(m_xFillChar->get_text());
593 if ( !aChar.isEmpty() )
594 aCurrentTab.GetFill() = aChar[0];
596 const int nPos = FindCurrentTab();
597 if (nPos != -1)
599 aNewTabs->Remove( nPos );
600 aNewTabs->Insert( aCurrentTab );
604 IMPL_LINK_NOARG(SvxTabulatorTabPage, GetDezCharHdl_Impl, weld::Widget&, void)
606 OUString aChar(m_xDezChar->get_text());
607 if ( !aChar.isEmpty() && ( aChar[0] >= ' '))
608 aCurrentTab.GetDecimal() = aChar[0];
610 const int nPos = FindCurrentTab();
611 if (nPos != -1)
613 aNewTabs->Remove( nPos );
614 aNewTabs->Insert( aCurrentTab );
618 IMPL_LINK_NOARG(SvxTabulatorTabPage, SelectHdl_Impl, weld::TreeView&, bool)
620 const int nPos = FindCurrentTab();
621 if (nPos != -1)
623 aCurrentTab = (*aNewTabs)[nPos];
624 m_xNewBtn->set_sensitive(false);
625 SetFillAndTabType_Impl();
627 return true;
630 OUString SvxTabulatorTabPage::FormatTab()
632 m_xTabSpin->set_text(m_xTabBox->get_active_text());
633 m_xTabSpin->reformat();
634 return m_xTabSpin->get_text();
637 IMPL_LINK_NOARG(SvxTabulatorTabPage, ReformatHdl_Impl, weld::Widget&, void)
639 m_xTabBox->set_entry_text(FormatTab());
642 IMPL_LINK_NOARG(SvxTabulatorTabPage, ModifyHdl_Impl, weld::ComboBox&, void)
644 const int nPos = FindCurrentTab();
645 if (nPos != -1)
647 aCurrentTab = (*aNewTabs)[nPos];
648 SetFillAndTabType_Impl();
650 m_xTabSpin->set_text(m_xTabBox->get_active_text());
651 aCurrentTab.GetTabPos() = m_xTabSpin->denormalize(m_xTabSpin->get_value(eDefUnit));
652 m_xNewBtn->set_sensitive(false);
653 m_xDelBtn->set_sensitive(true);
654 return;
656 m_xNewBtn->set_sensitive(true);
657 m_xDelBtn->set_sensitive(false);
660 void SvxTabulatorTabPage::PageCreated(const SfxAllItemSet& aSet)
662 const SfxUInt16Item* pControlItem = aSet.GetItem<SfxUInt16Item>(SID_SVXTABULATORTABPAGE_DISABLEFLAGS, false);
663 if (pControlItem)
664 DisableControls(static_cast<TabulatorDisableFlags>(pControlItem->GetValue()));
667 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */