From b6311393b5a01eee500b1ebe440bce60939aaead Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 23 Jul 2020 10:26:09 +0100 Subject: weld AbsolutePos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I273d01bb5d8bf1a1d2dc9066b0c9f099bf115e32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99311 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- forms/source/solar/control/navtoolbar.cxx | 2 +- forms/source/solar/inc/navtoolbar.hxx | 2 +- include/svtools/brwbox.hxx | 4 +- include/svtools/recorditemwindow.hxx | 42 +++++++++++++ include/svx/gridctrl.hxx | 11 ++-- include/svx/recorditemwindow.hxx | 37 ----------- solenv/sanitizers/ui/svx.suppr | 3 +- svtools/Library_svt.mk | 1 + svtools/source/brwbox/brwbox1.cxx | 6 +- svtools/source/brwbox/brwbox2.cxx | 4 +- svtools/source/brwbox/recorditemwindow.cxx | 99 ++++++++++++++++++++++++++++++ svx/Library_svxcore.mk | 1 - svx/source/fmcomp/gridctrl.cxx | 72 +++++++--------------- svx/source/form/recorditemwindow.cxx | 93 ---------------------------- svx/source/form/tbxform.cxx | 2 +- svx/source/inc/gridcell.hxx | 1 + svx/source/inc/tbxform.hxx | 2 +- svx/uiconfig/ui/absrecbox.ui | 22 ++++++- 18 files changed, 202 insertions(+), 202 deletions(-) create mode 100644 include/svtools/recorditemwindow.hxx delete mode 100644 include/svx/recorditemwindow.hxx create mode 100644 svtools/source/brwbox/recorditemwindow.cxx delete mode 100644 svx/source/form/recorditemwindow.cxx diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx index 2f0147d04307..5c0ee830cbec 100644 --- a/forms/source/solar/control/navtoolbar.cxx +++ b/forms/source/solar/control/navtoolbar.cxx @@ -621,7 +621,7 @@ namespace frm } RecordPositionInput::RecordPositionInput(vcl::Window* pParent) - : RecordItemWindow(pParent) + : RecordItemWindow(pParent, true) , m_pDispatcher( nullptr ) { } diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx index 576ddb951293..c96fd141662b 100644 --- a/forms/source/solar/inc/navtoolbar.hxx +++ b/forms/source/solar/inc/navtoolbar.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX #define INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX -#include +#include #include namespace frm diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx index 67a3e8fdbb7a..00b68803515b 100644 --- a/include/svtools/brwbox.hxx +++ b/include/svtools/brwbox.hxx @@ -39,7 +39,7 @@ class BrowserColumn; class BrowserHeader; class ScrollBar; -class StatusBar; +class RecordItemWindow; namespace svt { class BrowseBoxImpl; @@ -275,7 +275,7 @@ private: VclPtr pDataWin; // window to display data rows VclPtr pVScroll; // vertical scrollbar VclPtr aHScroll; // horizontal scrollbar - VclPtr aStatusBar; // statusbar, just to measure its height + VclPtr aStatusBarHeight; // statusbar, just to measure its height long nDataRowHeight; // height of a single data-row sal_uInt16 nTitleLines; // number of lines in title row diff --git a/include/svtools/recorditemwindow.hxx b/include/svtools/recorditemwindow.hxx new file mode 100644 index 000000000000..576be8766430 --- /dev/null +++ b/include/svtools/recorditemwindow.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include + +class SVT_DLLPUBLIC RecordItemWindow : public InterimItemWindow +{ +public: + RecordItemWindow(vcl::Window* pParent, bool bHasFrame); + virtual void dispose() override; + virtual ~RecordItemWindow() override; + + void set_text(const OUString& rText) { m_xWidget->set_text(rText); } + void set_font(const vcl::Font& rFont) { m_xWidget->set_font(rFont); } + +protected: + virtual bool DoKeyInput(const KeyEvent& rEvt); + +private: + virtual void PositionFired(sal_Int64 nRecord); + + std::unique_ptr m_xWidget; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + + DECL_LINK(ActivatedHdl, weld::Entry&, bool); + // for invalidating our content when losing the focus + DECL_LINK(FocusOutHdl, weld::Widget&, void); + + void FirePosition(bool bForce); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/svx/gridctrl.hxx b/include/svx/gridctrl.hxx index 90eaa9927280..c07f9ed464f1 100644 --- a/include/svx/gridctrl.hxx +++ b/include/svx/gridctrl.hxx @@ -20,12 +20,13 @@ #define INCLUDED_SVX_GRIDCTRL_HXX #include -#include #include #include +#include #include #include +#include #include #include #include @@ -174,13 +175,13 @@ public: class SAL_DLLPRIVATE NavigationBar final : public Control { - class AbsolutePos : public NumericField + class AbsolutePos final : public RecordItemWindow { public: - AbsolutePos(vcl::Window* pParent, WinBits nStyle); + AbsolutePos(vcl::Window* pParent); - virtual void KeyInput(const KeyEvent& rEvt) override; - virtual void LoseFocus() override; + virtual bool DoKeyInput(const KeyEvent& rEvt) override; + virtual void PositionFired(sal_Int64 nRecord) override; }; friend class NavigationBar::AbsolutePos; diff --git a/include/svx/recorditemwindow.hxx b/include/svx/recorditemwindow.hxx deleted file mode 100644 index d49db978c136..000000000000 --- a/include/svx/recorditemwindow.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#pragma once - -#include -#include - -class SVXCORE_DLLPUBLIC RecordItemWindow : public InterimItemWindow -{ -public: - RecordItemWindow(vcl::Window* _pParent); - virtual void dispose() override; - virtual ~RecordItemWindow() override; - - void set_text(const OUString& rText) { m_xWidget->set_text(rText); } - -private: - virtual void PositionFired(sal_Int64 nRecord) = 0; - - std::unique_ptr m_xWidget; - - DECL_LINK(KeyInputHdl, const KeyEvent&, bool); - DECL_LINK(ActivatedHdl, weld::Entry&, bool); - // for invalidating our content when losing the focus - DECL_LINK(FocusOutHdl, weld::Widget&, void); - - void FirePosition(bool bForce); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/solenv/sanitizers/ui/svx.suppr b/solenv/sanitizers/ui/svx.suppr index d33877fd457f..5a9d0f52fde2 100644 --- a/solenv/sanitizers/ui/svx.suppr +++ b/solenv/sanitizers/ui/svx.suppr @@ -1,4 +1,5 @@ -svx/uiconfig/ui/absrecbox.ui://GtkEntry[@id='entry'] no-labelled-by +svx/uiconfig/ui/absrecbox.ui://GtkEntry[@id='entry-frame'] no-labelled-by +svx/uiconfig/ui/absrecbox.ui://GtkEntry[@id='entry-noframe'] no-labelled-by svx/uiconfig/ui/addinstancedialog.ui://GtkLabel[@id='alttitle'] orphan-label svx/uiconfig/ui/addmodeldialog.ui://GtkLabel[@id='alttitle'] orphan-label svx/uiconfig/ui/addnamespacedialog.ui://GtkLabel[@id='alttitle'] orphan-label diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 63bb7e13205d..456a7ae568a0 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/brwbox/ebbcontrols \ svtools/source/brwbox/editbrowsebox \ svtools/source/brwbox/editbrowsebox2 \ + svtools/source/brwbox/recorditemwindow \ svtools/source/config/accessibilityoptions \ svtools/source/config/apearcfg \ svtools/source/config/colorcfg \ diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index 17392a79db0e..5bac96fc1945 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include "datwin.hxx" @@ -26,7 +27,6 @@ #include #include #include -#include #include #include @@ -110,7 +110,7 @@ BrowseBox::BrowseBox( vcl::Window* pParent, WinBits nBits, BrowserMode nMode ) ,DragSourceHelper( this ) ,DropTargetHelper( this ) ,aHScroll( VclPtr::Create(this, WB_HSCROLL) ) - ,aStatusBar( VclPtr::Create(this) ) + ,aStatusBarHeight(VclPtr::Create(this, false)) { ConstructImpl( nMode ); } @@ -137,7 +137,7 @@ void BrowseBox::dispose() pDataWin.disposeAndClear(); pVScroll.disposeAndClear(); aHScroll.disposeAndClear(); - aStatusBar.disposeAndClear(); + aStatusBarHeight.disposeAndClear(); // free columns-space mvCols.clear(); diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 1046363849b9..5abdf5e34099 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -22,13 +22,13 @@ #include #include #include +#include #include "datwin.hxx" #include #include #include #include #include -#include #include #include @@ -1037,7 +1037,7 @@ long BrowseBox::GetBarHeight() const // (we can't ask the scrollbars for their size cause if we're zoomed they still have to be // resized - which is done in UpdateScrollbars) - return std::max(aStatusBar->GetSizePixel().Height(), GetSettings().GetStyleSettings().GetScrollBarSize()); + return std::max(aStatusBarHeight->GetSizePixel().Height(), GetSettings().GetStyleSettings().GetScrollBarSize()); } void BrowseBox::UpdateScrollbars() diff --git a/svtools/source/brwbox/recorditemwindow.cxx b/svtools/source/brwbox/recorditemwindow.cxx new file mode 100644 index 000000000000..a993044cb6de --- /dev/null +++ b/svtools/source/brwbox/recorditemwindow.cxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +RecordItemWindow::RecordItemWindow(vcl::Window* pParent, bool bHasFrame) + : InterimItemWindow(pParent, "svx/ui/absrecbox.ui", "AbsRecBox") + , m_xWidget(m_xBuilder->weld_entry(bHasFrame ? "entry-frame" : "entry-noframe")) +{ + InitControlBase(m_xWidget.get()); + + m_xWidget->connect_key_press(LINK(this, RecordItemWindow, KeyInputHdl)); + m_xWidget->connect_activate(LINK(this, RecordItemWindow, ActivatedHdl)); + m_xWidget->connect_focus_out(LINK(this, RecordItemWindow, FocusOutHdl)); + + m_xWidget->show(); + + auto aPrefSize(m_xWidget->get_preferred_size()); + + m_xWidget->set_width_chars(1); // so a smaller than default width can be used later + + SetSizePixel(aPrefSize); +} + +void RecordItemWindow::dispose() +{ + m_xWidget.reset(); + InterimItemWindow::dispose(); +} + +RecordItemWindow::~RecordItemWindow() { disposeOnce(); } + +void RecordItemWindow::FirePosition(bool _bForce) +{ + if (!_bForce && !m_xWidget->get_value_changed_from_saved()) + return; + + sal_Int64 nRecord = m_xWidget->get_text().toInt64(); + if (nRecord < 1) + nRecord = 1; + + PositionFired(nRecord); + + m_xWidget->save_value(); +} + +IMPL_LINK_NOARG(RecordItemWindow, FocusOutHdl, weld::Widget&, void) { FirePosition(false); } + +bool RecordItemWindow::DoKeyInput(const KeyEvent& rKEvt) +{ + vcl::KeyCode aCode = rKEvt.GetKeyCode(); + bool bUp = (aCode.GetCode() == KEY_UP); + bool bDown = (aCode.GetCode() == KEY_DOWN); + + if (!aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && (bUp || bDown)) + { + sal_Int64 nRecord = m_xWidget->get_text().toInt64(); + if (bUp) + ++nRecord; + else + --nRecord; + if (nRecord < 1) + nRecord = 1; + m_xWidget->set_text(OUString::number(nRecord)); + return true; + } + + return ChildKeyInput(rKEvt); +} + +void RecordItemWindow::PositionFired(sal_Int64 /*nRecord*/) {} + +IMPL_LINK(RecordItemWindow, KeyInputHdl, const KeyEvent&, rKEvt, bool) { return DoKeyInput(rKEvt); } + +IMPL_LINK_NOARG(RecordItemWindow, ActivatedHdl, weld::Entry&, bool) +{ + if (!m_xWidget->get_text().isEmpty()) + FirePosition(true); + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index bd9cf307393b..73d22cafee6c 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -469,7 +469,6 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/form/navigatortree \ svx/source/form/navigatortreemodel \ svx/source/form/ParseContext \ - svx/source/form/recorditemwindow \ svx/source/form/sdbdatacolumn \ svx/source/form/sqlparserclient \ svx/source/form/typemap \ diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 71d51825c560..e0d8093ec989 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -274,44 +274,26 @@ void FmXGridSourcePropListener::_propertyChanged(const PropertyChangeEvent& evt) m_pParent->DataSourcePropertyChanged(evt); } -DbGridControl::NavigationBar::AbsolutePos::AbsolutePos(vcl::Window* pParent, WinBits nStyle) - :NumericField(pParent, nStyle) +DbGridControl::NavigationBar::AbsolutePos::AbsolutePos(vcl::Window* pParent) + : RecordItemWindow(pParent, false) { - SetMin(1); - SetFirst(1); - SetSpinSize(1); - - SetDecimalDigits(0); - SetStrictFormat(true); } -void DbGridControl::NavigationBar::AbsolutePos::KeyInput(const KeyEvent& rEvt) +bool DbGridControl::NavigationBar::AbsolutePos::DoKeyInput(const KeyEvent& rEvt) { - if (rEvt.GetKeyCode() == KEY_RETURN && !GetText().isEmpty()) + if (rEvt.GetKeyCode() == KEY_TAB) { - sal_Int64 nRecord = GetValue(); - if (nRecord < GetMin() || nRecord > GetMax()) - return; - else - static_cast(GetParent())->PositionDataSource(static_cast(nRecord)); - } - else if (rEvt.GetKeyCode() == KEY_TAB) GetParent()->GetParent()->GrabFocus(); - else - NumericField::KeyInput(rEvt); + return true; + } + return RecordItemWindow::DoKeyInput(rEvt); } -void DbGridControl::NavigationBar::AbsolutePos::LoseFocus() +void DbGridControl::NavigationBar::AbsolutePos::PositionFired(sal_Int64 nRecord) { - NumericField::LoseFocus(); - sal_Int64 nRecord = GetValue(); - if (nRecord < GetMin() || nRecord > GetMax()) - return; - else - { - static_cast(GetParent())->PositionDataSource(static_cast(nRecord)); - static_cast(GetParent())->InvalidateState(DbGridControlNavigationBarState::Absolute); - } + NavigationBar* pBar = static_cast(GetParent()); + pBar->PositionDataSource(nRecord); + pBar->InvalidateState(DbGridControlNavigationBarState::Absolute); } void DbGridControl::NavigationBar::PositionDataSource(sal_Int32 nRecord) @@ -328,7 +310,7 @@ void DbGridControl::NavigationBar::PositionDataSource(sal_Int32 nRecord) DbGridControl::NavigationBar::NavigationBar(vcl::Window* pParent) :Control(pParent, 0) ,m_aRecordText(VclPtr::Create(this, WB_VCENTER)) - ,m_aAbsolute(VclPtr::Create(this, WB_CENTER | WB_VCENTER)) + ,m_aAbsolute(VclPtr::Create(this)) ,m_aRecordOf(VclPtr::Create(this, WB_VCENTER)) ,m_aRecordCount(VclPtr::Create(this, WB_VCENTER)) ,m_aFirstBtn(VclPtr::Create(this, WB_RECTSTYLE|WB_NOPOINTERFOCUS)) @@ -392,7 +374,6 @@ DbGridControl::NavigationBar::NavigationBar(vcl::Window* pParent) m_aAbsolute->Show(); } - DbGridControl::NavigationBar::~NavigationBar() { disposeOnce(); @@ -428,6 +409,7 @@ sal_uInt16 DbGridControl::NavigationBar::ArrangeControls() // calculate base size tools::Rectangle aRect(static_cast(GetParent())->GetControlArea()); long nH = aRect.GetSize().Height(); + long nW = GetParent()->GetOutputSizePixel().Width(); Size aBorder = LogicToPixel(Size(2, 2), MapMode(MapUnit::MapAppFont)); aBorder = Size(CalcZoom(aBorder.Width()), CalcZoom(aBorder.Height())); @@ -436,7 +418,7 @@ sal_uInt16 DbGridControl::NavigationBar::ArrangeControls() { vcl::Font aApplFont(GetSettings().GetStyleSettings().GetToolFont()); - m_aAbsolute->SetControlFont( aApplFont ); + m_aAbsolute->set_font(aApplFont); aApplFont.SetTransparent( true ); m_aRecordText->SetControlFont( aApplFont ); m_aRecordOf->SetControlFont( aApplFont ); @@ -451,7 +433,7 @@ sal_uInt16 DbGridControl::NavigationBar::ArrangeControls() nX = sal::static_int_cast< sal_uInt16 >(nX + nTextWidth + aBorder.Width()); // count an extra hairspace (U+200A) left and right - const OUString sevenDigits(m_aAbsolute->CreateFieldText(6000000)); + const OUString sevenDigits(OUString::number(6000000)); const OUString hairSpace(u'\x200A'); OUString textPattern = hairSpace + sevenDigits + hairSpace; nTextWidth = m_aAbsolute->GetTextWidth(textPattern); @@ -691,21 +673,9 @@ void DbGridControl::NavigationBar::SetState(DbGridControlNavigationBarState nWhi case DbGridControlNavigationBarState::Absolute: pWnd = m_aAbsolute.get(); if (bAvailable) - { - if (pParent->m_nTotalCount >= 0) - { - if (pParent->IsCurrentAppending()) - m_aAbsolute->SetMax(pParent->m_nTotalCount + 1); - else - m_aAbsolute->SetMax(pParent->m_nTotalCount); - } - else - m_aAbsolute->SetMax(LONG_MAX); - - m_aAbsolute->SetValue(m_nCurrentPos + 1); - } + m_aAbsolute->set_text(OUString::number(m_nCurrentPos + 1)); else - m_aAbsolute->SetText(OUString()); + m_aAbsolute->set_text(OUString()); break; case DbGridControlNavigationBarState::Text: pWnd = m_aRecordText.get(); @@ -722,12 +692,12 @@ void DbGridControl::NavigationBar::SetState(DbGridControlNavigationBarState nWhi if (pParent->GetOptions() & DbGridControlOptions::Insert) { if (pParent->IsCurrentAppending() && !pParent->IsModified()) - aText = m_aAbsolute->CreateFieldText(pParent->GetRowCount()); + aText = OUString::number(pParent->GetRowCount()); else - aText = m_aAbsolute->CreateFieldText(pParent->GetRowCount() - 1); + aText = OUString::number(pParent->GetRowCount() - 1); } else - aText = m_aAbsolute->CreateFieldText(pParent->GetRowCount()); + aText = OUString::number(pParent->GetRowCount()); if(!pParent->m_bRecordCountFinal) aText += " *"; } @@ -738,7 +708,7 @@ void DbGridControl::NavigationBar::SetState(DbGridControlNavigationBarState nWhi if (pParent->GetSelectRowCount()) { OUString aExtendedInfo = aText + " (" + - m_aAbsolute->CreateFieldText(pParent->GetSelectRowCount()) + ")"; + OUString::number(pParent->GetSelectRowCount()) + ")"; pWnd->SetText(aExtendedInfo); } else diff --git a/svx/source/form/recorditemwindow.cxx b/svx/source/form/recorditemwindow.cxx deleted file mode 100644 index efb07343ecfc..000000000000 --- a/svx/source/form/recorditemwindow.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include - -RecordItemWindow::RecordItemWindow(vcl::Window* pParent) - : InterimItemWindow(pParent, "svx/ui/absrecbox.ui", "AbsRecBox") - , m_xWidget(m_xBuilder->weld_entry("entry")) -{ - InitControlBase(m_xWidget.get()); - - m_xWidget->connect_key_press(LINK(this, RecordItemWindow, KeyInputHdl)); - m_xWidget->connect_activate(LINK(this, RecordItemWindow, ActivatedHdl)); - m_xWidget->connect_focus_out(LINK(this, RecordItemWindow, FocusOutHdl)); - - auto aPrefSize(m_xWidget->get_preferred_size()); - - m_xWidget->set_width_chars(1); // so a smaller than default width can be used later - - SetSizePixel(aPrefSize); -} - -void RecordItemWindow::dispose() -{ - m_xWidget.reset(); - InterimItemWindow::dispose(); -} - -RecordItemWindow::~RecordItemWindow() { disposeOnce(); } - -void RecordItemWindow::FirePosition(bool _bForce) -{ - if (!_bForce && !m_xWidget->get_value_changed_from_saved()) - return; - - sal_Int64 nRecord = m_xWidget->get_text().toInt64(); - if (nRecord < 1) - nRecord = 1; - - PositionFired(nRecord); - - m_xWidget->save_value(); -} - -IMPL_LINK_NOARG(RecordItemWindow, FocusOutHdl, weld::Widget&, void) { FirePosition(false); } - -IMPL_LINK(RecordItemWindow, KeyInputHdl, const KeyEvent&, rKEvt, bool) -{ - vcl::KeyCode aCode = rKEvt.GetKeyCode(); - bool bUp = (aCode.GetCode() == KEY_UP); - bool bDown = (aCode.GetCode() == KEY_DOWN); - - if (!aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && (bUp || bDown)) - { - sal_Int64 nRecord = m_xWidget->get_text().toInt64(); - if (bUp) - ++nRecord; - else - --nRecord; - if (nRecord < 1) - nRecord = 1; - m_xWidget->set_text(OUString::number(nRecord)); - return true; - } - - return ChildKeyInput(rKEvt); -} - -IMPL_LINK_NOARG(RecordItemWindow, ActivatedHdl, weld::Entry&, bool) -{ - if (!m_xWidget->get_text().isEmpty()) - FirePosition(true); - return true; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx index 97aac28af619..ad081492f25c 100644 --- a/svx/source/form/tbxform.cxx +++ b/svx/source/form/tbxform.cxx @@ -34,7 +34,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window* pParent, SfxToolBoxControl* pController) - : RecordItemWindow(pParent) + : RecordItemWindow(pParent, true) , m_pController(pController) { } diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index 2f57874c779b..669d1d6095a8 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -22,6 +22,7 @@ #include #include +#include #include "sqlparserclient.hxx" diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx index a167b51d42ea..cd8f7e037502 100644 --- a/svx/source/inc/tbxform.hxx +++ b/svx/source/inc/tbxform.hxx @@ -20,7 +20,7 @@ #define INCLUDED_SVX_SOURCE_INC_TBXFORM_HXX #include -#include +#include class SvxFmAbsRecWin final : public RecordItemWindow { diff --git a/svx/uiconfig/ui/absrecbox.ui b/svx/uiconfig/ui/absrecbox.ui index a91603f505f6..b1f763b33587 100644 --- a/svx/uiconfig/ui/absrecbox.ui +++ b/svx/uiconfig/ui/absrecbox.ui @@ -7,11 +7,11 @@ False True True - 4 + vertical - - True + True + True True True 4 @@ -23,5 +23,21 @@ 0 + + + True + True + True + True + False + 4 + none + + + False + True + 1 + + -- cgit