diff options
-rw-r--r-- | avmedia/source/framework/mediacontrol.cxx | 1 | ||||
-rw-r--r-- | include/svx/relfld.hxx | 1 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaSpacingControl.cxx | 10 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaSpacingWindow.cxx | 295 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaSpacingWindow.hxx | 60 | ||||
-rw-r--r-- | svx/uiconfig/ui/paralrspacing.ui | 43 | ||||
-rw-r--r-- | svx/uiconfig/ui/paraulspacing.ui | 25 |
7 files changed, 271 insertions, 164 deletions
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index ddec4f90436d..a9c144b1e455 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -145,6 +145,7 @@ void MediaControl::Resize() vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); assert(pChild); VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); + Control::Resize(); } void MediaControl::setState( const MediaItem& rItem ) diff --git a/include/svx/relfld.hxx b/include/svx/relfld.hxx index 8f8c84dc38f3..7aa6b88d7c5b 100644 --- a/include/svx/relfld.hxx +++ b/include/svx/relfld.hxx @@ -66,6 +66,7 @@ public: void save_value() { m_xSpinButton->save_value(); } bool get_value_changed_from_saved() const { return m_xSpinButton->get_value_changed_from_saved(); } void set_size_request(int nWidth, int nHeight) { m_xSpinButton->set_size_request(nWidth, nHeight); } + void grab_focus() { m_xSpinButton->grab_focus(); } Size get_preferred_size() const { return m_xSpinButton->get_preferred_size(); } weld::SpinButton& get_widget() { return m_xSpinButton->get_widget(); } diff --git a/svx/source/sidebar/paragraph/ParaSpacingControl.cxx b/svx/source/sidebar/paragraph/ParaSpacingControl.cxx index 29ce7e3bbc0d..d097a907aa8a 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingControl.cxx +++ b/svx/source/sidebar/paragraph/ParaSpacingControl.cxx @@ -90,7 +90,7 @@ ParaAboveSpacingControl::ParaAboveSpacingControl(sal_uInt16 nSlotId, sal_uInt16 VclPtr<vcl::Window> ParaAboveSpacingControl::CreateItemWindow(vcl::Window* pParent) { - VclPtr<ParaAboveSpacingWindow> pWindow = VclPtr<ParaAboveSpacingWindow>::Create(pParent, m_xFrame); + VclPtr<ParaAboveSpacingWindow> pWindow = VclPtr<ParaAboveSpacingWindow>::Create(pParent); pWindow->Show(); return pWindow; @@ -105,7 +105,7 @@ ParaBelowSpacingControl::ParaBelowSpacingControl(sal_uInt16 nSlotId, sal_uInt16 VclPtr<vcl::Window> ParaBelowSpacingControl::CreateItemWindow(vcl::Window* pParent) { - VclPtr<ParaBelowSpacingWindow> pWindow = VclPtr<ParaBelowSpacingWindow>::Create(pParent, m_xFrame); + VclPtr<ParaBelowSpacingWindow> pWindow = VclPtr<ParaBelowSpacingWindow>::Create(pParent); pWindow->Show(); return pWindow; @@ -219,7 +219,7 @@ ParaLeftSpacingControl::ParaLeftSpacingControl(sal_uInt16 nSlotId, sal_uInt16 nI VclPtr<vcl::Window> ParaLeftSpacingControl::CreateItemWindow(vcl::Window* pParent) { - VclPtr<ParaLeftSpacingWindow> pWindow = VclPtr<ParaLeftSpacingWindow>::Create(pParent, m_xFrame); + VclPtr<ParaLeftSpacingWindow> pWindow = VclPtr<ParaLeftSpacingWindow>::Create(pParent); pWindow->Show(); return pWindow; @@ -234,7 +234,7 @@ ParaRightSpacingControl::ParaRightSpacingControl(sal_uInt16 nSlotId, sal_uInt16 VclPtr<vcl::Window> ParaRightSpacingControl::CreateItemWindow(vcl::Window* pParent) { - VclPtr<ParaRightSpacingWindow> pWindow = VclPtr<ParaRightSpacingWindow>::Create(pParent, m_xFrame); + VclPtr<ParaRightSpacingWindow> pWindow = VclPtr<ParaRightSpacingWindow>::Create(pParent); pWindow->Show(); return pWindow; @@ -249,7 +249,7 @@ ParaFirstLineSpacingControl::ParaFirstLineSpacingControl(sal_uInt16 nSlotId, sal VclPtr<vcl::Window> ParaFirstLineSpacingControl::CreateItemWindow(vcl::Window* pParent) { - VclPtr<ParaFirstLineSpacingWindow> pWindow = VclPtr<ParaFirstLineSpacingWindow>::Create(pParent, m_xFrame); + VclPtr<ParaFirstLineSpacingWindow> pWindow = VclPtr<ParaFirstLineSpacingWindow>::Create(pParent); pWindow->Show(); return pWindow; diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx index 6dd4f4858c90..8ddbe0949e03 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx @@ -36,23 +36,27 @@ using namespace svx; // ParaULSpacingWindow -ParaULSpacingWindow::ParaULSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : VclVBox(pParent) +ParaULSpacingWindow::ParaULSpacingWindow(vcl::Window* pParent) + : Control(pParent, WB_TABSTOP) , m_eUnit(MapUnit::MapTwip) { - m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), - "svx/ui/paraulspacing.ui", - "ParaULSpacingWindow", - xFrame)); - - get(m_pAboveSpacing, "aboveparaspacing"); - get(m_pBelowSpacing, "belowparaspacing"); - get(m_pAboveContainer, "above"); - get(m_pBelowContainer, "below"); - - Link<Edit&,void> aLink = LINK(this, ParaULSpacingWindow, ModifySpacingHdl); - m_pAboveSpacing->SetModifyHdl(aLink); - m_pBelowSpacing->SetModifyHdl(aLink); + m_xVclContentArea = VclPtr<VclVBox>::Create(this); + m_xVclContentArea->Show(); + m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, "svx/ui/paraulspacing.ui")); + m_xContainer = m_xBuilder->weld_container("ParaULSpacingWindow"); + + m_xAboveSpacing = std::make_unique<RelativeField>(m_xBuilder->weld_metric_spin_button("aboveparaspacing", FieldUnit::CM)); + m_xBelowSpacing = std::make_unique<RelativeField>(m_xBuilder->weld_metric_spin_button("belowparaspacing", FieldUnit::CM)); + m_xAboveContainer = m_xBuilder->weld_container("above"); + m_xBelowContainer = m_xBuilder->weld_container("below"); + + Link<weld::MetricSpinButton&,void> aLink = LINK(this, ParaULSpacingWindow, ModifySpacingHdl); + m_xAboveSpacing->connect_value_changed(aLink); + m_xBelowSpacing->connect_value_changed(aLink); + + /// set the initial values of max width + m_xAboveSpacing->set_max(m_xAboveSpacing->normalize(MAX_DURCH), FieldUnit::CM); + m_xBelowSpacing->set_max(m_xBelowSpacing->normalize(MAX_DURCH), FieldUnit::CM); } ParaULSpacingWindow::~ParaULSpacingWindow() @@ -62,101 +66,126 @@ ParaULSpacingWindow::~ParaULSpacingWindow() void ParaULSpacingWindow::dispose() { - m_pAboveSpacing.clear(); - m_pBelowSpacing.clear(); - m_pAboveContainer.clear(); - m_pBelowContainer.clear(); + m_xAboveSpacing.reset(); + m_xBelowSpacing.reset(); + m_xAboveContainer.reset(); + m_xBelowContainer.reset(); - disposeBuilder(); - VclVBox::dispose(); + m_xContainer.reset(); + m_xBuilder.reset(); + m_xVclContentArea.disposeAndClear(); + + Control::dispose(); } void ParaULSpacingWindow::SetUnit(FieldUnit eUnit) { - SetFieldUnit(*m_pAboveSpacing, eUnit); - SetFieldUnit(*m_pBelowSpacing, eUnit); + m_xAboveSpacing->SetFieldUnit(eUnit); + m_xBelowSpacing->SetFieldUnit(eUnit); SfxItemPool &rPool = SfxGetpApp()->GetPool(); sal_uInt16 nWhich = rPool.GetWhich(SID_ATTR_PARA_ULSPACE); m_eUnit = rPool.GetMetric(nWhich); - m_pAboveSpacing->SetMax(m_pAboveSpacing->Normalize(MAX_DURCH), MapToFieldUnit(m_eUnit)); - m_pBelowSpacing->SetMax(m_pBelowSpacing->Normalize(MAX_DURCH), MapToFieldUnit(m_eUnit)); + m_xAboveSpacing->set_max(m_xAboveSpacing->normalize(MAX_DURCH), MapToFieldUnit(m_eUnit)); + m_xBelowSpacing->set_max(m_xBelowSpacing->normalize(MAX_DURCH), MapToFieldUnit(m_eUnit)); } void ParaULSpacingWindow::SetValue(const SvxULSpaceItem* pItem) { sal_Int64 nVal = pItem->GetUpper(); - nVal = m_pAboveSpacing->Normalize(nVal); - m_pAboveSpacing->SetValue(nVal, FieldUnit::MM_100TH); + nVal = m_xAboveSpacing->normalize(nVal); + m_xAboveSpacing->set_value(nVal, FieldUnit::MM_100TH); nVal = pItem->GetLower(); - nVal = m_pBelowSpacing->Normalize(nVal); - m_pBelowSpacing->SetValue(nVal, FieldUnit::MM_100TH); + nVal = m_xBelowSpacing->normalize(nVal); + m_xBelowSpacing->set_value(nVal, FieldUnit::MM_100TH); } -IMPL_LINK_NOARG(ParaULSpacingWindow, ModifySpacingHdl, Edit&, void) +void ParaULSpacingWindow::Resize() +{ + vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); + assert(pChild); + VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); + Control::Resize(); +} + +Size ParaULSpacingWindow::GetOptimalSize() const +{ + return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); +} + +IMPL_LINK_NOARG(ParaULSpacingWindow, ModifySpacingHdl, weld::MetricSpinButton&, void) { SfxDispatcher* pDisp = SfxViewFrame::Current()->GetBindings().GetDispatcher(); if(pDisp) { SvxULSpaceItem aMargin(SID_ATTR_PARA_ULSPACE); - aMargin.SetUpper(static_cast<sal_uInt16>(GetCoreValue(*m_pAboveSpacing, m_eUnit))); - aMargin.SetLower(static_cast<sal_uInt16>(GetCoreValue(*m_pBelowSpacing, m_eUnit))); + aMargin.SetUpper(m_xAboveSpacing->GetCoreValue(m_eUnit)); + aMargin.SetLower(m_xBelowSpacing->GetCoreValue(m_eUnit)); pDisp->ExecuteList(SID_ATTR_PARA_ULSPACE, SfxCallMode::RECORD, {&aMargin}); } } // ParaAboveSpacingWindow -ParaAboveSpacingWindow::ParaAboveSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : ParaULSpacingWindow(pParent, xFrame) +ParaAboveSpacingWindow::ParaAboveSpacingWindow(vcl::Window* pParent) + : ParaULSpacingWindow(pParent) { - m_pAboveContainer->Show(); - m_pBelowContainer->Hide(); + m_xAboveContainer->show(); + m_xBelowContainer->hide(); + + SetSizePixel(GetOptimalSize()); } void ParaAboveSpacingWindow::GetFocus() { - m_pAboveSpacing->GrabFocus(); + m_xAboveSpacing->grab_focus(); } // ParaBelowSpacingWindow -ParaBelowSpacingWindow::ParaBelowSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : ParaULSpacingWindow(pParent, xFrame) +ParaBelowSpacingWindow::ParaBelowSpacingWindow(vcl::Window* pParent) + : ParaULSpacingWindow(pParent) { - m_pAboveContainer->Hide(); - m_pBelowContainer->Show(); + m_xAboveContainer->hide(); + m_xBelowContainer->show(); + + SetSizePixel(GetOptimalSize()); } void ParaBelowSpacingWindow::GetFocus() { - m_pBelowSpacing->GrabFocus(); + m_xBelowSpacing->grab_focus(); } // ParaLRSpacingWindow -ParaLRSpacingWindow::ParaLRSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : VclVBox(pParent) +ParaLRSpacingWindow::ParaLRSpacingWindow(vcl::Window* pParent) + : Control(pParent, WB_TABSTOP) , m_eUnit(MapUnit::MapTwip) { - m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), - "svx/ui/paralrspacing.ui", - "ParaLRSpacingWindow", - xFrame)); - - get(m_pBeforeSpacing, "beforetextindent"); - get(m_pAfterSpacing, "aftertextindent"); - get(m_pFLSpacing, "firstlineindent"); - get(m_pBeforeContainer, "before"); - get(m_pAfterContainer, "after"); - get(m_pFirstLineContainer, "firstline"); - - Link<Edit&,void> aLink = LINK(this, ParaLRSpacingWindow, ModifySpacingHdl); - m_pBeforeSpacing->SetModifyHdl(aLink); - m_pAfterSpacing->SetModifyHdl(aLink); - m_pFLSpacing->SetModifyHdl(aLink); + m_xVclContentArea = VclPtr<VclVBox>::Create(this); + m_xVclContentArea->Show(); + m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, "svx/ui/paralrspacing.ui")); + m_xContainer = m_xBuilder->weld_container("ParaLRSpacingWindow"); + + m_xBeforeSpacing = std::make_unique<RelativeField>(m_xBuilder->weld_metric_spin_button("beforetextindent", FieldUnit::CM)); + m_xAfterSpacing = std::make_unique<RelativeField>(m_xBuilder->weld_metric_spin_button("aftertextindent", FieldUnit::CM)); + m_xFLSpacing = std::make_unique<RelativeField>(m_xBuilder->weld_metric_spin_button("firstlineindent", FieldUnit::CM)); + m_xBeforeContainer = m_xBuilder->weld_container("before"); + m_xAfterContainer = m_xBuilder->weld_container("after"); + m_xFirstLineContainer = m_xBuilder->weld_container("firstline"); + + Link<weld::MetricSpinButton&,void> aLink = LINK(this, ParaLRSpacingWindow, ModifySpacingHdl); + m_xBeforeSpacing->connect_value_changed(aLink); + m_xAfterSpacing->connect_value_changed(aLink); + m_xFLSpacing->connect_value_changed(aLink); + + /// set the initial values of max width + m_xBeforeSpacing->set_min(NEGA_MAXVALUE, FieldUnit::MM_100TH); + m_xAfterSpacing->set_min(NEGA_MAXVALUE, FieldUnit::MM_100TH); + m_xFLSpacing->set_min(NEGA_MAXVALUE, FieldUnit::MM_100TH); } ParaLRSpacingWindow::~ParaLRSpacingWindow() @@ -166,15 +195,18 @@ ParaLRSpacingWindow::~ParaLRSpacingWindow() void ParaLRSpacingWindow::dispose() { - m_pBeforeSpacing.clear(); - m_pAfterSpacing.clear(); - m_pFLSpacing.clear(); - m_pBeforeContainer.clear(); - m_pAfterContainer.clear(); - m_pFirstLineContainer.clear(); - - disposeBuilder(); - VclVBox::dispose(); + m_xBeforeSpacing.reset(); + m_xAfterSpacing.reset(); + m_xFLSpacing.reset(); + m_xBeforeContainer.reset(); + m_xAfterContainer.reset(); + m_xFirstLineContainer.reset(); + + m_xContainer.reset(); + m_xBuilder.reset(); + m_xVclContentArea.disposeAndClear(); + + Control::dispose(); } void ParaLRSpacingWindow::SetContext(const vcl::EnumContext& eContext) @@ -196,43 +228,43 @@ void ParaLRSpacingWindow::SetValue(SfxItemState eState, const SfxPoolItem* pStat case CombinedEnumContext(Application::DrawImpress, Context::Graphic): case CombinedEnumContext(Application::DrawImpress, Context::Table): { - m_pBeforeSpacing->SetMin(DEFAULT_VALUE); - m_pAfterSpacing->SetMin(DEFAULT_VALUE); - m_pFLSpacing->SetMin(DEFAULT_VALUE); + m_xBeforeSpacing->set_min(DEFAULT_VALUE, FieldUnit::NONE); + m_xAfterSpacing->set_min(DEFAULT_VALUE, FieldUnit::NONE); + m_xFLSpacing->set_min(DEFAULT_VALUE, FieldUnit::NONE); } break; case CombinedEnumContext(Application::WriterVariants, Context::Default): case CombinedEnumContext(Application::WriterVariants, Context::Text): case CombinedEnumContext(Application::WriterVariants, Context::Table): { - m_pBeforeSpacing->SetMin(NEGA_MAXVALUE, FieldUnit::MM_100TH); - m_pAfterSpacing->SetMin(NEGA_MAXVALUE, FieldUnit::MM_100TH); - m_pFLSpacing->SetMin(NEGA_MAXVALUE, FieldUnit::MM_100TH); + m_xBeforeSpacing->set_min(NEGA_MAXVALUE, FieldUnit::MM_100TH); + m_xAfterSpacing->set_min(NEGA_MAXVALUE, FieldUnit::MM_100TH); + m_xFLSpacing->set_min(NEGA_MAXVALUE, FieldUnit::MM_100TH); } break; } if(pState && eState >= SfxItemState::DEFAULT) { - m_pBeforeSpacing-> Enable(); - m_pAfterSpacing->Enable(); - m_pFLSpacing->Enable(); + m_xBeforeSpacing->set_sensitive(true); + m_xAfterSpacing->set_sensitive(true); + m_xFLSpacing->set_sensitive(true); const SvxLRSpaceItem* pSpace = static_cast<const SvxLRSpaceItem*>(pState); long aTxtLeft = pSpace->GetTextLeft(); long aTxtRight = pSpace->GetRight(); long aTxtFirstLineOfst = pSpace->GetTextFirstLineOfst(); - aTxtLeft = static_cast<long>(m_pBeforeSpacing->Normalize(aTxtLeft)); + aTxtLeft = m_xBeforeSpacing->normalize(aTxtLeft); if(m_aContext.GetCombinedContext_DI() != CombinedEnumContext(Application::WriterVariants, Context::Text) && m_aContext.GetCombinedContext_DI() != CombinedEnumContext(Application::WriterVariants, Context::Default) && m_aContext.GetCombinedContext_DI() != CombinedEnumContext(Application::WriterVariants, Context::Table)) { - m_pFLSpacing->SetMin(aTxtLeft*-1, FieldUnit::MM_100TH); + m_xFLSpacing->set_min(aTxtLeft*-1, FieldUnit::MM_100TH); } - aTxtRight = static_cast<long>(m_pAfterSpacing->Normalize(aTxtRight)); + aTxtRight = m_xAfterSpacing->normalize(aTxtRight); switch(m_aContext.GetCombinedContext_DI()) { @@ -242,9 +274,9 @@ void ParaLRSpacingWindow::SetValue(SfxItemState eState, const SfxPoolItem* pStat case CombinedEnumContext(Application::WriterVariants, Context::Table): case CombinedEnumContext(Application::WriterVariants, Context::Annotation): { - m_pBeforeSpacing->SetMax(MAX_SW - aTxtRight, FieldUnit::MM_100TH); - m_pAfterSpacing->SetMax(MAX_SW - aTxtLeft, FieldUnit::MM_100TH); - m_pFLSpacing->SetMax(MAX_SW - aTxtLeft - aTxtRight, FieldUnit::MM_100TH); + m_xBeforeSpacing->set_max(MAX_SW - aTxtRight, FieldUnit::MM_100TH); + m_xAfterSpacing->set_max(MAX_SW - aTxtLeft, FieldUnit::MM_100TH); + m_xFLSpacing->set_max(MAX_SW - aTxtLeft - aTxtRight, FieldUnit::MM_100TH); } break; case CombinedEnumContext(Application::DrawImpress, Context::DrawText): @@ -253,52 +285,65 @@ void ParaLRSpacingWindow::SetValue(SfxItemState eState, const SfxPoolItem* pStat case CombinedEnumContext(Application::DrawImpress, Context::TextObject): case CombinedEnumContext(Application::DrawImpress, Context::Graphic): { - m_pBeforeSpacing->SetMax(MAX_SC_SD - aTxtRight, FieldUnit::MM_100TH); - m_pAfterSpacing->SetMax(MAX_SC_SD - aTxtLeft, FieldUnit::MM_100TH); - m_pFLSpacing->SetMax(MAX_SC_SD - aTxtLeft - aTxtRight, FieldUnit::MM_100TH); + m_xBeforeSpacing->set_max(MAX_SC_SD - aTxtRight, FieldUnit::MM_100TH); + m_xAfterSpacing->set_max(MAX_SC_SD - aTxtLeft, FieldUnit::MM_100TH); + m_xFLSpacing->set_max(MAX_SC_SD - aTxtLeft - aTxtRight, FieldUnit::MM_100TH); } } - m_pBeforeSpacing->SetValue(aTxtLeft, FieldUnit::MM_100TH); - m_pAfterSpacing->SetValue(aTxtRight, FieldUnit::MM_100TH); + m_xBeforeSpacing->set_value(aTxtLeft, FieldUnit::MM_100TH); + m_xAfterSpacing->set_value(aTxtRight, FieldUnit::MM_100TH); - aTxtFirstLineOfst = static_cast<long>(m_pFLSpacing->Normalize(aTxtFirstLineOfst)); - m_pFLSpacing->SetValue(aTxtFirstLineOfst, FieldUnit::MM_100TH); + aTxtFirstLineOfst = m_xFLSpacing->normalize(aTxtFirstLineOfst); + m_xFLSpacing->set_value(aTxtFirstLineOfst, FieldUnit::MM_100TH); } else if(eState == SfxItemState::DISABLED) { - m_pBeforeSpacing-> Disable(); - m_pAfterSpacing->Disable(); - m_pFLSpacing->Disable(); + m_xBeforeSpacing->set_sensitive(false); + m_xAfterSpacing->set_sensitive(false); + m_xFLSpacing->set_sensitive(false); } else { - m_pBeforeSpacing->SetEmptyFieldValue(); - m_pAfterSpacing->SetEmptyFieldValue(); - m_pFLSpacing->SetEmptyFieldValue(); + m_xBeforeSpacing->set_text(""); + m_xAfterSpacing->set_text(""); + m_xFLSpacing->set_text(""); } } +void ParaLRSpacingWindow::Resize() +{ + vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); + assert(pChild); + VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); + Control::Resize(); +} + +Size ParaLRSpacingWindow::GetOptimalSize() const +{ + return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); +} + void ParaLRSpacingWindow::SetUnit(FieldUnit eUnit) { - SetFieldUnit(*m_pBeforeSpacing, eUnit); - SetFieldUnit(*m_pAfterSpacing, eUnit); - SetFieldUnit(*m_pFLSpacing, eUnit); + m_xBeforeSpacing->SetFieldUnit(eUnit); + m_xAfterSpacing->SetFieldUnit(eUnit); + m_xFLSpacing->SetFieldUnit(eUnit); SfxItemPool &rPool = SfxGetpApp()->GetPool(); sal_uInt16 nWhich = rPool.GetWhich(SID_ATTR_PARA_LRSPACE); m_eUnit = rPool.GetMetric(nWhich); } -IMPL_LINK_NOARG(ParaLRSpacingWindow, ModifySpacingHdl, Edit&, void) +IMPL_LINK_NOARG(ParaLRSpacingWindow, ModifySpacingHdl, weld::MetricSpinButton&, void) { SfxDispatcher* pDisp = SfxViewFrame::Current()->GetBindings().GetDispatcher(); if(pDisp) { SvxLRSpaceItem aMargin(SID_ATTR_PARA_LRSPACE); - aMargin.SetTextLeft(GetCoreValue(*m_pBeforeSpacing, m_eUnit)); - aMargin.SetRight(GetCoreValue(*m_pAfterSpacing, m_eUnit)); - aMargin.SetTextFirstLineOfst(static_cast<short>(GetCoreValue(*m_pFLSpacing, m_eUnit))); + aMargin.SetTextLeft(m_xBeforeSpacing->GetCoreValue(m_eUnit)); + aMargin.SetRight(m_xAfterSpacing->GetCoreValue(m_eUnit)); + aMargin.SetTextFirstLineOfst(m_xFLSpacing->GetCoreValue(m_eUnit)); pDisp->ExecuteList(SID_ATTR_PARA_LRSPACE, SfxCallMode::RECORD, {&aMargin}); } @@ -306,47 +351,53 @@ IMPL_LINK_NOARG(ParaLRSpacingWindow, ModifySpacingHdl, Edit&, void) // ParaLeftSpacingWindow -ParaLeftSpacingWindow::ParaLeftSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : ParaLRSpacingWindow(pParent, xFrame) +ParaLeftSpacingWindow::ParaLeftSpacingWindow(vcl::Window* pParent) + : ParaLRSpacingWindow(pParent) { - m_pBeforeContainer->Show(); - m_pAfterContainer->Hide(); - m_pFirstLineContainer->Hide(); + m_xBeforeContainer->show(); + m_xAfterContainer->hide(); + m_xFirstLineContainer->hide(); + + SetSizePixel(GetOptimalSize()); } void ParaLeftSpacingWindow::GetFocus() { - m_pBeforeSpacing->GrabFocus(); + m_xBeforeSpacing->grab_focus(); } // ParaRightSpacingWindow -ParaRightSpacingWindow::ParaRightSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : ParaLRSpacingWindow(pParent, xFrame) +ParaRightSpacingWindow::ParaRightSpacingWindow(vcl::Window* pParent) + : ParaLRSpacingWindow(pParent) { - m_pBeforeContainer->Hide(); - m_pAfterContainer->Show(); - m_pFirstLineContainer->Hide(); + m_xBeforeContainer->hide(); + m_xAfterContainer->show(); + m_xFirstLineContainer->hide(); + + SetSizePixel(GetOptimalSize()); } void ParaRightSpacingWindow::GetFocus() { - m_pAfterSpacing->GrabFocus(); + m_xAfterSpacing->grab_focus(); } // ParaFirstLineSpacingWindow -ParaFirstLineSpacingWindow::ParaFirstLineSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame) - : ParaLRSpacingWindow(pParent, xFrame) +ParaFirstLineSpacingWindow::ParaFirstLineSpacingWindow(vcl::Window* pParent) + : ParaLRSpacingWindow(pParent) { - m_pBeforeContainer->Hide(); - m_pAfterContainer->Hide(); - m_pFirstLineContainer->Show(); + m_xBeforeContainer->hide(); + m_xAfterContainer->hide(); + m_xFirstLineContainer->show(); + + SetSizePixel(GetOptimalSize()); } void ParaFirstLineSpacingWindow::GetFocus() { - m_pFLSpacing->GrabFocus(); + m_xFLSpacing->grab_focus(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx index 88ba80e26489..1e19fdb78bed 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx @@ -29,9 +29,7 @@ using namespace com::sun::star; namespace svx { -class ParaULSpacingWindow : public VclVBox, - public VclBuilderContainer - +class ParaULSpacingWindow : public Control { public: virtual ~ParaULSpacingWindow() override; @@ -40,78 +38,92 @@ public: void SetValue(const SvxULSpaceItem* pItem); void SetUnit(FieldUnit eUnit); + virtual void Resize() override; + virtual Size GetOptimalSize() const override; + protected: - ParaULSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); - VclPtr<SvxRelativeField> m_pAboveSpacing; - VclPtr<SvxRelativeField> m_pBelowSpacing; - VclPtr<VclHBox> m_pAboveContainer; - VclPtr<VclHBox> m_pBelowContainer; + ParaULSpacingWindow(vcl::Window* pParent); + + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; + + std::unique_ptr<RelativeField> m_xAboveSpacing; + std::unique_ptr<RelativeField> m_xBelowSpacing; + std::unique_ptr<weld::Container> m_xAboveContainer; + std::unique_ptr<weld::Container> m_xBelowContainer; MapUnit m_eUnit; - DECL_LINK(ModifySpacingHdl, Edit&, void); + DECL_LINK(ModifySpacingHdl, weld::MetricSpinButton&, void); }; class ParaAboveSpacingWindow : public ParaULSpacingWindow { public: - explicit ParaAboveSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); + explicit ParaAboveSpacingWindow(vcl::Window* pParent); virtual void GetFocus() override; }; class ParaBelowSpacingWindow : public ParaULSpacingWindow { public: - explicit ParaBelowSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); + explicit ParaBelowSpacingWindow(vcl::Window* pParent); virtual void GetFocus() override; }; -class ParaLRSpacingWindow : public VclVBox, - public VclBuilderContainer +class ParaLRSpacingWindow : public Control { public: virtual ~ParaLRSpacingWindow() override; virtual void dispose() override; + virtual void Resize() override; + virtual Size GetOptimalSize() const override; + void SetValue(SfxItemState eState, const SfxPoolItem* pState); void SetUnit(FieldUnit eUnit); void SetContext(const vcl::EnumContext& eContext); protected: - ParaLRSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); + ParaLRSpacingWindow(vcl::Window* pParent); + + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; - VclPtr<SvxRelativeField> m_pBeforeSpacing; - VclPtr<SvxRelativeField> m_pAfterSpacing; - VclPtr<SvxRelativeField> m_pFLSpacing; - VclPtr<VclHBox> m_pBeforeContainer; - VclPtr<VclHBox> m_pAfterContainer; - VclPtr<VclHBox> m_pFirstLineContainer; + std::unique_ptr<RelativeField> m_xBeforeSpacing; + std::unique_ptr<RelativeField> m_xAfterSpacing; + std::unique_ptr<RelativeField> m_xFLSpacing; + std::unique_ptr<weld::Container> m_xBeforeContainer; + std::unique_ptr<weld::Container> m_xAfterContainer; + std::unique_ptr<weld::Container> m_xFirstLineContainer; MapUnit m_eUnit; vcl::EnumContext m_aContext; - DECL_LINK(ModifySpacingHdl, Edit&, void); + DECL_LINK(ModifySpacingHdl, weld::MetricSpinButton&, void); }; class ParaLeftSpacingWindow : public ParaLRSpacingWindow { public: - explicit ParaLeftSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); + explicit ParaLeftSpacingWindow(vcl::Window* pParent); virtual void GetFocus() override; }; class ParaRightSpacingWindow : public ParaLRSpacingWindow { public: - explicit ParaRightSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); + explicit ParaRightSpacingWindow(vcl::Window* pParent); virtual void GetFocus() override; }; class ParaFirstLineSpacingWindow : public ParaLRSpacingWindow { public: - explicit ParaFirstLineSpacingWindow(vcl::Window* pParent, css::uno::Reference<css::frame::XFrame> const & xFrame); + explicit ParaFirstLineSpacingWindow(vcl::Window* pParent); virtual void GetFocus() override; }; diff --git a/svx/uiconfig/ui/paralrspacing.ui b/svx/uiconfig/ui/paralrspacing.ui index 6093e4a1eee9..ceaf32c47c6c 100644 --- a/svx/uiconfig/ui/paralrspacing.ui +++ b/svx/uiconfig/ui/paralrspacing.ui @@ -2,19 +2,37 @@ <!-- Generated with glade 3.22.1 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkBox" id="ParaLRSpacingWindow"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <child> <object class="GtkBox" id="before"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkImage" id="image5"> @@ -22,7 +40,7 @@ <property name="can_focus">False</property> <property name="halign">center</property> <property name="valign">center</property> - <property name="pixbuf">svx/res/symphony/Indent4.png</property> + <property name="icon_name">svx/res/symphony/Indent4.png</property> </object> <packing> <property name="expand">False</property> @@ -31,11 +49,14 @@ </packing> </child> <child> - <object class="svxlo-SvxRelativeField" id="beforetextindent"> + <object class="GtkSpinButton" id="beforetextindent"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes" context="paralrspacing|beforetextindent|tooltip_text">Before Text Indent</property> + <property name="hexpand">True</property> <property name="text">0</property> + <property name="adjustment">adjustment1</property> + <property name="digits">2</property> </object> <packing> <property name="expand">False</property> @@ -53,6 +74,7 @@ <object class="GtkBox" id="after"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkImage" id="image4"> @@ -60,7 +82,7 @@ <property name="can_focus">False</property> <property name="halign">center</property> <property name="valign">center</property> - <property name="pixbuf">svx/res/symphony/Indent3.png</property> + <property name="icon_name">svx/res/symphony/Indent3.png</property> </object> <packing> <property name="expand">False</property> @@ -69,11 +91,14 @@ </packing> </child> <child> - <object class="svxlo-SvxRelativeField" id="aftertextindent"> + <object class="GtkSpinButton" id="aftertextindent"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes" context="paralrspacing|aftertextindent|tooltip_text">After Text Indent</property> + <property name="hexpand">True</property> <property name="text">0</property> + <property name="adjustment">adjustment2</property> + <property name="digits">2</property> </object> <packing> <property name="expand">False</property> @@ -90,6 +115,7 @@ <child> <object class="GtkBox" id="firstline"> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkImage" id="image11"> @@ -97,7 +123,7 @@ <property name="can_focus">False</property> <property name="halign">center</property> <property name="valign">center</property> - <property name="pixbuf">svx/res/symphony/Indent2.png</property> + <property name="icon_name">svx/res/symphony/Indent2.png</property> </object> <packing> <property name="expand">False</property> @@ -106,11 +132,14 @@ </packing> </child> <child> - <object class="svxlo-SvxRelativeField" id="firstlineindent"> + <object class="GtkSpinButton" id="firstlineindent"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes" context="paralrspacing|firstlineindent|tooltip_text">First Line Indent</property> + <property name="hexpand">True</property> <property name="text">0</property> + <property name="adjustment">adjustment3</property> + <property name="digits">2</property> </object> <packing> <property name="expand">False</property> diff --git a/svx/uiconfig/ui/paraulspacing.ui b/svx/uiconfig/ui/paraulspacing.ui index 56aa668d143f..e0d6ba48ed60 100644 --- a/svx/uiconfig/ui/paraulspacing.ui +++ b/svx/uiconfig/ui/paraulspacing.ui @@ -2,26 +2,34 @@ <!-- Generated with glade 3.22.1 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="upper">100</property> <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkBox" id="ParaULSpacingWindow"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="row_spacing">1</property> <property name="column_spacing">6</property> <child> <object class="GtkBox" id="above"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkImage" id="image6"> @@ -29,7 +37,7 @@ <property name="can_focus">False</property> <property name="halign">center</property> <property name="valign">center</property> - <property name="pixbuf">svx/res/symphony/spacing1.png</property> + <property name="icon_name">svx/res/symphony/spacing1.png</property> </object> <packing> <property name="expand">False</property> @@ -38,12 +46,14 @@ </packing> </child> <child> - <object class="svxlo-SvxRelativeField" id="aboveparaspacing"> + <object class="GtkSpinButton" id="aboveparaspacing"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes" context="paraulspacing|aboveparaspacing|tooltip_text">Above Paragraph Spacing</property> + <property name="hexpand">True</property> <property name="text">0</property> <property name="adjustment">adjustment1</property> + <property name="digits">2</property> </object> <packing> <property name="expand">False</property> @@ -61,6 +71,7 @@ <object class="GtkBox" id="below"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="spacing">6</property> <child> <object class="GtkImage" id="image7"> @@ -68,7 +79,7 @@ <property name="can_focus">False</property> <property name="halign">center</property> <property name="valign">center</property> - <property name="pixbuf">svx/res/symphony/spacing2.png</property> + <property name="icon_name">svx/res/symphony/spacing2.png</property> </object> <packing> <property name="expand">False</property> @@ -77,12 +88,14 @@ </packing> </child> <child> - <object class="svxlo-SvxRelativeField" id="belowparaspacing"> + <object class="GtkSpinButton" id="belowparaspacing"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes" context="paraulspacing|belowparaspacing|tooltip_text">Below Paragraph Spacing</property> + <property name="hexpand">True</property> <property name="text">0</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustment2</property> + <property name="digits">2</property> </object> <packing> <property name="expand">False</property> |