diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-04-19 20:36:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-04-21 11:52:58 +0200 |
commit | 850b8de31c5be5127eac16a4f5cc18c26a582e53 (patch) | |
tree | 385ba78cc33139785caa81aa7015d18e14846da8 | |
parent | c5769df7ecbc11c09ee5f2007d24cbd01ac33a52 (diff) |
weld sidebar text panel
includes
weld SvxFontNameToolBoxControl
Change-Id: Ie48338243600c07f9f8c609701c137175133f8e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92585
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | svx/source/sidebar/text/TextPropertyPanel.cxx | 62 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextPropertyPanel.hxx | 26 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 300 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunocontroller.cxx | 2 | ||||
-rw-r--r-- | svx/uiconfig/ui/sidebartextpanel.ui | 185 |
5 files changed, 361 insertions, 214 deletions
diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx index 7cc3c7995fa5..8944f85530f5 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.cxx +++ b/svx/source/sidebar/text/TextPropertyPanel.cxx @@ -20,7 +20,6 @@ #include "TextPropertyPanel.hxx" #include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <vcl/toolbox.hxx> #include <comphelper/lok.hxx> #include <sfx2/lokhelper.hxx> @@ -41,20 +40,33 @@ VclPtr<vcl::Window> TextPropertyPanel::Create ( } TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame ) - : PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui", rxFrame) + : PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui", rxFrame, true) + , mxFont(m_xBuilder->weld_toolbar("font")) + , mxFontDispatch(new ToolbarUnoDispatcher(*mxFont, *m_xBuilder, rxFrame)) + , mxFontHeight(m_xBuilder->weld_toolbar("fontheight")) + , mxFontHeightDispatch(new ToolbarUnoDispatcher(*mxFontHeight, *m_xBuilder, rxFrame)) + , mxFontEffects(m_xBuilder->weld_toolbar("fonteffects")) + , mxFontEffectsDispatch(new ToolbarUnoDispatcher(*mxFontEffects, *m_xBuilder, rxFrame)) + , mxFontAdjust(m_xBuilder->weld_toolbar("fontadjust")) + , mxFontAdjustDispatch(new ToolbarUnoDispatcher(*mxFontAdjust, *m_xBuilder, rxFrame)) + , mxToolBoxFontColorSw(m_xBuilder->weld_toolbar("colorbar_writer")) + , mxToolBoxFontColorSwDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColorSw, *m_xBuilder, rxFrame)) + , mxToolBoxFontColor(m_xBuilder->weld_toolbar("colorbar_others")) + , mxToolBoxFontColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColor, *m_xBuilder, rxFrame)) + , mxToolBoxBackgroundColor(m_xBuilder->weld_toolbar("colorbar_background")) + , mxToolBoxBackgroundColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxBackgroundColor, *m_xBuilder, rxFrame)) + , mxResetBar(m_xBuilder->weld_toolbar("resetattr")) + , mxResetBarDispatch(new ToolbarUnoDispatcher(*mxResetBar, *m_xBuilder, rxFrame)) + , mxPositionBar(m_xBuilder->weld_toolbar("position")) + , mxPositionBarDispatch(new ToolbarUnoDispatcher(*mxPositionBar, *m_xBuilder, rxFrame)) + , mxSpacingBar(m_xBuilder->weld_toolbar("spacingbar")) + , mxSpacingBarDispatch(new ToolbarUnoDispatcher(*mxSpacingBar, *m_xBuilder, rxFrame)) { - get(mpToolBoxFontColorSw, "colorbar_writer"); - get(mpToolBoxFontColor, "colorbar_others"); - get(mpToolBoxBackgroundColor, "colorbar_background"); - bool isMobilePhone = false; if (comphelper::LibreOfficeKit::isActive() && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) isMobilePhone = true; - VclPtr<ToolBox> xSpacingBar; - get(xSpacingBar, "spacingbar"); - xSpacingBar->Show(!isMobilePhone); - xSpacingBar->ShowItem(0, !isMobilePhone); + mxSpacingBar->set_visible(!isMobilePhone); } TextPropertyPanel::~TextPropertyPanel() @@ -64,9 +76,27 @@ TextPropertyPanel::~TextPropertyPanel() void TextPropertyPanel::dispose() { - mpToolBoxFontColorSw.clear(); - mpToolBoxFontColor.clear(); - mpToolBoxBackgroundColor.clear(); + mxResetBarDispatch.reset(); + mxPositionBarDispatch.reset(); + mxSpacingBarDispatch.reset(); + mxToolBoxFontColorSwDispatch.reset(); + mxToolBoxFontColorDispatch.reset(); + mxToolBoxBackgroundColorDispatch.reset(); + mxFontAdjustDispatch.reset(); + mxFontEffectsDispatch.reset(); + mxFontHeightDispatch.reset(); + mxFontDispatch.reset(); + + mxResetBar.reset(); + mxPositionBar.reset(); + mxSpacingBar.reset(); + mxToolBoxFontColorSw.reset(); + mxToolBoxFontColor.reset(); + mxToolBoxBackgroundColor.reset(); + mxFontAdjust.reset(); + mxFontEffects.reset(); + mxFontHeight.reset(); + mxFont.reset(); PanelLayout::dispose(); } @@ -106,9 +136,9 @@ void TextPropertyPanel::HandleContextChange ( break; } - mpToolBoxFontColor->Show(!bWriterText); - mpToolBoxFontColorSw->Show(bWriterText); - mpToolBoxBackgroundColor->Show(bDrawText); + mxToolBoxFontColor->set_visible(!bWriterText); + mxToolBoxFontColorSw->set_visible(bWriterText); + mxToolBoxBackgroundColor->set_visible(bDrawText); } } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/text/TextPropertyPanel.hxx b/svx/source/sidebar/text/TextPropertyPanel.hxx index bbfe13f030d2..bfa905446785 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.hxx +++ b/svx/source/sidebar/text/TextPropertyPanel.hxx @@ -20,11 +20,10 @@ #define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX #include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/weldutils.hxx> #include <vcl/EnumContext.hxx> #include <svx/sidebar/PanelLayout.hxx> -class ToolBox; - namespace svx { namespace sidebar { class TextPropertyPanel @@ -47,9 +46,26 @@ public: const css::uno::Reference<css::frame::XFrame>& rxFrame); private: - VclPtr<ToolBox> mpToolBoxFontColorSw; - VclPtr<ToolBox> mpToolBoxFontColor; - VclPtr<ToolBox> mpToolBoxBackgroundColor; + std::unique_ptr<weld::Toolbar> mxFont; + std::unique_ptr<ToolbarUnoDispatcher> mxFontDispatch; + std::unique_ptr<weld::Toolbar> mxFontHeight; + std::unique_ptr<ToolbarUnoDispatcher> mxFontHeightDispatch; + std::unique_ptr<weld::Toolbar> mxFontEffects; + std::unique_ptr<ToolbarUnoDispatcher> mxFontEffectsDispatch; + std::unique_ptr<weld::Toolbar> mxFontAdjust; + std::unique_ptr<ToolbarUnoDispatcher> mxFontAdjustDispatch; + std::unique_ptr<weld::Toolbar> mxToolBoxFontColorSw; + std::unique_ptr<ToolbarUnoDispatcher> mxToolBoxFontColorSwDispatch; + std::unique_ptr<weld::Toolbar> mxToolBoxFontColor; + std::unique_ptr<ToolbarUnoDispatcher> mxToolBoxFontColorDispatch; + std::unique_ptr<weld::Toolbar> mxToolBoxBackgroundColor; + std::unique_ptr<ToolbarUnoDispatcher> mxToolBoxBackgroundColorDispatch; + std::unique_ptr<weld::Toolbar> mxResetBar; + std::unique_ptr<ToolbarUnoDispatcher> mxResetBarDispatch; + std::unique_ptr<weld::Toolbar> mxPositionBar; + std::unique_ptr<ToolbarUnoDispatcher> mxPositionBarDispatch; + std::unique_ptr<weld::Toolbar> mxSpacingBar; + std::unique_ptr<ToolbarUnoDispatcher> mxSpacingBarDispatch; vcl::EnumContext maContext; }; diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 523d2816fa64..fef375d4aff6 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -31,6 +31,7 @@ #include <vcl/toolbox.hxx> #include <vcl/customweld.hxx> #include <vcl/vclptr.hxx> +#include <vcl/weldutils.hxx> #include <svtools/valueset.hxx> #include <svtools/ctrlbox.hxx> #include <svl/style.hxx> @@ -178,9 +179,41 @@ private: namespace { -class SvxFontNameBox_Impl final : public InterimItemWindow +class SvxFontNameBox_Impl; +class SvxFontNameBox_Base; + +class SvxFontNameToolBoxControl : public cppu::ImplInheritanceHelper< svt::ToolboxController, + css::lang::XServiceInfo > { +public: + SvxFontNameToolBoxControl(); + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; + + // XToolbarController + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + private: + VclPtr<SvxFontNameBox_Impl> m_xVclBox; + std::unique_ptr<SvxFontNameBox_Base> m_xWeldBox; + SvxFontNameBox_Base* m_pBox; +}; + +class SvxFontNameBox_Base +{ +protected: + SvxFontNameToolBoxControl& m_rCtrl; + int m_nCharWidth; + std::unique_ptr<FontNameBox> m_xWidget; const FontList* pFontList; ::std::unique_ptr<FontList> m_aOwnFontList; @@ -206,15 +239,12 @@ private: } void CheckAndMarkUnknownFont(); - void SetOptimalSize(); - - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - virtual void GetFocus() override; - public: - SvxFontNameBox_Impl(vcl::Window* pParent, const Reference<XDispatchProvider>& rDispatchProvider, const Reference<XFrame>& _xFrame); - virtual ~SvxFontNameBox_Impl() override; - virtual void dispose() override; + SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget, const Reference<XDispatchProvider>& rDispatchProvider, + const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl); + virtual ~SvxFontNameBox_Base() + { + } void FillList(); void Update( const css::awt::FontDescriptor* pFontDesc ); @@ -226,16 +256,19 @@ public: nFtCount = pList->GetFontNameCount(); } - virtual Reference< css::accessibility::XAccessible > CreateAccessible() override; - void SetOwnFontList(::std::unique_ptr<FontList> && _aOwnFontList) { m_aOwnFontList = std::move(_aOwnFontList); } + void SetOwnFontList(::std::unique_ptr<FontList> && _aOwnFontList) { m_aOwnFontList = std::move(_aOwnFontList); } - void Enable() {m_xWidget->set_sensitive(true); InterimItemWindow::Enable();} - void Disable() {m_xWidget->set_sensitive(false); InterimItemWindow::Disable();} + virtual void set_sensitive(bool bSensitive) + { + m_xWidget->set_sensitive(bSensitive); + } void set_active_or_entry_text(const OUString& rText); void statusChanged_Impl(const css::frame::FeatureStateEvent& rEvent); + virtual bool DoKeyInput(const KeyEvent& rKEvt); + DECL_LINK(SelectHdl, weld::ComboBox&, void); DECL_LINK(KeyInputHdl, const KeyEvent&, bool); DECL_LINK(ActivateHdl, weld::ComboBox&, bool); @@ -244,6 +277,50 @@ public: DECL_LINK(DumpAsPropertyTreeHdl, boost::property_tree::ptree&, void); }; +class SvxFontNameBox_Impl final : public InterimItemWindow + , public SvxFontNameBox_Base +{ +private: + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void GetFocus() override + { + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); + } + + void SetOptimalSize(); + + virtual bool DoKeyInput(const KeyEvent& rKEvt) override; + +public: + SvxFontNameBox_Impl(vcl::Window* pParent, const Reference<XDispatchProvider>& rDispatchProvider, + const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl); + + virtual void dispose() override + { + m_xWidget.reset(); + InterimItemWindow::dispose(); + } + + virtual ~SvxFontNameBox_Impl() override + { + disposeOnce(); + } + + virtual Reference< css::accessibility::XAccessible > CreateAccessible() override; + + virtual void set_sensitive(bool bSensitive) override + { + m_xWidget->set_sensitive(bSensitive); + if (bSensitive) + InterimItemWindow::Enable(); + else + InterimItemWindow::Disable(); + } +}; + + // SelectHdl needs the Modifiers, get them in MouseButtonUp class SvxFrmValueSet_Impl final : public SvtValueSet { @@ -1248,7 +1325,7 @@ boost::property_tree::ptree SvxStyleBox_Impl::DumpAsPropertyTree() } -static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl* pBox ) +static bool lcl_GetDocFontList(const FontList** ppFontList, SvxFontNameBox_Base* pBox) { bool bChanged = false; const SfxObjectShell* pDocSh = SfxObjectShell::Current(); @@ -1259,7 +1336,7 @@ static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl static_cast<const SvxFontListItem*>(pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST )); else { - ::std::unique_ptr<FontList> aFontList(new FontList( pBox->GetParent() )); + ::std::unique_ptr<FontList> aFontList(new FontList(Application::GetDefaultDevice())); *ppFontList = aFontList.get(); pBox->SetOwnFontList(std::move(aFontList)); bChanged = true; @@ -1293,7 +1370,7 @@ static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl } if ( pBox ) - pBox->Enable(); + pBox->set_sensitive(true); } else if ( pBox && ( pDocSh || !ppFontList )) { @@ -1304,7 +1381,7 @@ static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl // the help window with F1. After closing the help window, we disable the font name // combo box. The SfxObjectShell::Current() method returns in that case zero. But the // font list hasn't changed and therefore the combo box shouldn't be disabled! - pBox->Disable(); + pBox->set_sensitive(false); } // Fill the FontBox, also the new list if necessary @@ -1318,48 +1395,44 @@ static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl return bChanged; } -SvxFontNameBox_Impl::SvxFontNameBox_Impl(vcl::Window* pParent, const Reference<XDispatchProvider>& rDispatchProvider, - const Reference<XFrame>& _xFrame) - : InterimItemWindow(pParent, "svx/ui/fontnamebox.ui", "FontNameBox") - , m_xWidget(new FontNameBox(m_xBuilder->weld_combo_box("fontnamecombobox"))) +SvxFontNameBox_Base::SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget, + const Reference<XDispatchProvider>& rDispatchProvider, + const Reference<XFrame>& rFrame, + SvxFontNameToolBoxControl& rCtrl) + : m_rCtrl(rCtrl) + , m_nCharWidth(xWidget->get_approximate_digit_width() * 15) + , m_xWidget(new FontNameBox(std::move(xWidget))) , pFontList(nullptr) , nFtCount(0) , bRelease(true) , m_xDispatchProvider(rDispatchProvider) - , m_xFrame(_xFrame) + , m_xFrame(rFrame) , mbCheckingUnknownFont(false) { EnableControls_Impl(); - set_id("fontnamecombobox"); - m_xWidget->connect_changed(LINK(this, SvxFontNameBox_Impl, SelectHdl)); - m_xWidget->connect_key_press(LINK(this, SvxFontNameBox_Impl, KeyInputHdl)); - m_xWidget->connect_entry_activate(LINK(this, SvxFontNameBox_Impl, ActivateHdl)); - m_xWidget->connect_focus_in(LINK(this, SvxFontNameBox_Impl, FocusInHdl)); - m_xWidget->connect_focus_out(LINK(this, SvxFontNameBox_Impl, FocusOutHdl)); - m_xWidget->connect_get_property_tree(LINK(this, SvxFontNameBox_Impl, DumpAsPropertyTreeHdl)); + m_xWidget->connect_changed(LINK(this, SvxFontNameBox_Base, SelectHdl)); + m_xWidget->connect_key_press(LINK(this, SvxFontNameBox_Base, KeyInputHdl)); + m_xWidget->connect_entry_activate(LINK(this, SvxFontNameBox_Base, ActivateHdl)); + m_xWidget->connect_focus_in(LINK(this, SvxFontNameBox_Base, FocusInHdl)); + m_xWidget->connect_focus_out(LINK(this, SvxFontNameBox_Base, FocusOutHdl)); + m_xWidget->connect_get_property_tree(LINK(this, SvxFontNameBox_Base, DumpAsPropertyTreeHdl)); - const Size aLogicalSize(60, 0); - Size aSize(LogicToPixel(aLogicalSize, MapMode(MapUnit::MapAppFont))); // set width in chars low so the size request will not be overridden m_xWidget->set_entry_width_chars(1); - m_xWidget->set_size_request(aSize.Width(), -1); - - SetOptimalSize(); + m_xWidget->set_size_request(m_nCharWidth, -1); } -SvxFontNameBox_Impl::~SvxFontNameBox_Impl() -{ - disposeOnce(); -} - -void SvxFontNameBox_Impl::dispose() +SvxFontNameBox_Impl::SvxFontNameBox_Impl(vcl::Window* pParent, const Reference<XDispatchProvider>& rDispatchProvider, + const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl) + : InterimItemWindow(pParent, "svx/ui/fontnamebox.ui", "FontNameBox") + , SvxFontNameBox_Base(m_xBuilder->weld_combo_box("fontnamecombobox"), rDispatchProvider, rFrame, rCtrl) { - m_xWidget.reset(); - InterimItemWindow::dispose(); + set_id("fontnamecombobox"); + SetOptimalSize(); } -void SvxFontNameBox_Impl::FillList() +void SvxFontNameBox_Base::FillList() { if (!m_xWidget) // e.g. disposed return; @@ -1374,7 +1447,7 @@ void SvxFontNameBox_Impl::FillList() m_xWidget->select_entry_region(nStartPos, nEndPos); } -void SvxFontNameBox_Impl::CheckAndMarkUnknownFont() +void SvxFontNameBox_Base::CheckAndMarkUnknownFont() { if (mbCheckingUnknownFont) //tdf#117537 block rentry return; @@ -1404,7 +1477,7 @@ void SvxFontNameBox_Impl::CheckAndMarkUnknownFont() mbCheckingUnknownFont = false; } -void SvxFontNameBox_Impl::Update( const css::awt::FontDescriptor* pFontDesc ) +void SvxFontNameBox_Base::Update( const css::awt::FontDescriptor* pFontDesc ) { if ( pFontDesc ) { @@ -1420,19 +1493,24 @@ void SvxFontNameBox_Impl::Update( const css::awt::FontDescriptor* pFontDesc ) set_active_or_entry_text(aCurName); } -void SvxFontNameBox_Impl::set_active_or_entry_text(const OUString& rText) +void SvxFontNameBox_Base::set_active_or_entry_text(const OUString& rText) { m_xWidget->set_active_or_entry_text(rText); CheckAndMarkUnknownFont(); } -IMPL_LINK_NOARG(SvxFontNameBox_Impl, FocusInHdl, weld::Widget&, void) +IMPL_LINK_NOARG(SvxFontNameBox_Base, FocusInHdl, weld::Widget&, void) { EnableControls_Impl(); FillList(); } -IMPL_LINK(SvxFontNameBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool) +IMPL_LINK(SvxFontNameBox_Base, KeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + return DoKeyInput(rKEvt); +} + +bool SvxFontNameBox_Base::DoKeyInput(const KeyEvent& rKEvt) { bool bHandled = false; @@ -1447,17 +1525,24 @@ IMPL_LINK(SvxFontNameBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool) case KEY_ESCAPE: set_active_or_entry_text(aCurText); - if ( typeid( *GetParent() ) != typeid( sfx2::sidebar::SidebarToolBox ) ) + if (!m_rCtrl.IsInSidebar()) + { ReleaseFocus_Impl(); + bHandled = true; + } EndPreview(); - bHandled = true; break; } - return bHandled || ChildKeyInput(rKEvt); + return bHandled; } -IMPL_LINK_NOARG(SvxFontNameBox_Impl, FocusOutHdl, weld::Widget&, void) +bool SvxFontNameBox_Impl::DoKeyInput(const KeyEvent& rKEvt) +{ + return SvxFontNameBox_Base::DoKeyInput(rKEvt) || ChildKeyInput(rKEvt); +} + +IMPL_LINK_NOARG(SvxFontNameBox_Base, FocusOutHdl, weld::Widget&, void) { if (!m_xWidget->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus { @@ -1488,7 +1573,7 @@ void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) } } -void SvxFontNameBox_Impl::ReleaseFocus_Impl() +void SvxFontNameBox_Base::ReleaseFocus_Impl() { if ( !bRelease ) { @@ -1499,7 +1584,7 @@ void SvxFontNameBox_Impl::ReleaseFocus_Impl() m_xFrame->getContainerWindow()->setFocus(); } -void SvxFontNameBox_Impl::EnableControls_Impl() +void SvxFontNameBox_Base::EnableControls_Impl() { SvtFontOptions aFontOpt; bool bEnable = aFontOpt.IsFontHistoryEnabled(); @@ -1516,18 +1601,18 @@ void SvxFontNameBox_Impl::EnableControls_Impl() m_xWidget->EnableWYSIWYG(); } -IMPL_LINK(SvxFontNameBox_Impl, SelectHdl, weld::ComboBox&, rCombo, void) +IMPL_LINK(SvxFontNameBox_Base, SelectHdl, weld::ComboBox&, rCombo, void) { Select(rCombo.changed_by_direct_pick()); // only when picked from the list } -IMPL_LINK_NOARG(SvxFontNameBox_Impl, ActivateHdl, weld::ComboBox&, bool) +IMPL_LINK_NOARG(SvxFontNameBox_Base, ActivateHdl, weld::ComboBox&, bool) { Select(true); return true; } -void SvxFontNameBox_Impl::Select(bool bNonTravelSelect) +void SvxFontNameBox_Base::Select(bool bNonTravelSelect) { Sequence< PropertyValue > aArgs( 1 ); std::unique_ptr<SvxFontItem> pFontItem; @@ -1578,14 +1663,7 @@ void SvxFontNameBox_Impl::Select(bool bNonTravelSelect) } } -void SvxFontNameBox_Impl::GetFocus() -{ - if (m_xWidget) - m_xWidget->grab_focus(); - InterimItemWindow::GetFocus(); -} - -IMPL_LINK(SvxFontNameBox_Impl, DumpAsPropertyTreeHdl, boost::property_tree::ptree&, rTree, void) +IMPL_LINK(SvxFontNameBox_Base, DumpAsPropertyTreeHdl, boost::property_tree::ptree&, rTree, void) { boost::property_tree::ptree aEntries; @@ -2840,48 +2918,20 @@ VclPtr<vcl::Window> SvxStyleToolBoxControl::CreateItemWindow( vcl::Window *pPare return pBox.get(); } -namespace { - -class SvxFontNameToolBoxControl : public cppu::ImplInheritanceHelper< svt::ToolboxController, - css::lang::XServiceInfo > -{ -public: - SvxFontNameToolBoxControl(); - - // XStatusListener - virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; - - // XToolbarController - virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) override; - - // XComponent - virtual void SAL_CALL dispose() override; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - -private: - VclPtr<SvxFontNameBox_Impl> m_pBox; -}; - -} - SvxFontNameToolBoxControl::SvxFontNameToolBoxControl() { } -void SvxFontNameBox_Impl::statusChanged_Impl( const css::frame::FeatureStateEvent& rEvent ) +void SvxFontNameBox_Base::statusChanged_Impl( const css::frame::FeatureStateEvent& rEvent ) { if ( !rEvent.IsEnabled ) { - Disable(); + set_sensitive(false); Update( nullptr ); } else { - Enable(); + set_sensitive(true); css::awt::FontDescriptor aFontDesc; if ( rEvent.State >>= aFontDesc ) @@ -2895,28 +2945,62 @@ void SvxFontNameBox_Impl::statusChanged_Impl( const css::frame::FeatureStateEven void SvxFontNameToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { SolarMutexGuard aGuard; - ToolBox* pToolBox = nullptr; - sal_uInt16 nId = 0; - if ( !getToolboxId( nId, &pToolBox ) ) - return; - m_pBox->statusChanged_Impl(rEvent); - pToolBox->EnableItem( nId, rEvent.IsEnabled ); + + if (m_pToolbar) + m_pToolbar->set_item_sensitive(m_aCommandURL.toUtf8(), rEvent.IsEnabled); + else + { + ToolBox* pToolBox = nullptr; + sal_uInt16 nId = 0; + if (!getToolboxId( nId, &pToolBox ) ) + return; + pToolBox->EnableItem( nId, rEvent.IsEnabled ); + } } css::uno::Reference< css::awt::XWindow > SvxFontNameToolBoxControl::createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) { - SolarMutexGuard aGuard; - m_pBox = VclPtr<SvxFontNameBox_Impl>::Create(VCLUnoHelper::GetWindow(rParent), - Reference< XDispatchProvider >(m_xFrame->getController(), UNO_QUERY), - m_xFrame); - return VCLUnoHelper::GetInterface( m_pBox ); + uno::Reference< awt::XWindow > xItemWindow; + + if (m_pBuilder) + { + SolarMutexGuard aSolarMutexGuard; + + std::unique_ptr<weld::ComboBox> xWidget(m_pBuilder->weld_combo_box("fontnamecombobox")); + + xItemWindow = css::uno::Reference<css::awt::XWindow>(new weld::TransportAsXWindow(xWidget.get())); + + m_xWeldBox.reset(new SvxFontNameBox_Base(std::move(xWidget), + Reference<XDispatchProvider>(m_xFrame->getController(), UNO_QUERY), + m_xFrame, *this)); + m_pBox = m_xWeldBox.get(); + } + else + { + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(rParent); + if ( pParent ) + { + SolarMutexGuard aSolarMutexGuard; + m_xVclBox = VclPtr<SvxFontNameBox_Impl>::Create(pParent, + Reference<XDispatchProvider>(m_xFrame->getController(), UNO_QUERY), + m_xFrame, *this); + m_pBox = m_xVclBox.get(); + xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox); + } + } + + return xItemWindow; } void SvxFontNameToolBoxControl::dispose() { - m_pBox.disposeAndClear(); ToolboxController::dispose(); + + SolarMutexGuard aSolarMutexGuard; + m_xVclBox.disposeAndClear(); + m_xWeldBox.reset(); + m_pBox = nullptr; } OUString SvxFontNameToolBoxControl::getImplementationName() diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx index cc638c794a1f..da2c2a1e40f5 100644 --- a/svx/source/tbxctrls/tbunocontroller.cxx +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -172,7 +172,7 @@ private: }; SvxFontSizeBox_Base::SvxFontSizeBox_Base(std::unique_ptr<weld::ComboBox> xWidget, - const uno::Reference< frame::XFrame >& rFrame, + const uno::Reference<frame::XFrame>& rFrame, FontHeightToolBoxControl& rCtrl) : m_rCtrl(rCtrl) , m_bRelease(true) diff --git a/svx/uiconfig/ui/sidebartextpanel.ui b/svx/uiconfig/ui/sidebartextpanel.ui index af220dcc0b25..a74f8ab77be2 100644 --- a/svx/uiconfig/ui/sidebartextpanel.ui +++ b/svx/uiconfig/ui/sidebartextpanel.ui @@ -1,17 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.22.2 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkGrid" id="SidebarTextPanel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_homogeneous">True</property> - <property name="column_homogeneous">True</property> + <property name="hexpand">True</property> <child> <object class="GtkBox" id="box1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="border_width">6</property> <property name="orientation">vertical</property> <property name="spacing">3</property> @@ -19,21 +18,39 @@ <object class="GtkBox" id="box2"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="spacing">6</property> <child> - <object class="sfxlo-SidebarToolBox" id="font"> + <object class="GtkToolbar" id="font"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="toolbar_style">icons</property> + <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="fontname"> + <object class="GtkToolItem" id=".uno:CharFontName"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:CharFontName</property> + <property name="hexpand">True</property> + <child> + <object class="GtkComboBoxText" id="fontnamecombobox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="has_entry">True</property> + <property name="popup_fixed_width">False</property> + <child internal-child="entry"> + <object class="GtkEntry"> + <property name="can_focus">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="expand">True</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -44,19 +61,32 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="fontheight"> + <object class="GtkToolbar" id="fontheight"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> + <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="fontsize"> + <object class="GtkToolItem" id=".uno:FontHeight"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:FontHeight</property> + <child> + <object class="GtkComboBoxText" id="fontsizecombobox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="has_entry">True</property> + <child internal-child="entry"> + <object class="GtkEntry"> + <property name="can_focus">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="expand">True</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -80,73 +110,65 @@ <property name="can_focus">False</property> <property name="spacing">6</property> <child> - <object class="sfxlo-SidebarToolBox" id="fonteffects"> + <object class="GtkToolbar" id="fonteffects"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="bold"> + <object class="GtkToolButton" id=".uno:Bold"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Bold</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="italic"> + <object class="GtkToolButton" id=".uno:Italic"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Italic</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkMenuToolButton" id="underline"> + <object class="GtkMenuToolButton" id=".uno:Underline"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Underline</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="strikeout"> + <object class="GtkToolButton" id=".uno:Strikeout"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Strikeout</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="shadowed"> + <object class="GtkToolButton" id=".uno:Shadowed"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Shadowed</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -157,34 +179,32 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="fontadjust"> + <object class="GtkToolbar" id="fontadjust"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="grow"> + <object class="GtkToolButton" id=".uno:Grow"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Grow</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="shrink"> + <object class="GtkToolButton" id=".uno:Shrink"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Shrink</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -208,34 +228,32 @@ <property name="can_focus">False</property> <property name="spacing">6</property> <child> - <object class="sfxlo-SidebarToolBox" id="colorbar_writer"> + <object class="GtkToolbar" id="colorbar_writer"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkMenuToolButton" id="fontcolor"> + <object class="GtkMenuToolButton" id=".uno:FontColor"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:FontColor</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkMenuToolButton" id="highlight"> + <object class="GtkMenuToolButton" id=".uno:BackColor"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:BackColor</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -246,20 +264,21 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="colorbar_others"> + <object class="GtkToolbar" id="colorbar_others"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> + <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkMenuToolButton" id="color"> + <object class="GtkMenuToolButton" id=".uno:Color"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Color</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -270,20 +289,20 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="colorbar_background"> + <object class="GtkToolbar" id="colorbar_background"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> + <property name="icon_size">2</property> <child> - <object class="GtkMenuToolButton" id="backgroundcolor"> + <object class="GtkMenuToolButton" id=".uno:CharBackColor"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:CharBackColor</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -294,21 +313,21 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="resetattr"> + <object class="GtkToolbar" id="resetattr"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="resetattributes"> + <object class="GtkToolButton" id=".uno:ResetAttributes"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:ResetAttributes</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -319,32 +338,32 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="position"> + <object class="GtkToolbar" id="position"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="superscript"> + <object class="GtkToolButton" id=".uno:SuperScript"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:SuperScript</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="subscript"> + <object class="GtkToolButton" id=".uno:SubScript"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:SubScript</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -356,20 +375,20 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="spacingbar"> - <property name="visible">False</property> + <object class="GtkToolbar" id="spacingbar"> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> + <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="spacing"> + <object class="GtkMenuToolButton" id=".uno:Spacing"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="is_important">True</property> - <property name="action_name">.uno:Spacing</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -391,8 +410,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> </object> |