diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-07-02 09:30:51 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-07-02 11:04:50 +0200 |
commit | 1600dd7929d18b6d234bdb975798882ef73722a7 (patch) | |
tree | 65fea2ba54d709759d84b91bfb7a35730a3825a5 /svx | |
parent | 3bff52cae392cf7e45729a3469333b0e76b3d874 (diff) |
Revert "weld SvxFontSizeBox_Impl"
This reverts commit f3ad8a70c3c15fd57891b0d2fe0bb0a5d2aa39a2.
Change caused font size combbobx to not work on mobile
devices in online.
Change-Id: I41fc370866689b047aeeec056dff708e24dbc11f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97722
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaSpacingWindow.cxx | 10 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaSpacingWindow.hxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunocontroller.cxx | 181 | ||||
-rw-r--r-- | svx/uiconfig/ui/fontsizebox.ui | 29 |
5 files changed, 87 insertions, 136 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index ab701884332a..dc4e4df5b8cf 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -49,7 +49,6 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/floatingundoredo \ svx/uiconfig/ui/fontworkgallerydialog \ svx/uiconfig/ui/fontworkspacingdialog \ - svx/uiconfig/ui/fontsizebox \ svx/uiconfig/ui/formdatamenu \ svx/uiconfig/ui/formlinkwarndialog \ svx/uiconfig/ui/formnavimenu \ diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx index d6bf95f83a00..d944c616a600 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx @@ -136,7 +136,7 @@ ParaAboveSpacingWindow::ParaAboveSpacingWindow(vcl::Window* pParent) m_xAboveContainer->show(); m_xBelowContainer->hide(); - SetSizePixel(get_preferred_size()); + SetSizePixel(GetOptimalSize()); } void ParaAboveSpacingWindow::GetFocus() @@ -152,7 +152,7 @@ ParaBelowSpacingWindow::ParaBelowSpacingWindow(vcl::Window* pParent) m_xAboveContainer->hide(); m_xBelowContainer->show(); - SetSizePixel(get_preferred_size()); + SetSizePixel(GetOptimalSize()); } void ParaBelowSpacingWindow::GetFocus() @@ -359,7 +359,7 @@ ParaLeftSpacingWindow::ParaLeftSpacingWindow(vcl::Window* pParent) m_xAfterContainer->hide(); m_xFirstLineContainer->hide(); - SetSizePixel(get_preferred_size()); + SetSizePixel(GetOptimalSize()); } void ParaLeftSpacingWindow::GetFocus() @@ -376,7 +376,7 @@ ParaRightSpacingWindow::ParaRightSpacingWindow(vcl::Window* pParent) m_xAfterContainer->show(); m_xFirstLineContainer->hide(); - SetSizePixel(get_preferred_size()); + SetSizePixel(GetOptimalSize()); } void ParaRightSpacingWindow::GetFocus() @@ -393,7 +393,7 @@ ParaFirstLineSpacingWindow::ParaFirstLineSpacingWindow(vcl::Window* pParent) m_xAfterContainer->hide(); m_xFirstLineContainer->show(); - SetSizePixel(get_preferred_size()); + SetSizePixel(GetOptimalSize()); } void ParaFirstLineSpacingWindow::GetFocus() diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx index 9196a4a9f3d7..6a25e338f784 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx @@ -22,6 +22,8 @@ #include <cppuhelper/queryinterface.hxx> #include <editeng/ulspitem.hxx> #include <editeng/lrspitem.hxx> +#include <vcl/builder.hxx> +#include <vcl/layout.hxx> #include <vcl/EnumContext.hxx> #include <svx/relfld.hxx> #include <vcl/InterimItemWindow.hxx> diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx index b87d313a9ad4..ae76544c8037 100644 --- a/svx/source/tbxctrls/tbunocontroller.cxx +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -86,40 +86,32 @@ class FontHeightToolBoxControl : public svt::ToolboxController, css::awt::FontDescriptor m_aCurrentFont; }; -class SvxFontSizeBox_Impl : public InterimItemWindow +class SvxFontSizeBox_Impl : public FontSizeBox { public: SvxFontSizeBox_Impl( vcl::Window* pParent, const uno::Reference< frame::XFrame >& _xFrame, FontHeightToolBoxControl& rCtrl ); - virtual void dispose() override; - virtual ~SvxFontSizeBox_Impl() override; void statusChanged_Impl( long nHeight, bool bErase ); void UpdateFont( const css::awt::FontDescriptor& rCurrentFont ); void SetOptimalSize(); + virtual bool EventNotify( NotifyEvent& rNEvt ) override; virtual boost::property_tree::ptree DumpAsPropertyTree() override; protected: + virtual void Select() override; virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - virtual void GetFocus() override; private: - FontHeightToolBoxControl& m_rCtrl; + FontHeightToolBoxControl* m_pCtrl; OUString m_aCurText; + Size const m_aLogicalSize; bool m_bRelease; uno::Reference< frame::XFrame > m_xFrame; - std::unique_ptr<SvtFontSizeBox> m_xWidget; void ReleaseFocus_Impl(); - - void Select(); - - DECL_LINK(SelectHdl, weld::ComboBox&, void); - DECL_LINK(KeyInputHdl, const KeyEvent&, bool); - DECL_LINK(ActivateHdl, weld::ComboBox&, bool); - DECL_LINK(FocusOutHdl, weld::Widget&, void); }; SvxFontSizeBox_Impl::SvxFontSizeBox_Impl( @@ -127,38 +119,16 @@ SvxFontSizeBox_Impl::SvxFontSizeBox_Impl( const uno::Reference< frame::XFrame >& _xFrame, FontHeightToolBoxControl& _rCtrl ) : - InterimItemWindow(_pParent, "svx/ui/fontsizebox.ui", "FontSizeBox"), + FontSizeBox( _pParent, WinBits( WB_DROPDOWN ) ), - m_rCtrl ( _rCtrl ), + m_pCtrl ( &_rCtrl ), + m_aLogicalSize ( 0,100 ), m_bRelease ( true ), - m_xFrame ( _xFrame ), - m_xWidget(new SvtFontSizeBox(m_xBuilder->weld_combo_box("fontsize"))) + m_xFrame ( _xFrame ) { + SetValue( 0 ); + SetText( "" ); set_id("fontsizecombobox"); - m_xWidget->set_value(0); - m_xWidget->set_active_text(""); - m_xWidget->disable_entry_completion(); - - m_xWidget->connect_changed(LINK(this, SvxFontSizeBox_Impl, SelectHdl)); - m_xWidget->connect_key_press(LINK(this, SvxFontSizeBox_Impl, KeyInputHdl)); - m_xWidget->connect_entry_activate(LINK(this, SvxFontSizeBox_Impl, ActivateHdl)); - m_xWidget->connect_focus_out(LINK(this, SvxFontSizeBox_Impl, FocusOutHdl)); -} - -void SvxFontSizeBox_Impl::dispose() -{ - m_xWidget.reset(); - InterimItemWindow::dispose(); -} - -SvxFontSizeBox_Impl::~SvxFontSizeBox_Impl() -{ - disposeOnce(); -} - -void SvxFontSizeBox_Impl::GetFocus() -{ - m_xWidget->grab_focus(); } void SvxFontSizeBox_Impl::ReleaseFocus_Impl() @@ -173,35 +143,30 @@ void SvxFontSizeBox_Impl::ReleaseFocus_Impl() m_xFrame->getContainerWindow()->setFocus(); } -IMPL_LINK(SvxFontSizeBox_Impl, SelectHdl, weld::ComboBox&, rCombo, void) -{ - if (rCombo.changed_by_menu()) // only when picked from the list - Select(); -} - -IMPL_LINK_NOARG(SvxFontSizeBox_Impl, ActivateHdl, weld::ComboBox&, bool) -{ - Select(); - return true; -} void SvxFontSizeBox_Impl::Select() { - sal_Int64 nSelVal = m_xWidget->get_value(); - float fSelVal = float( nSelVal ) / 10; + FontSizeBox::Select(); + + if ( !IsTravelSelect() ) + { + sal_Int64 nSelVal = GetValue(); + float fSelVal = float( nSelVal ) / 10; - uno::Sequence< beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "FontHeight.Height"; - aArgs[0].Value <<= fSelVal; + uno::Sequence< beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = "FontHeight.Height"; + aArgs[0].Value <<= fSelVal; - /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. - This instance may be deleted in the meantime (i.e. when a dialog is opened - while in Dispatch()), accessing members will crash in this case. */ - ReleaseFocus_Impl(); + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + ReleaseFocus_Impl(); - m_rCtrl.dispatchCommand( aArgs ); + m_pCtrl->dispatchCommand( aArgs ); + } } + void SvxFontSizeBox_Impl::statusChanged_Impl( long nPoint, bool bErase ) { if ( !bErase ) @@ -210,22 +175,23 @@ void SvxFontSizeBox_Impl::statusChanged_Impl( long nPoint, bool bErase ) long nVal = nPoint; // changed => set new value - if (m_xWidget->get_value() != nVal) - m_xWidget->set_value(nVal); + if ( GetValue() != nVal ) + SetValue( nVal ); } else { // delete value in the display - m_xWidget->set_value(-1L); - m_xWidget->set_active_text(""); + SetValue( -1L ); + SetText( "" ); } - m_xWidget->save_value(); + SaveValue(); } + void SvxFontSizeBox_Impl::UpdateFont( const css::awt::FontDescriptor& rCurrentFont ) { // filling up the sizes list - auto nOldVal = m_xWidget->get_value(); // memorize old value + sal_Int64 nOldVal = GetValue(); // memorize old value const FontList* _pFontList = nullptr; std::unique_ptr<FontList> aHold( new FontList( this )); _pFontList = aHold.get(); @@ -236,49 +202,61 @@ void SvxFontSizeBox_Impl::UpdateFont( const css::awt::FontDescriptor& rCurrentFo _aFontMetric.SetFamilyName( rCurrentFont.Name ); _aFontMetric.SetStyleName( rCurrentFont.StyleName ); _aFontMetric.SetFontHeight( rCurrentFont.Height ); - m_xWidget->Fill(&_aFontMetric, _pFontList); + Fill( &_aFontMetric, _pFontList ); } else { - m_xWidget->Fill(nullptr, _pFontList); + Fill( nullptr, _pFontList ); } - m_xWidget->set_value(nOldVal); // restore old value - m_aCurText = m_xWidget->get_active_text(); // memorize to reset at ESC + SetValue( nOldVal ); // restore old value + m_aCurText = GetText(); // memorize to reset at ESC } -IMPL_LINK(SvxFontSizeBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool) + +bool SvxFontSizeBox_Impl::EventNotify( NotifyEvent& rNEvt ) { bool bHandled = false; - sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); + if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) + { + sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); - switch (nCode) + switch ( nCode ) + { + case KEY_RETURN: + case KEY_TAB: + { + if ( KEY_TAB == nCode ) + m_bRelease = false; + else + bHandled = true; + Select(); + break; + } + + case KEY_ESCAPE: + SetText( m_aCurText ); + if ( typeid( *GetParent() ) != typeid( sfx2::sidebar::SidebarToolBox ) ) + ReleaseFocus_Impl(); + bHandled = true; + break; + } + } + else if( MouseNotifyEvent::LOSEFOCUS == rNEvt.GetType() ) { - case KEY_TAB: - m_bRelease = false; - Select(); - break; - - case KEY_ESCAPE: - m_xWidget->set_active_text(m_aCurText); - if ( typeid( *GetParent() ) != typeid( sfx2::sidebar::SidebarToolBox ) ) - ReleaseFocus_Impl(); - bHandled = true; - break; + vcl::Window* pFocusWin = Application::GetFocusWindow(); + if(!HasFocus() && GetSubEdit() != pFocusWin) + SetText(GetSavedValue()); } - return bHandled || ChildKeyInput(rKEvt); -} - -IMPL_LINK_NOARG(SvxFontSizeBox_Impl, 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 - m_xWidget->set_value(m_xWidget->get_saved_value()); + return bHandled || FontSizeBox::EventNotify( rNEvt ); } void SvxFontSizeBox_Impl::SetOptimalSize() { - SetSizePixel(get_preferred_size()); + Size aPrefSize(LogicToPixel(m_aLogicalSize, MapMode(MapUnit::MapAppFont))); + aPrefSize.setWidth( get_preferred_size().Width() ); + SetSizePixel(aPrefSize); } void SvxFontSizeBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) @@ -288,18 +266,20 @@ void SvxFontSizeBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) { SetOptimalSize(); } + + FontSizeBox::DataChanged( rDCEvt ); } boost::property_tree::ptree SvxFontSizeBox_Impl::DumpAsPropertyTree() { - boost::property_tree::ptree aTree(m_xWidget->get_property_tree()); + boost::property_tree::ptree aTree(FontSizeBox::DumpAsPropertyTree()); boost::property_tree::ptree aEntries; - for (int i = 0, nCount = m_xWidget->get_count(); i < nCount; ++i) + for (int i = 0; i < GetEntryCount(); ++i) { boost::property_tree::ptree aEntry; - aEntry.put("", m_xWidget->get_text(i)); + aEntry.put("", GetEntry(i)); aEntries.push_back(std::make_pair("", aEntry)); } @@ -307,15 +287,14 @@ boost::property_tree::ptree SvxFontSizeBox_Impl::DumpAsPropertyTree() boost::property_tree::ptree aSelected; - int nActive = m_xWidget->get_active(); - if (nActive != -1) + for (int i = 0; i < GetSelectedEntryCount(); ++i) { boost::property_tree::ptree aEntry; - aEntry.put("", nActive); + aEntry.put("", GetSelectedEntryPos(i)); aSelected.push_back(std::make_pair("", aEntry)); } - aTree.put("selectedCount", nActive == -1 ? 0 : 1); + aTree.put("selectedCount", GetSelectedEntryCount()); aTree.add_child("selectedEntries", aSelected); aTree.put("command", ".uno:FontHeight"); diff --git a/svx/uiconfig/ui/fontsizebox.ui b/svx/uiconfig/ui/fontsizebox.ui deleted file mode 100644 index c1702822b3e2..000000000000 --- a/svx/uiconfig/ui/fontsizebox.ui +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> -<interface domain="svx"> - <requires lib="gtk+" version="3.18"/> - <object class="GtkBox" id="FontSizeBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="spacing">6</property> - <child> - <object class="GtkComboBoxText" id="fontsize"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="has_entry">True</property> - <child internal-child="entry"> - <object class="GtkEntry"> - <property name="can_focus">True</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> -</interface> |