android: Update app-specific/MIME type icons
[LibreOffice.git] / cui / source / tabpages / tabstpge.cxx
blobb3a1745c26f9fd5341b6db2400ee1ce4d51208c8
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 WhichRangesContainer SvxTabulatorTabPage::pRanges(
36 svl::Items<SID_ATTR_TABSTOP, SID_ATTR_TABSTOP_OFFSET>);
38 static void FillUpWithDefTabs_Impl( tools::Long nDefDist, SvxTabStopItem& rTabs )
40 if( rTabs.Count() )
41 return;
43 SvxTabStop aSwTabStop( nDefDist, SvxTabAdjust::Default );
44 rTabs.Insert( aSwTabStop );
48 void TabWin_Impl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&)
50 // Paint tabulators
51 Point aPoint;
52 Size aSize(GetOutputSizePixel());
53 aPoint.setX( aSize.Width() / 2 );
54 aPoint.setY( aSize.Height() / 2 );
55 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
56 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
57 rRenderContext.SetFillColor(rStyleSettings.GetDialogColor());
58 rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize()));
59 Ruler::DrawTab(rRenderContext, rStyleSettings.GetDialogTextColor(), 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 m_xLeftTab = m_xBuilder->weld_radio_button(SvtCJKOptions::IsAsianTypographyEnabled() ? "radiobuttonST_LEFTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_LEFT");
98 m_xRightTab = m_xBuilder->weld_radio_button(SvtCJKOptions::IsAsianTypographyEnabled() ? "radiobuttonST_RIGHTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_RIGHT");
99 m_xLeftTab->show();
100 m_xRightTab->show();
102 // This page needs ExchangeSupport
103 SetExchangeSupport();
105 // Set metric
106 FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
107 SetFieldUnit(*m_xTabSpin, eFUnit);
109 // Initialize buttons
110 m_xNewBtn->connect_clicked(LINK(this,SvxTabulatorTabPage, NewHdl_Impl));
111 m_xDelBtn->connect_clicked(LINK(this,SvxTabulatorTabPage, DelHdl_Impl));
112 m_xDelAllBtn->connect_clicked(LINK(this,SvxTabulatorTabPage, DelAllHdl_Impl));
114 Link<weld::Toggleable&,void> aLink = LINK(this, SvxTabulatorTabPage, TabTypeCheckHdl_Impl);
115 m_xLeftTab->connect_toggled(aLink);
116 m_xRightTab->connect_toggled(aLink);
117 m_xDezTab->connect_toggled(aLink);
118 m_xCenterTab->connect_toggled(aLink);
120 m_xDezChar->connect_focus_out(LINK(this, SvxTabulatorTabPage, GetDezCharHdl_Impl));
121 m_xDezChar->set_sensitive(false);
122 m_xDezCharLabel->set_sensitive(false);
124 aLink = LINK(this, SvxTabulatorTabPage, FillTypeCheckHdl_Impl);
125 m_xNoFillChar->connect_toggled(aLink);
126 m_xFillPoints->connect_toggled(aLink);
127 m_xFillDashLine->connect_toggled(aLink);
128 m_xFillSolidLine->connect_toggled(aLink);
129 m_xFillSpecial->connect_toggled(aLink);
130 m_xFillChar->connect_focus_out(LINK(this, SvxTabulatorTabPage, GetFillCharHdl_Impl));
131 m_xFillChar->set_sensitive(false);
133 m_xTabBox->connect_row_activated(LINK(this, SvxTabulatorTabPage, SelectHdl_Impl));
134 m_xTabBox->connect_changed(LINK(this, SvxTabulatorTabPage, ModifyHdl_Impl));
135 m_xTabBox->connect_focus_out(LINK(this, SvxTabulatorTabPage, ReformatHdl_Impl));
137 // Get the default decimal char from the system
138 const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
139 aCurrentTab.GetDecimal() = rLocaleWrapper.getNumDecimalSep()[0];
142 SvxTabulatorTabPage::~SvxTabulatorTabPage()
144 m_xDezWin.reset();
145 m_xCenterWin.reset();
146 m_xRightWin.reset();
147 m_xLeftWin.reset();
148 m_xFillChar.reset();
149 m_xDezChar.reset();
150 m_xTabBox.reset();
153 bool SvxTabulatorTabPage::FillItemSet(SfxItemSet* rSet)
155 bool bModified = false;
157 // Put the controls' values in here
158 if (m_xNewBtn->get_sensitive())
159 NewHdl_Impl(nullptr);
161 // Call the LoseFocus-Handler first
162 GetDezCharHdl_Impl(*m_xDezChar);
163 GetFillCharHdl_Impl(*m_xFillChar);
165 FillUpWithDefTabs_Impl(nDefDist, *aNewTabs);
166 SfxItemPool* pPool = rSet->GetPool();
167 MapUnit eUnit = pPool->GetMetric(GetWhich(SID_ATTR_TABSTOP));
168 const SfxPoolItem* pOld = GetOldItem(*rSet, SID_ATTR_TABSTOP);
170 if (MapUnit::Map100thMM != eUnit)
172 // If the ItemSet contains a LRSpaceItem with negative first line indent,
173 // the TabStopItem needs to have a DefTab at position 0.
174 const SfxPoolItem* pLRSpace;
175 // If not in the new set, then maybe in the old one
176 if (SfxItemState::SET != rSet->GetItemState(GetWhich(SID_ATTR_LRSPACE), true, &pLRSpace))
177 pLRSpace = GetOldItem(*rSet, SID_ATTR_LRSPACE);
179 if (pLRSpace && static_cast<const SvxLRSpaceItem*>(pLRSpace)->GetTextFirstLineOffset() < 0)
181 SvxTabStop aNull(0, SvxTabAdjust::Default);
182 aNewTabs->Insert(aNull);
185 std::unique_ptr<SvxTabStopItem> aTmp(aNewTabs->Clone());
186 aTmp->Remove(0, aTmp->Count());
188 for (sal_uInt16 i = 0; i < aNewTabs->Count(); ++i)
190 SvxTabStop aTmpStop = (*aNewTabs)[i];
191 aTmpStop.GetTabPos() = OutputDevice::LogicToLogic(aTmpStop.GetTabPos(), MapUnit::Map100thMM, eUnit);
192 aTmp->Insert(aTmpStop);
195 if (!pOld || *static_cast<const SvxTabStopItem*>(pOld) != *aTmp)
197 rSet->Put(std::move(aTmp));
198 bModified = true;
201 else if (!pOld || *static_cast<const SvxTabStopItem*>(pOld) != *aNewTabs)
203 rSet->Put(*aNewTabs);
204 bModified = true;
207 return bModified;
210 std::unique_ptr<SfxTabPage> SvxTabulatorTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
212 return std::make_unique<SvxTabulatorTabPage>(pPage, pController, *rSet);
215 void SvxTabulatorTabPage::Reset(const SfxItemSet* rSet)
217 SfxItemPool* pPool = rSet->GetPool();
218 MapUnit eUnit = pPool->GetMetric(GetWhich(SID_ATTR_TABSTOP));
220 // Current tabs
221 const SfxPoolItem* pItem = GetItem(*rSet, SID_ATTR_TABSTOP);
223 if (pItem)
225 if (MapUnit::Map100thMM != eUnit)
227 std::unique_ptr<SvxTabStopItem> aTmp(static_cast<SvxTabStopItem*>(pItem->Clone()));
228 aNewTabs->Remove(0, aNewTabs->Count());
230 for (sal_uInt16 i = 0; i < aTmp->Count(); ++i)
232 SvxTabStop aTmpStop = (*aTmp)[i];
233 aTmpStop.GetTabPos() = OutputDevice::LogicToLogic(aTmpStop.GetTabPos(), eUnit, MapUnit::Map100thMM);
234 aNewTabs->Insert(aTmpStop);
237 else
239 aNewTabs.reset(static_cast<SvxTabStopItem*>(pItem->Clone()));
242 else
244 aNewTabs->Remove(0, aNewTabs->Count());
247 // Default tab distance
248 nDefDist = SVX_TAB_DEFDIST;
249 pItem = GetItem(*rSet, SID_ATTR_TABSTOP_DEFAULTS);
251 if (pItem)
252 nDefDist = OutputDevice::LogicToLogic(tools::Long(static_cast<const SfxUInt16Item*>(pItem)->GetValue()), eUnit, MapUnit::Map100thMM);
254 // Tab pos currently selected
255 sal_uInt16 nTabPos = 0;
256 pItem = GetItem(*rSet, SID_ATTR_TABSTOP_POS);
258 if (pItem)
259 nTabPos = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
261 InitTabPos_Impl(nTabPos);
264 void SvxTabulatorTabPage::DisableControls(const TabulatorDisableFlags nFlag)
266 if (TabulatorDisableFlags::TypeLeft & nFlag)
268 m_xLeftTab->set_sensitive(false);
269 m_xLeftWin->set_sensitive(false);
271 if (TabulatorDisableFlags::TypeRight & nFlag)
273 m_xRightTab->set_sensitive(false);
274 m_xRightWin->set_sensitive(false);
276 if (TabulatorDisableFlags::TypeCenter & nFlag)
278 m_xCenterTab->set_sensitive(false);
279 m_xCenterWin->set_sensitive(false);
281 if (TabulatorDisableFlags::TypeDecimal & nFlag)
283 m_xDezTab->set_sensitive(false);
284 m_xDezWin->set_sensitive(false);
285 m_xDezCharLabel->set_sensitive(false);
286 m_xDezChar->set_sensitive(false);
288 if (TabulatorDisableFlags::TypeMask & nFlag)
289 m_xTypeFrame->set_sensitive(false);
290 if (TabulatorDisableFlags::FillNone & nFlag)
291 m_xNoFillChar->set_sensitive(false);
292 if (TabulatorDisableFlags::FillPoint & nFlag)
293 m_xFillPoints->set_sensitive(false);
294 if (TabulatorDisableFlags::FillDashLine & nFlag)
295 m_xFillDashLine->set_sensitive(false);
296 if (TabulatorDisableFlags::FillSolidLine & nFlag)
297 m_xFillSolidLine->set_sensitive(false);
298 if (TabulatorDisableFlags::FillSpecial & nFlag)
300 m_xFillSpecial->set_sensitive(false);
301 m_xFillChar->set_sensitive(false);
303 if (TabulatorDisableFlags::FillMask & nFlag)
304 m_xFillFrame->set_sensitive(false);
307 DeactivateRC SvxTabulatorTabPage::DeactivatePage( SfxItemSet* _pSet )
309 if ( _pSet )
310 FillItemSet( _pSet );
311 return DeactivateRC::LeavePage;
314 void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos )
316 m_xTabBox->clear();
318 tools::Long nOffset = 0;
319 if (const SfxInt32Item* pOffSetItem = GetItemSet().GetItemIfSet(SID_ATTR_TABSTOP_OFFSET))
321 nOffset = pOffSetItem->GetValue();
322 MapUnit eUnit = GetItemSet().GetPool()->GetMetric(GetWhich(SID_ATTR_TABSTOP));
323 nOffset = OutputDevice::LogicToLogic(nOffset, eUnit, MapUnit::Map100thMM);
326 // Correct current TabPos and default tabs
327 for ( sal_uInt16 i = 0; i < aNewTabs->Count(); i++ )
329 if ( (*aNewTabs)[i].GetAdjustment() != SvxTabAdjust::Default )
331 m_xTabSpin->set_value(m_xTabSpin->normalize((*aNewTabs)[i].GetTabPos() + nOffset ), eDefUnit);
332 m_xTabBox->append_text(m_xTabSpin->get_text());
334 else
336 aNewTabs->Remove( i-- );
340 // Select current tabulator
341 const sal_uInt16 nSize = aNewTabs->Count();
343 if ( nTabPos >= nSize )
344 nTabPos = 0;
346 // Switch off all RadioButtons for a start
347 m_xLeftTab->set_active(true);
348 m_xNoFillChar->set_active(true);
350 if (m_xTabBox->get_count() > 0)
352 m_xTabBox->set_active(nTabPos);
353 aCurrentTab = (*aNewTabs)[nTabPos];
355 SetFillAndTabType_Impl();
356 m_xNewBtn->set_sensitive(false);
357 m_xDelBtn->set_sensitive(true);
359 else
360 { // If no entry, 0 is the default value
361 m_xTabSpin->set_value(0, eDefUnit);
362 m_xTabBox->set_entry_text(m_xTabSpin->get_text());
364 m_xNewBtn->set_sensitive(true);
365 m_xDelBtn->set_sensitive(false);
369 void SvxTabulatorTabPage::SetFillAndTabType_Impl()
371 weld::RadioButton* pTypeBtn = nullptr;
372 weld::RadioButton* pFillBtn = nullptr;
374 m_xDezChar->set_sensitive(false);
375 m_xDezCharLabel->set_sensitive(false);
377 if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Left )
378 pTypeBtn = m_xLeftTab.get();
379 else if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Right )
380 pTypeBtn = m_xRightTab.get();
381 else if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Decimal )
383 pTypeBtn = m_xDezTab.get();
384 m_xDezChar->set_sensitive(true);
385 m_xDezCharLabel->set_sensitive(true);
386 m_xDezChar->set_text(OUString(aCurrentTab.GetDecimal()));
388 else if ( aCurrentTab.GetAdjustment() == SvxTabAdjust::Center )
389 pTypeBtn = m_xCenterTab.get();
391 if (pTypeBtn)
392 pTypeBtn->set_active(true);
394 m_xFillChar->set_sensitive(false);
395 m_xFillChar->set_text("");
397 if ( aCurrentTab.GetFill() == ' ' )
398 pFillBtn = m_xNoFillChar.get();
399 else if ( aCurrentTab.GetFill() == '-' )
400 pFillBtn = m_xFillDashLine.get();
401 else if ( aCurrentTab.GetFill() == '_' )
402 pFillBtn = m_xFillSolidLine.get();
403 else if ( aCurrentTab.GetFill() == '.' )
404 pFillBtn = m_xFillPoints.get();
405 else
407 pFillBtn = m_xFillSpecial.get();
408 m_xFillChar->set_sensitive(true);
409 m_xFillChar->set_text(OUString(aCurrentTab.GetFill()));
411 pFillBtn->set_active(true);
414 IMPL_LINK(SvxTabulatorTabPage, NewHdl_Impl, weld::Button&, rBtn, void)
416 NewHdl_Impl(&rBtn);
419 void SvxTabulatorTabPage::NewHdl_Impl(const weld::Button* pBtn)
421 // Add a new one and select it
422 // Get the value from the display
423 ReformatHdl_Impl(*m_xTabBox);
424 m_xTabSpin->set_text(m_xTabBox->get_active_text());
425 auto nVal = m_xTabSpin->denormalize(m_xTabSpin->get_value(eDefUnit));
427 // If the pBtn == 0 && the value == 0 then do not create a tab, because we create via OK
428 if (nVal == 0 && pBtn == nullptr)
429 return;
431 tools::Long nOffset = 0;
433 if ( const SfxInt32Item* pOffsetItem = GetItemSet().GetItemIfSet( SID_ATTR_TABSTOP_OFFSET ) )
435 nOffset = pOffsetItem->GetValue();
436 MapUnit eUnit = GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
437 nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MapUnit::Map100thMM );
439 const tools::Long nReal = nVal - nOffset;
440 sal_Int32 nSize = m_xTabBox->get_count();
442 sal_Int32 i;
443 for( i = 0; i < nSize; i++ )
445 if ( nReal < (*aNewTabs)[i].GetTabPos() )
446 break;
449 // Make ListBox entry
450 m_xTabSpin->set_value(m_xTabSpin->normalize(nVal), eDefUnit);
451 m_xTabBox->insert_text(i, m_xTabSpin->get_text());
453 aCurrentTab.GetTabPos() = nReal;
454 SvxTabAdjust eAdj = SvxTabAdjust::Left;
456 if (m_xRightTab->get_active())
457 eAdj = SvxTabAdjust::Right;
458 else if (m_xCenterTab->get_active())
459 eAdj = SvxTabAdjust::Center;
460 else if (m_xDezTab->get_active())
461 eAdj = SvxTabAdjust::Decimal;
463 aCurrentTab.GetAdjustment() = eAdj;
464 aNewTabs->Insert( aCurrentTab );
466 m_xNewBtn->set_sensitive(false);
467 m_xDelBtn->set_sensitive(true);
468 m_xTabBox->grab_focus();
470 // Set the selection into the position Edit
471 m_xTabBox->select_entry_region(0, -1);
474 int SvxTabulatorTabPage::FindCurrentTab()
476 return m_xTabBox->find_text(FormatTab());
479 IMPL_LINK_NOARG(SvxTabulatorTabPage, DelHdl_Impl, weld::Button&, void)
481 int nPos = FindCurrentTab();
482 if (nPos == -1)
483 return;
485 if (m_xTabBox->get_count() == 1)
487 DelAllHdl_Impl(*m_xDelAllBtn);
488 return;
491 // Delete Tab
492 m_xTabBox->remove(nPos);
493 aNewTabs->Remove( nPos );
495 // Reset aCurrentTab
496 const sal_uInt16 nSize = aNewTabs->Count();
498 if ( nSize > 0 )
500 // Correct Pos
501 nPos = ( ( nSize - 1 ) >= nPos) ? nPos : nPos - 1;
502 m_xTabBox->set_active(nPos);
503 aCurrentTab = (*aNewTabs)[nPos];
506 // If no Tabs Enable Disable Controls
507 if (m_xTabBox->get_count() == 0)
509 m_xDelBtn->set_sensitive(false);
510 m_xNewBtn->set_sensitive(true);
511 m_xTabBox->grab_focus();
515 IMPL_LINK_NOARG(SvxTabulatorTabPage, DelAllHdl_Impl, weld::Button&, void)
517 if ( aNewTabs->Count() )
519 aNewTabs = std::make_unique<SvxTabStopItem>(GetWhich(SID_ATTR_TABSTOP));
520 InitTabPos_Impl();
524 IMPL_LINK(SvxTabulatorTabPage, TabTypeCheckHdl_Impl, weld::Toggleable&, rBox, void)
526 if (!rBox.get_active())
527 return;
529 SvxTabAdjust eAdj;
530 m_xDezChar->set_sensitive(false);
531 m_xDezCharLabel->set_sensitive(false);
532 m_xDezChar->set_text("");
534 if (&rBox == m_xLeftTab.get())
535 eAdj = SvxTabAdjust::Left;
536 else if (&rBox == m_xRightTab.get())
537 eAdj = SvxTabAdjust::Right;
538 else if (&rBox == m_xCenterTab.get())
539 eAdj = SvxTabAdjust::Center;
540 else
542 eAdj = SvxTabAdjust::Decimal;
543 m_xDezChar->set_sensitive(true);
544 m_xDezCharLabel->set_sensitive(true);
545 m_xDezChar->set_text(OUString(aCurrentTab.GetDecimal()));
548 aCurrentTab.GetAdjustment() = eAdj;
549 int nPos = FindCurrentTab();
550 if (nPos != -1)
552 aNewTabs->Remove( nPos );
553 aNewTabs->Insert( aCurrentTab );
557 IMPL_LINK(SvxTabulatorTabPage, FillTypeCheckHdl_Impl, weld::Toggleable&, rBox, void)
559 if (!rBox.get_active())
560 return;
562 sal_uInt8 cFill = ' ';
563 m_xFillChar->set_text( "" );
564 m_xFillChar->set_sensitive(false);
566 if (&rBox == m_xFillSpecial.get())
567 m_xFillChar->set_sensitive(true);
568 else if (&rBox == m_xNoFillChar.get())
569 cFill = ' ';
570 else if (&rBox == m_xFillSolidLine.get())
571 cFill = '_';
572 else if (&rBox == m_xFillPoints.get())
573 cFill = '.';
574 else if (&rBox == m_xFillDashLine.get())
575 cFill = '-';
577 aCurrentTab.GetFill() = cFill;
578 int nPos = FindCurrentTab();
579 if (nPos != -1)
581 aNewTabs->Remove( nPos );
582 aNewTabs->Insert( aCurrentTab );
586 IMPL_LINK_NOARG(SvxTabulatorTabPage, GetFillCharHdl_Impl, weld::Widget&, void)
588 OUString aChar(m_xFillChar->get_text());
589 if ( !aChar.isEmpty() )
590 aCurrentTab.GetFill() = aChar[0];
592 const int nPos = FindCurrentTab();
593 if (nPos != -1)
595 aNewTabs->Remove( nPos );
596 aNewTabs->Insert( aCurrentTab );
600 IMPL_LINK_NOARG(SvxTabulatorTabPage, GetDezCharHdl_Impl, weld::Widget&, void)
602 OUString aChar(m_xDezChar->get_text());
603 if ( !aChar.isEmpty() && ( aChar[0] >= ' '))
604 aCurrentTab.GetDecimal() = aChar[0];
606 const int nPos = FindCurrentTab();
607 if (nPos != -1)
609 aNewTabs->Remove( nPos );
610 aNewTabs->Insert( aCurrentTab );
614 IMPL_LINK_NOARG(SvxTabulatorTabPage, SelectHdl_Impl, weld::TreeView&, bool)
616 const int nPos = FindCurrentTab();
617 if (nPos != -1)
619 aCurrentTab = (*aNewTabs)[nPos];
620 m_xNewBtn->set_sensitive(false);
621 SetFillAndTabType_Impl();
623 return true;
626 OUString SvxTabulatorTabPage::FormatTab()
628 m_xTabSpin->set_text(m_xTabBox->get_active_text());
629 m_xTabSpin->reformat();
630 return m_xTabSpin->get_text();
633 IMPL_LINK_NOARG(SvxTabulatorTabPage, ReformatHdl_Impl, weld::Widget&, void)
635 m_xTabBox->set_entry_text(FormatTab());
638 IMPL_LINK_NOARG(SvxTabulatorTabPage, ModifyHdl_Impl, weld::ComboBox&, void)
640 const int nPos = FindCurrentTab();
641 if (nPos != -1)
643 aCurrentTab = (*aNewTabs)[nPos];
644 SetFillAndTabType_Impl();
646 m_xTabSpin->set_text(m_xTabBox->get_active_text());
647 aCurrentTab.GetTabPos() = m_xTabSpin->denormalize(m_xTabSpin->get_value(eDefUnit));
648 m_xNewBtn->set_sensitive(false);
649 m_xDelBtn->set_sensitive(true);
650 return;
652 m_xNewBtn->set_sensitive(true);
653 m_xDelBtn->set_sensitive(false);
656 void SvxTabulatorTabPage::PageCreated(const SfxAllItemSet& aSet)
658 const SfxUInt16Item* pControlItem = aSet.GetItem<SfxUInt16Item>(SID_SVXTABULATORTABPAGE_DISABLEFLAGS, false);
659 if (pControlItem)
660 DisableControls(static_cast<TabulatorDisableFlags>(pControlItem->GetValue()));
663 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */