summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-06-06 17:04:10 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-06-07 15:24:12 +0200
commit56e813e810c42fd7885521698a0e4dfaf5862038 (patch)
treebb1cf0766791b69dff28b0807cb390e324d6b8ed /sw
parent08814a34e3a3841c316dfb27a07583049abc5195 (diff)
weld SwFormatTablePage
Change-Id: Ia82fdd5666a4a59cf4e1867d295ecb1d336e10a2 Reviewed-on: https://gerrit.libreoffice.org/55418 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/table/tabledlg.cxx481
-rw-r--r--sw/source/uibase/inc/prcntfld.hxx70
-rw-r--r--sw/source/uibase/table/tablepg.hxx59
-rw-r--r--sw/source/uibase/utlui/prcntfld.cxx215
-rw-r--r--sw/uiconfig/swriter/ui/formattablepage.ui146
5 files changed, 587 insertions, 384 deletions
diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index 1c7583c62373..91cdb2dbe3d3 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -62,38 +62,44 @@
using namespace ::com::sun::star;
-SwFormatTablePage::SwFormatTablePage(vcl::Window* pParent, const SfxItemSet& rSet)
- : SfxTabPage(pParent, "FormatTablePage", "modules/swriter/ui/formattablepage.ui", &rSet)
+SwFormatTablePage::SwFormatTablePage(TabPageParent pParent, const SfxItemSet& rSet)
+ : SfxTabPage(pParent, "modules/swriter/ui/formattablepage.ui", "FormatTablePage", &rSet)
, pTableData(nullptr)
, nSaveWidth(0)
, nMinTableWidth(MINLAY)
, bModified(false)
, bFull(false)
, bHtmlMode(false)
+ , m_xNameED(m_xBuilder->weld_entry("name"))
+ , m_xWidthFT(m_xBuilder->weld_label("widthft"))
+ , m_xWidthMF(new SwPercentField(m_xBuilder->weld_metric_spin_button("widthmf", FUNIT_CM)))
+ , m_xRelWidthCB(m_xBuilder->weld_check_button("relwidth"))
+ , m_xFullBtn(m_xBuilder->weld_radio_button("full"))
+ , m_xLeftBtn(m_xBuilder->weld_radio_button("left"))
+ , m_xFromLeftBtn(m_xBuilder->weld_radio_button("fromleft"))
+ , m_xRightBtn(m_xBuilder->weld_radio_button("right"))
+ , m_xCenterBtn(m_xBuilder->weld_radio_button("center"))
+ , m_xFreeBtn(m_xBuilder->weld_radio_button("free"))
+ , m_xLeftFT(m_xBuilder->weld_label("leftft"))
+ , m_xLeftMF(new SwPercentField(m_xBuilder->weld_metric_spin_button("leftmf", FUNIT_CM)))
+ , m_xRightFT(m_xBuilder->weld_label("rightft"))
+ , m_xRightMF(new SwPercentField(m_xBuilder->weld_metric_spin_button("rightmf", FUNIT_CM)))
+ , m_xTopFT(m_xBuilder->weld_label("aboveft"))
+ , m_xTopMF(m_xBuilder->weld_metric_spin_button("abovemf", FUNIT_CM))
+ , m_xBottomFT(m_xBuilder->weld_label("belowft"))
+ , m_xBottomMF(m_xBuilder->weld_metric_spin_button("belowmf", FUNIT_CM))
+ , m_xTextDirectionLB(new svx::SvxFrameDirectionListBox(m_xBuilder->weld_combo_box_text("textdirection")))
+ , m_xProperties(m_xBuilder->weld_widget("properties"))
{
- get(m_pNameED, "name");
- get(m_pWidthFT, "widthft");
- m_aWidthMF.set(get<MetricField>("widthmf"));
- m_aLeftMF.set(get<MetricField>("leftmf"));
- m_aRightMF.set(get<MetricField>("rightmf"));
- get(m_pRelWidthCB, "relwidth");
- get(m_pFullBtn, "full");
- get(m_pLeftBtn, "left");
- get(m_pFromLeftBtn, "fromleft");
- get(m_pRightBtn, "right");
- get(m_pCenterBtn, "center");
- get(m_pFreeBtn, "free");
- get(m_pLeftFT, "leftft");
- get(m_pRightFT, "rightft");
- get(m_pTopFT, "aboveft");
- get(m_pTopMF, "abovemf");
- get(m_pBottomFT, "belowft");
- get(m_pBottomMF, "belowmf");
- get(m_pTextDirectionLB, "textdirection");
+ //lock these to initial sizes so they don't change on percent to non percent change
+ Size aPrefSize(m_xLeftMF->get()->get_preferred_size());
+ m_xLeftMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
+ m_xRightMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
+ m_xWidthMF->get()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
- m_pTextDirectionLB->InsertEntryValue( SvxResId( RID_SVXSTR_FRAMEDIR_LTR ), SvxFrameDirection::Horizontal_LR_TB );
- m_pTextDirectionLB->InsertEntryValue( SvxResId( RID_SVXSTR_FRAMEDIR_RTL ), SvxFrameDirection::Horizontal_RL_TB );
- m_pTextDirectionLB->InsertEntryValue( SvxResId( RID_SVXSTR_FRAMEDIR_SUPER ), SvxFrameDirection::Environment );
+ m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
+ m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
+ m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
SetExchangeSupport();
@@ -102,160 +108,124 @@ SwFormatTablePage::SwFormatTablePage(vcl::Window* pParent, const SfxItemSet& rSe
bHtmlMode = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
bool bCTL = SW_MOD()->GetCTLOptions().IsCTLFontEnabled();
- get<VclContainer>("properties")->Show(!bHtmlMode && bCTL);
+ m_xProperties->show(!bHtmlMode && bCTL);
Init();
}
SwFormatTablePage::~SwFormatTablePage()
{
- disposeOnce();
-}
-
-void SwFormatTablePage::dispose()
-{
- m_pNameED.clear();
- m_pWidthFT.clear();
- m_pRelWidthCB.clear();
- m_pFullBtn.clear();
- m_pLeftBtn.clear();
- m_pFromLeftBtn.clear();
- m_pRightBtn.clear();
- m_pCenterBtn.clear();
- m_pFreeBtn.clear();
- m_pLeftFT.clear();
- m_pRightFT.clear();
- m_pTopFT.clear();
- m_pTopMF.clear();
- m_pBottomFT.clear();
- m_pBottomMF.clear();
- m_pTextDirectionLB.clear();
- SfxTabPage::dispose();
}
void SwFormatTablePage::Init()
{
- m_aLeftMF.SetMetricFieldMin(-999999);
- m_aRightMF.SetMetricFieldMin(-999999);
+ m_xLeftMF->SetMetricFieldMin(-999999);
+ m_xRightMF->SetMetricFieldMin(-999999);
//handler
- Link<Button*,void> aLk2 = LINK( this, SwFormatTablePage, AutoClickHdl );
- m_pFullBtn->SetClickHdl( aLk2 );
- m_pFreeBtn->SetClickHdl( aLk2 );
- m_pLeftBtn->SetClickHdl( aLk2 );
- m_pFromLeftBtn->SetClickHdl( aLk2 );
- m_pRightBtn->SetClickHdl( aLk2 );
- m_pCenterBtn->SetClickHdl( aLk2 );
-
- Link<SpinField&,void> aLk = LINK( this, SwFormatTablePage, UpDownHdl );
- m_pTopMF->SetUpHdl( aLk );
- m_pBottomMF->SetUpHdl( aLk );
- m_aRightMF.SetUpHdl( aLk );
- m_aLeftMF.SetUpHdl( aLk );
- m_aWidthMF.SetUpHdl( aLk );
-
- m_pTopMF->SetDownHdl( aLk );
- m_pBottomMF->SetDownHdl( aLk );
- m_aRightMF.SetDownHdl( aLk );
- m_aLeftMF.SetDownHdl( aLk );
- m_aWidthMF.SetDownHdl( aLk );
-
- Link<Control&,void> aLk3 = LINK( this, SwFormatTablePage, LoseFocusHdl );
- m_pTopMF->SetLoseFocusHdl( aLk3 );
- m_pBottomMF->SetLoseFocusHdl( aLk3 );
- m_aRightMF.SetLoseFocusHdl( aLk3 );
- m_aLeftMF.SetLoseFocusHdl( aLk3 );
- m_aWidthMF.SetLoseFocusHdl( aLk3 );
-
- m_pRelWidthCB->SetClickHdl(LINK( this, SwFormatTablePage, RelWidthClickHdl ));
+ Link<weld::ToggleButton&,void> aLk2 = LINK( this, SwFormatTablePage, AutoClickHdl );
+ m_xFullBtn->connect_toggled( aLk2 );
+ m_xFreeBtn->connect_toggled( aLk2 );
+ m_xLeftBtn->connect_toggled( aLk2 );
+ m_xFromLeftBtn->connect_toggled( aLk2 );
+ m_xRightBtn->connect_toggled( aLk2 );
+ m_xCenterBtn->connect_toggled( aLk2 );
+
+ Link<weld::MetricSpinButton&,void> aLk = LINK( this, SwFormatTablePage, UpDownHdl );
+ m_xTopMF->connect_value_changed(aLk);
+ m_xBottomMF->connect_value_changed(aLk);
+ m_xRightMF->connect_value_changed(aLk);
+ m_xLeftMF->connect_value_changed(aLk);
+ m_xWidthMF->connect_value_changed(aLk);
+
+ m_xRelWidthCB->connect_toggled(LINK( this, SwFormatTablePage, RelWidthClickHdl ));
}
-IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, Button*, p, void )
+IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, weld::ToggleButton&, rBtn, void )
{
- CheckBox* pBtn = static_cast<CheckBox*>(p);
OSL_ENSURE(pTableData, "table data not available?");
- bool bIsChecked = pBtn->IsChecked();
- sal_Int64 nLeft = m_aLeftMF.DenormalizePercent(m_aLeftMF.GetValue(FUNIT_TWIP ));
- sal_Int64 nRight = m_aRightMF.DenormalizePercent(m_aRightMF.GetValue(FUNIT_TWIP ));
- m_aWidthMF.ShowPercent(bIsChecked);
- m_aLeftMF.ShowPercent(bIsChecked);
- m_aRightMF.ShowPercent(bIsChecked);
+ bool bIsChecked = rBtn.get_active();
+ sal_Int64 nLeft = m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FUNIT_TWIP));
+ sal_Int64 nRight = m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FUNIT_TWIP));
+ m_xWidthMF->ShowPercent(bIsChecked);
+ m_xLeftMF->ShowPercent(bIsChecked);
+ m_xRightMF->ShowPercent(bIsChecked);
if (bIsChecked)
{
- m_aWidthMF.SetRefValue(pTableData->GetSpace());
- m_aLeftMF.SetRefValue(pTableData->GetSpace());
- m_aRightMF.SetRefValue(pTableData->GetSpace());
- m_aLeftMF.SetMetricFieldMin(0); //will be overwritten by the Percentfield
- m_aRightMF.SetMetricFieldMin(0); //dito
- m_aLeftMF.SetMetricFieldMax(99);
- m_aRightMF.SetMetricFieldMax(99);
- m_aLeftMF.SetPrcntValue(m_aLeftMF.NormalizePercent(nLeft ), FUNIT_TWIP );
- m_aRightMF.SetPrcntValue(m_aRightMF.NormalizePercent(nRight ), FUNIT_TWIP );
+ m_xWidthMF->SetRefValue(pTableData->GetSpace());
+ m_xLeftMF->SetRefValue(pTableData->GetSpace());
+ m_xRightMF->SetRefValue(pTableData->GetSpace());
+ m_xLeftMF->SetMetricFieldMin(0); //will be overwritten by the Percentfield
+ m_xRightMF->SetMetricFieldMin(0); //dito
+ m_xLeftMF->SetMetricFieldMax(99);
+ m_xRightMF->SetMetricFieldMax(99);
+ m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(nLeft ), FUNIT_TWIP );
+ m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(nRight ), FUNIT_TWIP );
}
else
- ModifyHdl(m_aLeftMF.get()); //correct values again
+ ModifyHdl(*m_xLeftMF->get()); //correct values again
- if(m_pFreeBtn->IsChecked())
+ if (m_xFreeBtn->get_active())
{
- bool bEnable = !pBtn->IsChecked();
- m_aRightMF.Enable(bEnable);
- m_pRightFT->Enable(bEnable);
+ bool bEnable = !rBtn.get_active();
+ m_xRightMF->set_sensitive(bEnable);
+ m_xRightFT->set_sensitive(bEnable);
}
bModified = true;
}
-IMPL_LINK( SwFormatTablePage, AutoClickHdl, Button*, pControl, void )
+IMPL_LINK(SwFormatTablePage, AutoClickHdl, weld::ToggleButton&, rControl, void)
{
bool bRestore = true,
bLeftEnable = false,
bRightEnable= false,
bWidthEnable= false,
bOthers = true;
- if (pControl == m_pFullBtn)
+ if (&rControl == m_xFullBtn.get())
{
- m_aLeftMF.SetPrcntValue(0);
- m_aRightMF.SetPrcntValue(0);
- nSaveWidth = static_cast< SwTwips >(m_aWidthMF.DenormalizePercent(m_aWidthMF.GetValue(FUNIT_TWIP )));
- m_aWidthMF.SetPrcntValue(m_aWidthMF.NormalizePercent(pTableData->GetSpace() ), FUNIT_TWIP );
+ m_xLeftMF->SetPrcntValue(0);
+ m_xRightMF->SetPrcntValue(0);
+ nSaveWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FUNIT_TWIP)));
+ m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(pTableData->GetSpace()), FUNIT_TWIP);
bFull = true;
bRestore = false;
}
- else if (pControl == m_pLeftBtn)
+ else if (&rControl == m_xLeftBtn.get())
{
bRightEnable = bWidthEnable = true;
- m_aLeftMF.SetPrcntValue(0);
+ m_xLeftMF->SetPrcntValue(0);
}
- else if (pControl == m_pFromLeftBtn)
+ else if (&rControl == m_xFromLeftBtn.get())
{
bLeftEnable = bWidthEnable = true;
- m_aRightMF.SetPrcntValue(0);
+ m_xRightMF->SetPrcntValue(0);
}
- else if (pControl == m_pRightBtn)
+ else if (&rControl == m_xRightBtn.get())
{
bLeftEnable = bWidthEnable = true;
- m_aRightMF.SetPrcntValue(0);
+ m_xRightMF->SetPrcntValue(0);
}
- else if (pControl == m_pCenterBtn)
+ else if (&rControl == m_xCenterBtn.get())
{
bLeftEnable = bWidthEnable = true;
}
- else if (pControl == m_pFreeBtn)
+ else if (&rControl == m_xFreeBtn.get())
{
RightModify();
bLeftEnable = true;
bWidthEnable = true;
bOthers = false;
}
- m_aLeftMF.Enable(bLeftEnable);
- m_pLeftFT->Enable(bLeftEnable);
- m_aWidthMF.Enable(bWidthEnable);
- m_pWidthFT->Enable(bWidthEnable);
+ m_xLeftMF->set_sensitive(bLeftEnable);
+ m_xLeftFT->set_sensitive(bLeftEnable);
+ m_xWidthMF->set_sensitive(bWidthEnable);
+ m_xWidthFT->set_sensitive(bWidthEnable);
if ( bOthers )
{
- m_aRightMF.Enable(bRightEnable);
- m_pRightFT->Enable(bRightEnable);
- m_pRelWidthCB->Enable(bWidthEnable);
+ m_xRightMF->set_sensitive(bRightEnable);
+ m_xRightFT->set_sensitive(bRightEnable);
+ m_xRelWidthCB->set_sensitive(bWidthEnable);
}
if(bFull && bRestore)
@@ -263,61 +233,57 @@ IMPL_LINK( SwFormatTablePage, AutoClickHdl, Button*, pControl, void )
//After being switched on automatic, the width was pinned
//in order to restore the width while switching back to.
bFull = false;
- m_aWidthMF.SetPrcntValue(m_aWidthMF.NormalizePercent(nSaveWidth ), FUNIT_TWIP );
+ m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(nSaveWidth ), FUNIT_TWIP );
}
- ModifyHdl(m_aWidthMF.get());
+ ModifyHdl(*m_xWidthMF->get());
bModified = true;
}
void SwFormatTablePage::RightModify()
{
- if(m_pFreeBtn->IsChecked())
+ if (m_xFreeBtn->get_active())
{
- bool bEnable = m_aRightMF.GetValue() == 0;
- m_pRelWidthCB->Enable(bEnable);
+ bool bEnable = m_xRightMF->get_value() == 0;
+ m_xRelWidthCB->set_sensitive(bEnable);
if ( !bEnable )
{
- m_pRelWidthCB->Check(false);
- RelWidthClickHdl(m_pRelWidthCB);
+ m_xRelWidthCB->set_active(false);
+ RelWidthClickHdl(*m_xRelWidthCB);
}
- bEnable = m_pRelWidthCB->IsChecked();
- m_aRightMF.Enable(!bEnable);
- m_pRightFT->Enable(!bEnable);
+ bEnable = m_xRelWidthCB->get_active();
+ m_xRightMF->set_sensitive(!bEnable);
+ m_xRightFT->set_sensitive(!bEnable);
}
}
-IMPL_LINK( SwFormatTablePage, LoseFocusHdl, Control&, rControl, void )
+IMPL_LINK( SwFormatTablePage, UpDownHdl, weld::MetricSpinButton&, rEdit, void )
{
- UpDownHdl(static_cast<SpinField&>(rControl));
-}
-IMPL_LINK( SwFormatTablePage, UpDownHdl, SpinField&, rEdit, void )
-{
- if( m_aRightMF.get() == &rEdit)
+ if( m_xRightMF->get() == &rEdit)
RightModify();
- ModifyHdl( &rEdit );
+ ModifyHdl(rEdit);
}
-void SwFormatTablePage::ModifyHdl(const Edit * pEdit)
+void SwFormatTablePage::ModifyHdl(const weld::MetricSpinButton& rEdit)
{
- SwTwips nCurWidth = static_cast< SwTwips >(m_aWidthMF.DenormalizePercent(m_aWidthMF.GetValue( FUNIT_TWIP )));
+ SwTwips nCurWidth = static_cast< SwTwips >(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FUNIT_TWIP)));
SwTwips nPrevWidth = nCurWidth;
- SwTwips nRight = static_cast< SwTwips >(m_aRightMF.DenormalizePercent(m_aRightMF.GetValue( FUNIT_TWIP )));
- SwTwips nLeft = static_cast< SwTwips >(m_aLeftMF.DenormalizePercent(m_aLeftMF.GetValue( FUNIT_TWIP )));
+ SwTwips nRight = static_cast< SwTwips >(m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FUNIT_TWIP)));
+ SwTwips nLeft = static_cast< SwTwips >(m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FUNIT_TWIP)));
SwTwips nDiff;
- if (pEdit == m_aWidthMF.get())
+ if (&rEdit == m_xWidthMF->get())
{
if( nCurWidth < MINLAY )
nCurWidth = MINLAY;
nDiff = nRight + nLeft + nCurWidth - pTableData->GetSpace() ;
//right aligned: only change the left margin
- if(m_pRightBtn->IsChecked())
+ if (m_xRightBtn->get_active())
nLeft -= nDiff;
//left aligned: only change the right margin
- else if(m_pLeftBtn->IsChecked())
+ else if(m_xLeftBtn->get_active())
nRight -= nDiff;
//left margin and width allowed - first right - then left
- else if(m_pFromLeftBtn->IsChecked())
+ else if (m_xFromLeftBtn->get_active())
{
if( nRight >= nDiff )
nRight -= nDiff;
@@ -337,7 +303,7 @@ void SwFormatTablePage::ModifyHdl(const Edit * pEdit)
}
}
//centered: change both sides equally
- else if(m_pCenterBtn->IsChecked())
+ else if (m_xCenterBtn->get_active())
{
if(nLeft != nRight)
{
@@ -352,13 +318,13 @@ void SwFormatTablePage::ModifyHdl(const Edit * pEdit)
}
}
//free alignment: decrease both margins
- else if(m_pFreeBtn->IsChecked())
+ else if (m_xFreeBtn->get_active())
{
nLeft -= nDiff/2;
nRight -= nDiff/2;
}
}
- if (pEdit == m_aRightMF.get())
+ if (&rEdit == m_xRightMF->get())
{
if( nRight + nLeft > pTableData->GetSpace() - MINLAY )
@@ -366,11 +332,11 @@ void SwFormatTablePage::ModifyHdl(const Edit * pEdit)
nCurWidth = pTableData->GetSpace() - nLeft - nRight;
}
- if (pEdit == m_aLeftMF.get())
+ if (&rEdit == m_xLeftMF->get())
{
- if(!m_pFromLeftBtn->IsChecked())
+ if(!m_xFromLeftBtn->get_active())
{
- bool bCenter = m_pCenterBtn->IsChecked();
+ bool bCenter = m_xCenterBtn->get_active();
if( bCenter )
nRight = nLeft;
if(nRight + nLeft > pTableData->GetSpace() - MINLAY )
@@ -392,58 +358,55 @@ void SwFormatTablePage::ModifyHdl(const Edit * pEdit)
}
}
if (nCurWidth != nPrevWidth )
- m_aWidthMF.SetPrcntValue( m_aWidthMF.NormalizePercent( nCurWidth ), FUNIT_TWIP );
- m_aRightMF.SetPrcntValue( m_aRightMF.NormalizePercent( nRight ), FUNIT_TWIP );
- m_aLeftMF.SetPrcntValue( m_aLeftMF.NormalizePercent( nLeft ), FUNIT_TWIP );
+ m_xWidthMF->SetPrcntValue( m_xWidthMF->NormalizePercent( nCurWidth ), FUNIT_TWIP );
+ m_xRightMF->SetPrcntValue( m_xRightMF->NormalizePercent( nRight ), FUNIT_TWIP );
+ m_xLeftMF->SetPrcntValue( m_xLeftMF->NormalizePercent( nLeft ), FUNIT_TWIP );
bModified = true;
}
-VclPtr<SfxTabPage> SwFormatTablePage::Create( TabPageParent pParent,
- const SfxItemSet* rAttrSet)
+VclPtr<SfxTabPage> SwFormatTablePage::Create(TabPageParent pParent, const SfxItemSet* rAttrSet)
{
- return VclPtr<SwFormatTablePage>::Create( pParent.pParent, *rAttrSet );
+ return VclPtr<SwFormatTablePage>::Create(pParent, *rAttrSet);
}
bool SwFormatTablePage::FillItemSet( SfxItemSet* rCoreSet )
{
//Test if one of the controls still has the focus
- if (m_aWidthMF.HasFocus())
- ModifyHdl(m_aWidthMF.get());
- else if (m_aLeftMF.HasFocus())
- ModifyHdl(m_aLeftMF.get());
- else if(m_aRightMF.HasFocus())
- ModifyHdl(m_aRightMF.get());
- else if(m_pTopMF->HasFocus())
- ModifyHdl(m_pTopMF);
- else if(m_pBottomMF->HasFocus())
- ModifyHdl(m_pBottomMF);
-
- if(bModified)
- {
- if( m_pBottomMF->IsValueChangedFromSaved() ||
- m_pTopMF->IsValueChangedFromSaved() )
+ if (m_xWidthMF->has_focus())
+ ModifyHdl(*m_xWidthMF->get());
+ else if (m_xLeftMF->has_focus())
+ ModifyHdl(*m_xLeftMF->get());
+ else if (m_xRightMF->has_focus())
+ ModifyHdl(*m_xRightMF->get());
+ else if (m_xTopMF->has_focus())
+ ModifyHdl(*m_xTopMF);
+ else if (m_xBottomMF->has_focus())
+ ModifyHdl(*m_xBottomMF);
+
+ if (bModified)
+ {
+ if (m_xBottomMF->get_value_changed_from_saved() ||
+ m_xTopMF->get_value_changed_from_saved() )
{
SvxULSpaceItem aULSpace(RES_UL_SPACE);
- aULSpace.SetUpper( m_pTopMF->Denormalize(m_pTopMF->GetValue( FUNIT_TWIP )));
- aULSpace.SetLower( m_pBottomMF->Denormalize(m_pBottomMF->GetValue( FUNIT_TWIP )));
+ aULSpace.SetUpper(m_xTopMF->denormalize(m_xTopMF->get_value(FUNIT_TWIP)));
+ aULSpace.SetLower(m_xBottomMF->denormalize(m_xBottomMF->get_value(FUNIT_TWIP)));
rCoreSet->Put(aULSpace);
}
}
- if(m_pNameED->IsValueChangedFromSaved())
+ if (m_xNameED->get_value_changed_from_saved())
{
- rCoreSet->Put(SfxStringItem( FN_PARAM_TABLE_NAME, m_pNameED->GetText()));
+ rCoreSet->Put(SfxStringItem(FN_PARAM_TABLE_NAME, m_xNameED->get_text()));
bModified = true;
}
- if( m_pTextDirectionLB->IsVisible() )
+ if (m_xTextDirectionLB->get_visible())
{
- const sal_Int32 nPos = m_pTextDirectionLB->GetSelectedEntryPos();
- if ( m_pTextDirectionLB->IsValueChangedFromSaved() )
+ if (m_xTextDirectionLB->get_value_changed_from_saved())
{
- SvxFrameDirection nDirection = static_cast<SvxFrameDirection>(
- reinterpret_cast<sal_IntPtr>(m_pTextDirectionLB->GetEntryData( nPos )));
- rCoreSet->Put( SvxFrameDirectionItem( nDirection, RES_FRAMEDIR));
+ SvxFrameDirection nDirection = m_xTextDirectionLB->get_active_id();
+ rCoreSet->Put(SvxFrameDirectionItem(nDirection, RES_FRAMEDIR));
bModified = true;
}
}
@@ -458,25 +421,25 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
if(bHtmlMode)
{
- m_pNameED->Disable();
- m_pTopFT->Hide();
- m_pTopMF->Hide();
- m_pBottomFT->Hide();
- m_pBottomMF->Hide();
- m_pFreeBtn->Enable(false);
+ m_xNameED->set_sensitive(false);
+ m_xTopFT->hide();
+ m_xTopMF->hide();
+ m_xBottomFT->hide();
+ m_xBottomMF->hide();
+ m_xFreeBtn->set_sensitive(false);
}
FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
- m_aWidthMF.SetMetric(aMetric);
- m_aRightMF.SetMetric(aMetric);
- m_aLeftMF.SetMetric(aMetric);
- SetMetric(*m_pTopMF, aMetric);
- SetMetric(*m_pBottomMF, aMetric);
+ m_xWidthMF->SetMetric(aMetric);
+ m_xRightMF->SetMetric(aMetric);
+ m_xLeftMF->SetMetric(aMetric);
+ SetFieldUnit(*m_xTopMF, aMetric);
+ SetFieldUnit(*m_xBottomMF, aMetric);
//Name
if(SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, false, &pItem ))
{
- m_pNameED->SetText(static_cast<const SfxStringItem*>(pItem)->GetValue());
- m_pNameED->SaveValue();
+ m_xNameED->set_text(static_cast<const SfxStringItem*>(pItem)->GetValue());
+ m_xNameED->save_value();
}
if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP, false, &pItem ))
@@ -486,85 +449,82 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
if(pTableData->GetWidthPercent())
{
- m_pRelWidthCB->Check();
- RelWidthClickHdl(m_pRelWidthCB);
- m_aWidthMF.SetPrcntValue(pTableData->GetWidthPercent(), FUNIT_CUSTOM);
+ m_xRelWidthCB->set_active(true);
+ RelWidthClickHdl(*m_xRelWidthCB);
+ m_xWidthMF->SetPrcntValue(pTableData->GetWidthPercent(), FUNIT_PERCENT);
- m_aWidthMF.SaveValue();
- nSaveWidth = static_cast< SwTwips >(m_aWidthMF.GetValue(FUNIT_CUSTOM));
+ m_xWidthMF->save_value();
+ nSaveWidth = static_cast< SwTwips >(m_xWidthMF->get_value(FUNIT_PERCENT));
}
else
{
- m_aWidthMF.SetPrcntValue(m_aWidthMF.NormalizePercent(
+ m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(
pTableData->GetWidth()), FUNIT_TWIP);
- m_aWidthMF.SaveValue();
+ m_xWidthMF->save_value();
nSaveWidth = pTableData->GetWidth();
nMinTableWidth = std::min( nSaveWidth, nMinTableWidth );
}
- m_aWidthMF.SetRefValue(pTableData->GetSpace());
- m_aWidthMF.SetLast(m_aWidthMF.NormalizePercent( pTableData->GetSpace() ));
- m_aLeftMF.SetLast(m_aLeftMF.NormalizePercent( pTableData->GetSpace() ));
- m_aRightMF.SetLast(m_aRightMF.NormalizePercent( pTableData->GetSpace() ));
+ m_xWidthMF->SetRefValue(pTableData->GetSpace());
- m_aLeftMF.SetPrcntValue(m_aLeftMF.NormalizePercent(
+ m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(
pTableData->GetLeftSpace()), FUNIT_TWIP);
- m_aRightMF.SetPrcntValue(m_aRightMF.NormalizePercent(
+ m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(
pTableData->GetRightSpace()), FUNIT_TWIP);
- m_aLeftMF.SaveValue();
- m_aRightMF.SaveValue();
+ m_xLeftMF->save_value();
+ m_xRightMF->save_value();
bool bSetRight = false, bSetLeft = false;
switch( pTableData->GetAlign() )
{
case text::HoriOrientation::NONE:
- m_pFreeBtn->Check();
- if(m_pRelWidthCB->IsChecked())
+ m_xFreeBtn->set_active(true);
+ if (m_xRelWidthCB->get_active())
bSetRight = true;
break;
case text::HoriOrientation::FULL:
{
bSetRight = bSetLeft = true;
- m_pFullBtn->Check();
- m_aWidthMF.Enable(false);
- m_pRelWidthCB->Enable(false);
- m_pWidthFT->Enable(false);
+ m_xFullBtn->set_active(true);
+ m_xWidthMF->set_sensitive(false);
+ m_xRelWidthCB->set_sensitive(false);
+ m_xWidthFT->set_sensitive(false);
}
break;
case text::HoriOrientation::LEFT:
{
bSetLeft = true;
- m_pLeftBtn->Check();
+ m_xLeftBtn->set_active(true);
}
break;
case text::HoriOrientation::LEFT_AND_WIDTH :
{
bSetRight = true;
- m_pFromLeftBtn->Check();
+ m_xFromLeftBtn->set_active(true);
}
break;
case text::HoriOrientation::RIGHT:
{
bSetRight = true;
- m_pRightBtn->Check();
+ m_xRightBtn->set_active(true);
}
break;
case text::HoriOrientation::CENTER:
{
bSetRight = true;
- m_pCenterBtn->Check();
+ m_xCenterBtn->set_active(true);
}
break;
}
if ( bSetRight )
{
- m_aRightMF.Enable(false);
- m_pRightFT->Enable(false);
+ m_xRightMF->set_sensitive(false);
+ m_xRightFT->set_sensitive(false);
}
if ( bSetLeft )
{
- m_aLeftMF.Enable(false);
- m_pLeftFT->Enable(false);
+ m_xLeftMF->set_sensitive(false);
+ m_xLeftFT->set_sensitive(false);
}
}
@@ -572,28 +532,26 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
//Margins
if(SfxItemState::SET == rSet.GetItemState( RES_UL_SPACE, false,&pItem ))
{
- m_pTopMF->SetValue(m_pTopMF->Normalize(
+ m_xTopMF->set_value(m_xTopMF->normalize(
static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()), FUNIT_TWIP);
- m_pBottomMF->SetValue(m_pBottomMF->Normalize(
+ m_xBottomMF->set_value(m_xBottomMF->normalize(
static_cast<const SvxULSpaceItem*>(pItem)->GetLower()), FUNIT_TWIP);
- m_pTopMF->SaveValue();
- m_pBottomMF->SaveValue();
+ m_xTopMF->save_value();
+ m_xBottomMF->save_value();
}
//Text direction
if( SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, true, &pItem ) )
{
- SvxFrameDirection nVal = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
- const sal_Int32 nPos = m_pTextDirectionLB->GetEntryPos( reinterpret_cast<void*>(nVal) );
- m_pTextDirectionLB->SelectEntryPos( nPos );
- m_pTextDirectionLB->SaveValue();
+ SvxFrameDirection nVal = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
+ m_xTextDirectionLB->set_active_id(nVal);
+ m_xTextDirectionLB->save_value();
}
- m_aWidthMF.SetMax( 2*m_aWidthMF.NormalizePercent( pTableData->GetSpace() ), FUNIT_TWIP );
- m_aRightMF.SetMax( m_aRightMF.NormalizePercent( pTableData->GetSpace() ), FUNIT_TWIP );
- m_aLeftMF.SetMax( m_aLeftMF.NormalizePercent( pTableData->GetSpace() ), FUNIT_TWIP );
- m_aWidthMF.SetMin( m_aWidthMF.NormalizePercent( nMinTableWidth ), FUNIT_TWIP );
-
+ m_xWidthMF->set_max( 2*m_xWidthMF->NormalizePercent( pTableData->GetSpace() ), FUNIT_TWIP );
+ m_xRightMF->set_max( m_xRightMF->NormalizePercent( pTableData->GetSpace() ), FUNIT_TWIP );
+ m_xLeftMF->set_max( m_xLeftMF->NormalizePercent( pTableData->GetSpace() ), FUNIT_TWIP );
+ m_xWidthMF->set_min( m_xWidthMF->NormalizePercent( nMinTableWidth ), FUNIT_TWIP );
}
void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
@@ -605,37 +563,36 @@ void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
pTableData->GetWidth() :
pTableData->GetSpace();
if(pTableData->GetWidthPercent() == 0 &&
- nCurWidth != m_aWidthMF.DenormalizePercent(m_aWidthMF.GetValue(FUNIT_TWIP )))
+ nCurWidth != m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FUNIT_TWIP)))
{
- m_aWidthMF.SetPrcntValue(m_aWidthMF.NormalizePercent(
+ m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(
nCurWidth), FUNIT_TWIP);
- m_aWidthMF.SaveValue();
+ m_xWidthMF->save_value();
nSaveWidth = nCurWidth;
- m_aLeftMF.SetPrcntValue(m_aLeftMF.NormalizePercent(
+ m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(
pTableData->GetLeftSpace()), FUNIT_TWIP);
- m_aLeftMF.SaveValue();
- m_aRightMF.SetPrcntValue(m_aRightMF.NormalizePercent(
+ m_xLeftMF->save_value();
+ m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(
pTableData->GetRightSpace()), FUNIT_TWIP);
- m_aRightMF.SaveValue();
+ m_xRightMF->save_value();
}
}
-
}
DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
{
//os: VCL doesn't take care of making the active widget
//in the dialog lose the focus
- m_pNameED->GrabFocus();
+ m_xNameED->grab_focus();
//test the table name for spaces
- OUString sTableName = m_pNameED->GetText();
+ OUString sTableName = m_xNameED->get_text();
if(sTableName.indexOf(' ') != -1)
{
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_WRONG_TABLENAME)));
xInfoBox->run();
- m_pNameED->GrabFocus();
+ m_xNameED->grab_focus();
return DeactivateRC::KeepPage;
}
if(_pSet)
@@ -643,11 +600,11 @@ DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
FillItemSet(_pSet);
if(bModified)
{
- SwTwips lLeft = static_cast< SwTwips >(m_aLeftMF.DenormalizePercent(m_aLeftMF.GetValue( FUNIT_TWIP )));
- SwTwips lRight = static_cast< SwTwips >(m_aRightMF.DenormalizePercent(m_aRightMF.GetValue( FUNIT_TWIP )));
+ SwTwips lLeft = static_cast< SwTwips >(m_xLeftMF->DenormalizePercent(m_xLeftMF->get_value(FUNIT_TWIP)));
+ SwTwips lRight = static_cast< SwTwips >(m_xRightMF->DenormalizePercent(m_xRightMF->get_value(FUNIT_TWIP)));
- if( m_aLeftMF.GetText() != m_aLeftMF.GetSavedValue() ||
- m_aRightMF.GetText() != m_aRightMF.GetSavedValue() )
+ if( m_xLeftMF->get_value_changed_from_saved() ||
+ m_xRightMF->get_value_changed_from_saved() )
{
pTableData->SetWidthChanged();
pTableData->SetLeftSpace( lLeft);
@@ -655,10 +612,10 @@ DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
}
SwTwips lWidth;
- if (m_pRelWidthCB->IsChecked() && m_pRelWidthCB->IsEnabled())
+ if (m_xRelWidthCB->get_active() && m_xRelWidthCB->get_sensitive())
{
lWidth = pTableData->GetSpace() - lRight - lLeft;
- const sal_uInt16 nPercentWidth = m_aWidthMF.GetValue(FUNIT_CUSTOM);
+ const sal_uInt16 nPercentWidth = m_xWidthMF->get_value(FUNIT_PERCENT);
if(pTableData->GetWidthPercent() != nPercentWidth)
{
pTableData->SetWidthPercent(nPercentWidth);
@@ -668,7 +625,7 @@ DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
else
{
pTableData->SetWidthPercent(0);
- lWidth = static_cast< SwTwips >(m_aWidthMF.DenormalizePercent(m_aWidthMF.GetValue( FUNIT_TWIP )));
+ lWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FUNIT_TWIP)));
}
pTableData->SetWidth(lWidth);
@@ -705,17 +662,17 @@ DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
}
sal_Int16 nAlign = 0;
- if(m_pRightBtn->IsChecked())
+ if (m_xRightBtn->get_active())
nAlign = text::HoriOrientation::RIGHT;
- else if(m_pLeftBtn->IsChecked())
+ else if(m_xLeftBtn->get_active())
nAlign = text::HoriOrientation::LEFT;
- else if(m_pFromLeftBtn->IsChecked())
+ else if(m_xFromLeftBtn->get_active())
nAlign = text::HoriOrientation::LEFT_AND_WIDTH;
- else if(m_pCenterBtn->IsChecked())
+ else if(m_xCenterBtn->get_active())
nAlign = text::HoriOrientation::CENTER;
- else if(m_pFreeBtn->IsChecked())
+ else if(m_xFreeBtn->get_active())
nAlign = text::HoriOrientation::NONE;
- else if(m_pFullBtn->IsChecked())
+ else if(m_xFullBtn->get_active())
{
nAlign = text::HoriOrientation::FULL;
lWidth = lAutoWidth;
diff --git a/sw/source/uibase/inc/prcntfld.hxx b/sw/source/uibase/inc/prcntfld.hxx
index 06021f4fb52e..dc7436500e64 100644
--- a/sw/source/uibase/inc/prcntfld.hxx
+++ b/sw/source/uibase/inc/prcntfld.hxx
@@ -19,11 +19,12 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_PRCNTFLD_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_PRCNTFLD_HXX
+#include <svtools/unitconv.hxx>
#include <vcl/field.hxx>
+#include <vcl/weld.hxx>
#include <swdllapi.h>
#include "uitool.hxx"
-//Wraps a MetricField with extra features, preferred to PercentField
class SW_DLLPUBLIC PercentField
{
VclPtr<MetricField> m_pField;
@@ -100,6 +101,73 @@ public:
void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
};
+class SW_DLLPUBLIC SwPercentField
+{
+ std::unique_ptr<weld::MetricSpinButton> m_pField;
+
+ int nRefValue; // 100% value for conversion (in Twips)
+ int nOldMax;
+ int nOldMin;
+ int nOldSpinSize;
+ int nOldPageSize;
+ int nLastPercent;
+ int nLastValue;
+ sal_uInt16 nOldDigits;
+ FieldUnit eOldUnit;
+ bool bLockAutoCalculation; //prevent recalculation of percent values when the
+ //reference value is changed
+
+ SAL_DLLPRIVATE static int ImpPower10(sal_uInt16 n);
+
+public:
+
+ SwPercentField(weld::MetricSpinButton* pControl);
+ const weld::MetricSpinButton* get() const { return m_pField.get(); }
+ weld::MetricSpinButton* get() { return m_pField.get(); }
+ void connect_value_changed(const Link<weld::MetricSpinButton&, void>& rLink) { m_pField->connect_value_changed(rLink); }
+ void SetMetric(FieldUnit eUnit) { ::SetFieldUnit(*m_pField, eUnit); }
+ void set_sensitive(bool bEnable) { m_pField->set_sensitive(bEnable); }
+ bool has_focus() const { return m_pField->has_focus(); }
+ void set_accessible_name(const OUString& rName) { m_pField->set_accessible_name(rName); }
+ void set_text(const OUString& rStr) { m_pField->set_text(rStr); }
+ void save_value() { m_pField->save_value(); }
+ bool get_value_changed_from_saved() const { return m_pField->get_value_changed_from_saved(); }
+ OUString get_text() const { return m_pField->get_text(); }
+ void SetMetricFieldMin(int nNewMin) { m_pField->set_min(nNewMin, FUNIT_NONE); }
+ void SetMetricFieldMax(int nNewMax) { m_pField->set_max(nNewMax, FUNIT_NONE); }
+ int GetMetrixFieldMin() const { int nMin, nMax; m_pField->get_range(nMin, nMax, FUNIT_NONE); return nMin; }
+
+ void set_value(int nNewValue) { m_pField->set_value(nNewValue, FUNIT_NONE); }
+
+ void SetPrcntValue(int nNewValue, FieldUnit eInUnit = FUNIT_NONE);
+
+ void SetUserValue(int nNewValue, FieldUnit eInUnit);
+
+ void SetBaseValue(int nNewValue, FieldUnit eInUnit);
+
+ int get_value(FieldUnit eOutUnit = FUNIT_NONE);
+
+ bool IsValueModified();
+
+ void set_min(int nNewMin, FieldUnit eInUnit);
+ void set_max(int nNewMax, FieldUnit eInUnit);
+
+ int NormalizePercent(int nValue);
+ int DenormalizePercent(int nValue);
+
+ int normalize(int nValue) const { return m_pField->normalize(nValue); }
+
+ void SetRefValue(int nValue);
+ int GetRealValue(FieldUnit eOutUnit);
+
+ int Convert(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
+
+ void ShowPercent(bool bPercent);
+
+ void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
+};
+
+
#endif // INCLUDED_SW_SOURCE_UIBASE_INC_PRCNTFLD_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/table/tablepg.hxx b/sw/source/uibase/table/tablepg.hxx
index 4e7319d405ae..975684ce572a 100644
--- a/sw/source/uibase/table/tablepg.hxx
+++ b/sw/source/uibase/table/tablepg.hxx
@@ -38,29 +38,6 @@ struct TColumn
class SwFormatTablePage : public SfxTabPage
{
- VclPtr<Edit> m_pNameED;
- VclPtr<FixedText> m_pWidthFT;
- PercentField m_aWidthMF;
- VclPtr<CheckBox> m_pRelWidthCB;
-
- VclPtr<RadioButton> m_pFullBtn;
- VclPtr<RadioButton> m_pLeftBtn;
- VclPtr<RadioButton> m_pFromLeftBtn;
- VclPtr<RadioButton> m_pRightBtn;
- VclPtr<RadioButton> m_pCenterBtn;
- VclPtr<RadioButton> m_pFreeBtn;
-
- VclPtr<FixedText> m_pLeftFT;
- PercentField m_aLeftMF;
- VclPtr<FixedText> m_pRightFT;
- PercentField m_aRightMF;
- VclPtr<FixedText> m_pTopFT;
- VclPtr<MetricField> m_pTopMF;
- VclPtr<FixedText> m_pBottomFT;
- VclPtr<MetricField> m_pBottomMF;
-
- VclPtr<svx::FrameDirectionListBox> m_pTextDirectionLB;
-
SwTableRep* pTableData;
SwTwips nSaveWidth;
SwTwips nMinTableWidth;
@@ -68,22 +45,44 @@ class SwFormatTablePage : public SfxTabPage
bool bFull:1;
bool bHtmlMode : 1;
+ std::unique_ptr<weld::Entry> m_xNameED;
+ std::unique_ptr<weld::Label> m_xWidthFT;
+ std::unique_ptr<SwPercentField> m_xWidthMF;
+ std::unique_ptr<weld::CheckButton> m_xRelWidthCB;
+
+ std::unique_ptr<weld::RadioButton> m_xFullBtn;
+ std::unique_ptr<weld::RadioButton> m_xLeftBtn;
+ std::unique_ptr<weld::RadioButton> m_xFromLeftBtn;
+ std::unique_ptr<weld::RadioButton> m_xRightBtn;
+ std::unique_ptr<weld::RadioButton> m_xCenterBtn;
+ std::unique_ptr<weld::RadioButton> m_xFreeBtn;
+
+ std::unique_ptr<weld::Label> m_xLeftFT;
+ std::unique_ptr<SwPercentField> m_xLeftMF;
+ std::unique_ptr<weld::Label> m_xRightFT;
+ std::unique_ptr<SwPercentField> m_xRightMF;
+ std::unique_ptr<weld::Label> m_xTopFT;
+ std::unique_ptr<weld::MetricSpinButton> m_xTopMF;
+ std::unique_ptr<weld::Label> m_xBottomFT;
+ std::unique_ptr<weld::MetricSpinButton> m_xBottomMF;
+
+ std::unique_ptr<svx::SvxFrameDirectionListBox> m_xTextDirectionLB;
+ std::unique_ptr<weld::Widget> m_xProperties;
+
void Init();
- void ModifyHdl(const Edit* pEdit);
+ void ModifyHdl(const weld::MetricSpinButton& rEdit);
- DECL_LINK( AutoClickHdl, Button*, void );
- DECL_LINK( RelWidthClickHdl, Button*, void );
+ DECL_LINK(AutoClickHdl, weld::ToggleButton&, void);
+ DECL_LINK(RelWidthClickHdl, weld::ToggleButton&, void);
void RightModify();
- DECL_LINK( UpDownHdl, SpinField&, void );
- DECL_LINK( LoseFocusHdl, Control&, void );
+ DECL_LINK(UpDownHdl, weld::MetricSpinButton&, void);
using TabPage::ActivatePage;
using TabPage::DeactivatePage;
public:
- SwFormatTablePage( vcl::Window* pParent, const SfxItemSet& rSet );
+ SwFormatTablePage(TabPageParent pParent, const SfxItemSet& rSet );
virtual ~SwFormatTablePage() override;
- virtual void dispose() override;
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rAttrSet);
virtual bool FillItemSet( SfxItemSet* rSet ) override;
diff --git a/sw/source/uibase/utlui/prcntfld.cxx b/sw/source/uibase/utlui/prcntfld.cxx
index 9eb5d06dbc35..a67898c43789 100644
--- a/sw/source/uibase/utlui/prcntfld.cxx
+++ b/sw/source/uibase/utlui/prcntfld.cxx
@@ -279,4 +279,219 @@ sal_Int64 PercentField::Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit e
return MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit);
}
+SwPercentField::SwPercentField(weld::MetricSpinButton* pControl)
+ : m_pField(pControl)
+ , nOldMax(0)
+ , nOldMin(0)
+ , nLastPercent(-1)
+ , nLastValue(-1)
+ , nOldDigits(m_pField->get_digits())
+ , eOldUnit(FUNIT_NONE)
+ , bLockAutoCalculation(false)
+{
+ int nMin, nMax;
+ m_pField->get_range(nMin, nMax, FUNIT_TWIP);
+ nRefValue = DenormalizePercent(nMax);
+ m_pField->get_increments(nOldSpinSize, nOldPageSize, FUNIT_NONE);
+}
+
+void SwPercentField::SetRefValue(int nValue)
+{
+ int nRealValue = GetRealValue(eOldUnit);
+
+ nRefValue = nValue;
+
+ if (!bLockAutoCalculation && (m_pField->get_unit() == FUNIT_PERCENT))
+ SetPrcntValue(nRealValue, eOldUnit);
+}
+
+void SwPercentField::ShowPercent(bool bPercent)
+{
+ if ((bPercent && m_pField->get_unit() == FUNIT_PERCENT) ||
+ (!bPercent && m_pField->get_unit() != FUNIT_PERCENT))
+ return;
+
+ int nOldValue;
+
+ if (bPercent)
+ {
+ int nCurrentWidth, nPercent;
+
+ nOldValue = get_value();
+
+ eOldUnit = m_pField->get_unit();
+ nOldDigits = m_pField->get_digits();
+ m_pField->get_range(nOldMin, nOldMax, FUNIT_NONE);
+ m_pField->get_increments(nOldSpinSize, nOldPageSize, FUNIT_NONE);
+ m_pField->set_unit(FUNIT_PERCENT);
+ m_pField->set_digits(0);
+
+ nCurrentWidth = MetricField::ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ // round to 0.5 percent
+ nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
+
+ m_pField->set_range(std::max(1, nPercent), 100, FUNIT_NONE);
+ m_pField->set_increments(5, 10, FUNIT_NONE);
+ if (nOldValue != nLastValue)
+ {
+ nCurrentWidth = MetricField::ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
+ m_pField->set_value(nPercent, FUNIT_NONE);
+ nLastPercent = nPercent;
+ nLastValue = nOldValue;
+ }
+ else
+ m_pField->set_value(nLastPercent, FUNIT_NONE);
+ }
+ else
+ {
+ int nOldPercent = get_value(FUNIT_PERCENT);
+
+ nOldValue = Convert(get_value(), m_pField->get_unit(), eOldUnit);
+
+ m_pField->set_unit(eOldUnit);
+ m_pField->set_digits(nOldDigits);
+ m_pField->set_range(nOldMin, nOldMax, FUNIT_NONE);
+ m_pField->set_increments(nOldSpinSize, nOldPageSize, FUNIT_NONE);
+
+ if (nOldPercent != nLastPercent)
+ {
+ SetPrcntValue(nOldValue, eOldUnit);
+ nLastPercent = nOldPercent;
+ nLastValue = nOldValue;
+ }
+ else
+ SetPrcntValue(nLastValue, eOldUnit);
+ }
+}
+
+void SwPercentField::SetPrcntValue(int nNewValue, FieldUnit eInUnit)
+{
+ if (m_pField->get_unit() != FUNIT_PERCENT || eInUnit == FUNIT_PERCENT)
+ m_pField->set_value(Convert(nNewValue, eInUnit, m_pField->get_unit()), FUNIT_NONE);
+ else
+ {
+ // Overwrite output value, do not restore later
+ int nPercent, nCurrentWidth;
+ if(eInUnit == FUNIT_TWIP)
+ {
+ nCurrentWidth = MetricField::ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP);
+ }
+ else
+ {
+ int nValue = Convert(nNewValue, eInUnit, eOldUnit);
+ nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ }
+ nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
+ m_pField->set_value(nPercent, FUNIT_NONE);
+ }
+}
+
+int SwPercentField::get_value(FieldUnit eOutUnit)
+{
+ return Convert(m_pField->get_value(FUNIT_NONE), m_pField->get_unit(), eOutUnit);
+}
+
+void SwPercentField::set_min(int nNewMin, FieldUnit eInUnit)
+{
+ if (m_pField->get_unit() != FUNIT_PERCENT)
+ m_pField->set_min(nNewMin, eInUnit);
+ else
+ {
+ if (eInUnit == FUNIT_NONE)
+ eInUnit = eOldUnit;
+ nOldMin = Convert(nNewMin, eInUnit, eOldUnit);
+
+ int nPercent = Convert(nNewMin, eInUnit, FUNIT_PERCENT);
+ m_pField->set_min(std::max(1, nPercent), FUNIT_NONE);
+ }
+}
+
+void SwPercentField::set_max(int nNewMax, FieldUnit eInUnit)
+{
+ if (m_pField->get_unit() != FUNIT_PERCENT)
+ m_pField->set_max(nNewMax, eInUnit);
+}
+
+int SwPercentField::NormalizePercent(int nValue)
+{
+ if (m_pField->get_unit() != FUNIT_PERCENT)
+ nValue = m_pField->normalize(nValue);
+ else
+ nValue = nValue * ImpPower10(nOldDigits);
+ return nValue;
+}
+
+int SwPercentField::DenormalizePercent(int nValue)
+{
+ if (m_pField->get_unit() != FUNIT_PERCENT)
+ nValue = m_pField->denormalize(nValue);
+ else
+ {
+ int nFactor = ImpPower10(nOldDigits);
+ nValue = ((nValue+(nFactor/2)) / nFactor);
+ }
+ return nValue;
+}
+
+bool SwPercentField::IsValueModified()
+{
+ if (m_pField->get_unit() == FUNIT_PERCENT)
+ return true;
+ else
+ return m_pField->get_value_changed_from_saved();
+}
+
+int SwPercentField::ImpPower10(sal_uInt16 n)
+{
+ int nValue = 1;
+
+ for (sal_uInt16 i=0; i < n; ++i)
+ nValue *= 10;
+
+ return nValue;
+}
+
+int SwPercentField::GetRealValue(FieldUnit eOutUnit)
+{
+ if (m_pField->get_unit() != FUNIT_PERCENT)
+ return get_value(eOutUnit);
+ else
+ return Convert(get_value(), m_pField->get_unit(), eOutUnit);
+}
+
+int SwPercentField::Convert(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit)
+{
+ if (eInUnit == eOutUnit ||
+ (eInUnit == FUNIT_NONE && eOutUnit == m_pField->get_unit()) ||
+ (eOutUnit == FUNIT_NONE && eInUnit == m_pField->get_unit()))
+ return nValue;
+
+ if (eInUnit == FUNIT_PERCENT)
+ {
+ // Convert to metric
+ int nTwipValue = (nRefValue * nValue + 50) / 100;
+
+ if (eOutUnit == FUNIT_TWIP) // Only convert if necessary
+ return NormalizePercent(nTwipValue);
+ else
+ return MetricField::ConvertValue(NormalizePercent(nTwipValue), 0, nOldDigits, FUNIT_TWIP, eOutUnit);
+ }
+
+ if (eOutUnit == FUNIT_PERCENT)
+ {
+ // Convert to percent
+ int nCurrentWidth;
+ nValue = DenormalizePercent(nValue);
+
+ if (eInUnit == FUNIT_TWIP) // Only convert if necessary
+ nCurrentWidth = nValue;
+ else
+ nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, FUNIT_TWIP);
+ // Round to 0.5 percent
+ return ((nCurrentWidth * 1000) / nRefValue + 5) / 10;
+ }
+
+ return MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/formattablepage.ui b/sw/uiconfig/swriter/ui/formattablepage.ui
index 292427157b23..f946acb69c80 100644
--- a/sw/uiconfig/swriter/ui/formattablepage.ui
+++ b/sw/uiconfig/swriter/ui/formattablepage.ui
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
- <!-- interface-requires LibreOffice 1.0 -->
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">99.989999999999995</property>
<property name="step_increment">0.050000000000000003</property>
@@ -14,6 +13,22 @@
<property name="step_increment">0.050000000000000003</property>
<property name="page_increment">1</property>
</object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="lower">-99.989999999999995</property>
+ <property name="upper">99.989999999999995</property>
+ <property name="step_increment">0.050000000000000003</property>
+ <property name="page_increment">1</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment4">
+ <property name="upper">99.989999999999995</property>
+ <property name="step_increment">0.050000000000000003</property>
+ <property name="page_increment">1</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment5">
+ <property name="upper">99.989999999999995</property>
+ <property name="step_increment">0.050000000000000003</property>
+ <property name="page_increment">1</property>
+ </object>
<object class="GtkGrid" id="FormatTablePage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -59,32 +74,28 @@
<object class="GtkLabel" id="nameft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="formattablepage|nameft">_Name</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">name</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="widthft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="formattablepage|widthft">W_idth</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">widthmf:0.00cm</property>
+ <property name="mnemonic_widget">widthmf</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -92,12 +103,11 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -118,30 +128,25 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="widthmf:0.00cm">
+ <object class="GtkSpinButton" id="widthmf">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
<property name="adjustment">adjustment1</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -162,8 +167,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -188,125 +191,113 @@
<object class="GtkLabel" id="leftft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.50999999046325684</property>
<property name="xpad">1</property>
<property name="label" translatable="yes" context="formattablepage|leftft">Lef_t</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">leftmf:0.00cm</property>
+ <property name="mnemonic_widget">leftmf</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.50999999046325684</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="rightft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="formattablepage|rightft">Ri_ght</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">rightmf:0.00cm</property>
+ <property name="mnemonic_widget">rightmf</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="aboveft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
<property name="label" translatable="yes" context="formattablepage|aboveft">_Above</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">abovemf:0.00cm</property>
+ <property name="mnemonic_widget">abovemf</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="belowft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="xpad">1</property>
<property name="label" translatable="yes" context="formattablepage|belowft">_Below</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">belowmf:0.00cm</property>
+ <property name="mnemonic_widget">belowmf</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="leftmf:0.00cm">
+ <object class="GtkSpinButton" id="leftmf">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
<property name="adjustment">adjustment2</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="rightmf:0.00cm">
+ <object class="GtkSpinButton" id="rightmf">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">adjustment2</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment3</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="abovemf:0.00cm">
+ <object class="GtkSpinButton" id="abovemf">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">adjustment1</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment4</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="belowmf:0.00cm">
+ <object class="GtkSpinButton" id="belowmf">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">adjustment1</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment5</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -327,16 +318,12 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -365,14 +352,12 @@
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">left</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -384,13 +369,11 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">fromleft</property>
+ <property name="group">full</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -402,13 +385,11 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">right</property>
+ <property name="group">full</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -419,15 +400,12 @@
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">center</property>
+ <property name="group">full</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -439,13 +417,11 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">free</property>
+ <property name="group">full</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -462,8 +438,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -485,16 +459,12 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -518,28 +488,24 @@
<object class="GtkLabel" id="label53">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="formattablepage|label53">Text _direction</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">textdirection</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="svxlo-FrameDirectionListBox" id="textdirection">
+ <object class="GtkComboBoxText" id="textdirection">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -560,8 +526,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -579,11 +543,11 @@
<object class="GtkSizeGroup" id="sizegroup2">
<property name="ignore_hidden">True</property>
<widgets>
- <widget name="widthmf:0.00cm"/>
- <widget name="leftmf:0.00cm"/>
- <widget name="rightmf:0.00cm"/>
- <widget name="abovemf:0.00cm"/>
- <widget name="belowmf:0.00cm"/>
+ <widget name="widthmf"/>
+ <widget name="leftmf"/>
+ <widget name="rightmf"/>
+ <widget name="abovemf"/>
+ <widget name="belowmf"/>
</widgets>
</object>
</interface>