summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/form/recorditemwindow.cxx89
-rw-r--r--svx/source/form/tbxform.cxx66
-rw-r--r--svx/source/inc/tbxform.hxx16
3 files changed, 94 insertions, 77 deletions
diff --git a/svx/source/form/recorditemwindow.cxx b/svx/source/form/recorditemwindow.cxx
new file mode 100644
index 000000000000..26920ee2a42f
--- /dev/null
+++ b/svx/source/form/recorditemwindow.cxx
@@ -0,0 +1,89 @@
+/* -*- 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 <vcl/event.hxx>
+#include <tbxform.hxx>
+
+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));
+
+ SetSizePixel(m_xWidget->get_preferred_size());
+}
+
+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 26ff4ad7a0cf..97aac28af619 100644
--- a/svx/source/form/tbxform.cxx
+++ b/svx/source/form/tbxform.cxx
@@ -34,39 +34,13 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window* pParent, SfxToolBoxControl* pController)
- : InterimItemWindow(pParent, "svx/ui/absrecbox.ui", "AbsRecBox")
- , m_xWidget(m_xBuilder->weld_entry("entry"))
+ : RecordItemWindow(pParent)
, m_pController(pController)
{
- InitControlBase(m_xWidget.get());
-
- m_xWidget->connect_key_press(LINK(this, SvxFmAbsRecWin, KeyInputHdl));
- m_xWidget->connect_activate(LINK(this, SvxFmAbsRecWin, ActivatedHdl));
- m_xWidget->connect_focus_out(LINK(this, SvxFmAbsRecWin, FocusOutHdl));
-
- SetSizePixel(m_xWidget->get_preferred_size());
}
-void SvxFmAbsRecWin::dispose()
+void SvxFmAbsRecWin::PositionFired(sal_Int64 nRecord)
{
- m_xWidget.reset();
- InterimItemWindow::dispose();
-}
-
-SvxFmAbsRecWin::~SvxFmAbsRecWin()
-{
- disposeOnce();
-}
-
-void SvxFmAbsRecWin::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;
-
SfxInt32Item aPositionParam( FN_PARAM_1, static_cast<sal_Int32>(nRecord) );
Any a;
@@ -77,42 +51,6 @@ void SvxFmAbsRecWin::FirePosition( bool _bForce )
m_pController->Dispatch( ".uno:AbsoluteRecord",
aArgs );
m_pController->updateStatus();
-
- m_xWidget->save_value();
-}
-
-IMPL_LINK_NOARG(SvxFmAbsRecWin, FocusOutHdl, weld::Widget&, void)
-{
- FirePosition( false );
-}
-
-IMPL_LINK(SvxFmAbsRecWin, 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(SvxFmAbsRecWin, ActivatedHdl, weld::Entry&, bool)
-{
- if (!m_xWidget->get_text().isEmpty())
- FirePosition( true );
- return true;
}
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlAbsRec, SfxInt32Item );
diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx
index 153fc0c74631..a167b51d42ea 100644
--- a/svx/source/inc/tbxform.hxx
+++ b/svx/source/inc/tbxform.hxx
@@ -20,25 +20,15 @@
#define INCLUDED_SVX_SOURCE_INC_TBXFORM_HXX
#include <sfx2/tbxctrl.hxx>
-#include <vcl/InterimItemWindow.hxx>
+#include <svx/recorditemwindow.hxx>
-class SvxFmAbsRecWin final : public InterimItemWindow
+class SvxFmAbsRecWin final : public RecordItemWindow
{
public:
SvxFmAbsRecWin( vcl::Window* _pParent, SfxToolBoxControl* _pController );
- virtual void dispose() override;
- virtual ~SvxFmAbsRecWin() override;
-
- void set_text(const OUString& rText) { m_xWidget->set_text(rText); }
private:
- std::unique_ptr<weld::Entry> m_xWidget;
-
- DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
- DECL_LINK(ActivatedHdl, weld::Entry&, bool);
- DECL_LINK(FocusOutHdl, weld::Widget&, void); // for invalidating our content when losing the focus
-
- void FirePosition( bool _bForce );
+ virtual void PositionFired(sal_Int64 nRecord) override;
SfxToolBoxControl* m_pController;
};