summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-23 10:26:09 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-23 20:45:17 +0200
commitb6311393b5a01eee500b1ebe440bce60939aaead (patch)
tree2da743b5fb32645a8b579825410ba456b4316215 /svx
parent6afd1e3c06e476a01c25032d3d95ed7e624b58e0 (diff)
weld AbsolutePos
Change-Id: I273d01bb5d8bf1a1d2dc9066b0c9f099bf115e32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99311 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/source/fmcomp/gridctrl.cxx72
-rw-r--r--svx/source/form/recorditemwindow.cxx93
-rw-r--r--svx/source/form/tbxform.cxx2
-rw-r--r--svx/source/inc/gridcell.hxx1
-rw-r--r--svx/source/inc/tbxform.hxx2
-rw-r--r--svx/uiconfig/ui/absrecbox.ui22
7 files changed, 43 insertions, 150 deletions
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<NavigationBar*>(GetParent())->PositionDataSource(static_cast<sal_Int32>(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<NavigationBar*>(GetParent())->PositionDataSource(static_cast<sal_Int32>(nRecord));
- static_cast<NavigationBar*>(GetParent())->InvalidateState(DbGridControlNavigationBarState::Absolute);
- }
+ NavigationBar* pBar = static_cast<NavigationBar*>(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<FixedText>::Create(this, WB_VCENTER))
- ,m_aAbsolute(VclPtr<DbGridControl::NavigationBar::AbsolutePos>::Create(this, WB_CENTER | WB_VCENTER))
+ ,m_aAbsolute(VclPtr<DbGridControl::NavigationBar::AbsolutePos>::Create(this))
,m_aRecordOf(VclPtr<FixedText>::Create(this, WB_VCENTER))
,m_aRecordCount(VclPtr<FixedText>::Create(this, WB_VCENTER))
,m_aFirstBtn(VclPtr<ImageButton>::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<DbGridControl*>(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 <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));
-
- 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 <memory>
#include <svx/gridctrl.hxx>
+#include <vcl/edit.hxx>
#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 <sfx2/tbxctrl.hxx>
-#include <svx/recorditemwindow.hxx>
+#include <svtools/recorditemwindow.hxx>
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 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="spacing">4</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkEntry" id="entry">
- <property name="visible">True</property>
+ <object class="GtkEntry" id="entry-frame">
<property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="width_chars">4</property>
@@ -23,5 +23,21 @@
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkEntry" id="entry-noframe">
+ <property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="has_frame">False</property>
+ <property name="width_chars">4</property>
+ <property name="shadow_type">none</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
</interface>