summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-16 19:44:51 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-17 09:49:12 +0100
commit7e360360f332c99b392e9034fe70628fe4c3c6b1 (patch)
tree92bd32e8024ad5ac0976e7cb8425adbfce062be2
parent5c8f744279cb4c34d6f20218b9727fa4f699d93f (diff)
weld PosEdit ItemWindow
Change-Id: I8fdcba471f3497545b7542f38a8fcb2ad40a4cd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88821 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--solenv/sanitizers/ui/modules/swriter.suppr1
-rw-r--r--sw/UIConfig_swriter.mk1
-rw-r--r--sw/source/uibase/inc/inputwin.hxx49
-rw-r--r--sw/source/uibase/ribbar/inputwin.cxx24
-rw-r--r--sw/uiconfig/swriter/ui/poseditbox.ui27
5 files changed, 90 insertions, 12 deletions
diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index 5aef0b32dc8f..25757e0b7bf2 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -131,6 +131,7 @@ sw/uiconfig/swriter/ui/opttablepage.ui://GtkLabel[@id='label13'] orphan-label
sw/uiconfig/swriter/ui/opttablepage.ui://GtkLabel[@id='label4'] orphan-label
sw/uiconfig/swriter/ui/opttablepage.ui://GtkLabel[@id='label14'] orphan-label
sw/uiconfig/swriter/ui/outlinenumberingpage.ui://GtkDrawingArea[@id='preview'] no-labelled-by
+sw/uiconfig/swriter/ui/poseditbox.ui://GtkEntry[@id='entry'] no-labelled-by
sw/uiconfig/swriter/ui/mailmerge.ui://GtkSpinButton[@id='from'] no-labelled-by
sw/uiconfig/swriter/ui/mailmerge.ui://GtkLabel[@id='fieldlabel'] orphan-label
sw/uiconfig/swriter/ui/mailmerge.ui://GtkLabel[@id='mailformatlabel'] orphan-label
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 9c61eb252c6b..1139afec7010 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -259,6 +259,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/pagestylespanel \
sw/uiconfig/swriter/ui/pageheaderpanel \
sw/uiconfig/swriter/ui/pagefooterpanel \
+ sw/uiconfig/swriter/ui/poseditbox \
sw/uiconfig/swriter/ui/sidebarwrap \
sw/uiconfig/swriter/ui/sidebarstylepresets \
sw/uiconfig/swriter/ui/sidebartableedit \
diff --git a/sw/source/uibase/inc/inputwin.hxx b/sw/source/uibase/inc/inputwin.hxx
index 2fcac269e132..a8a0123a6e5d 100644
--- a/sw/source/uibase/inc/inputwin.hxx
+++ b/sw/source/uibase/inc/inputwin.hxx
@@ -19,6 +19,7 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_INPUTWIN_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_INPUTWIN_HXX
+#include <sfx2/InterimItemWindow.hxx>
#include <vcl/edit.hxx>
#include <vcl/menu.hxx>
#include <vcl/toolbox.hxx>
@@ -43,12 +44,56 @@ protected:
virtual void KeyInput( const KeyEvent& ) override;
};
+class PosEdit final : public InterimItemWindow
+{
+private:
+ std::unique_ptr<weld::Entry> m_xWidget;
+
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+public:
+ PosEdit(vcl::Window* pParent)
+ : InterimItemWindow(pParent, "modules/swriter/ui/poseditbox.ui", "PosEditBox")
+ , m_xWidget(m_xBuilder->weld_entry("entry"))
+ {
+ m_xWidget->connect_key_press(LINK(this, PosEdit, KeyInputHdl));
+ SetSizePixel(m_xWidget->get_preferred_size());
+ }
+
+ virtual void dispose() override
+ {
+ m_xWidget.reset();
+ InterimItemWindow::dispose();
+ }
+
+ virtual void GetFocus() override
+ {
+ if (m_xWidget)
+ m_xWidget->grab_focus();
+ InterimItemWindow::GetFocus();
+ }
+
+ void set_text(const OUString& rText)
+ {
+ m_xWidget->set_text(rText);
+ }
+
+ void set_accessible_name(const OUString& rName)
+ {
+ m_xWidget->set_accessible_name(rName);
+ }
+
+ virtual ~PosEdit() override
+ {
+ disposeOnce();
+ }
+};
+
class SwInputWindow final : public ToolBox
{
friend class InputEdit;
- VclPtr<Edit> aPos;
- VclPtr<InputEdit> aEdit;
+ VclPtr<PosEdit> mxPos;
+ VclPtr<InputEdit> aEdit;
std::unique_ptr<SwFieldMgr> pMgr;
SwWrtShell* pWrtShell;
SwView* pView;
diff --git a/sw/source/uibase/ribbar/inputwin.cxx b/sw/source/uibase/ribbar/inputwin.cxx
index 4b6ee2d286b3..b7e35a5c1310 100644
--- a/sw/source/uibase/ribbar/inputwin.cxx
+++ b/sw/source/uibase/ribbar/inputwin.cxx
@@ -58,9 +58,14 @@
SFX_IMPL_POS_CHILDWINDOW_WITHID( SwInputChild, FN_EDIT_FORMULA, SFX_OBJECTBAR_OBJECT )
+IMPL_LINK(PosEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+ return ChildKeyInput(rKEvt);
+}
+
SwInputWindow::SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispatcher)
: ToolBox(pParent, WB_3DLOOK|WB_BORDER)
- , aPos(VclPtr<Edit>::Create(this, WB_3DLOOK|WB_CENTER|WB_BORDER|WB_READONLY))
+ , mxPos(VclPtr<PosEdit>::Create(this))
, aEdit(VclPtr<InputEdit>::Create(this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION))
, pWrtShell(nullptr)
, pView(nullptr)
@@ -72,7 +77,6 @@ SwInputWindow::SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispat
bIsTable = bDelSel = false;
aEdit->SetSizePixel(aEdit->CalcMinimumSize());
- aPos->SetSizePixel(aPos->LogicToPixel(Size(45, 11), MapMode(MapUnit::MapAppFont)));
InsertItem(FN_FORMULA_CALC, Image(StockImage::Yes, RID_BMP_FORMULA_CALC),
SwResId(STR_FORMULA_CALC));
@@ -91,9 +95,9 @@ SwInputWindow::SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispat
pView = pActiveView;
pWrtShell = pView ? pView->GetWrtShellPtr() : nullptr;
- InsertWindow(ED_POS, aPos.get(), ToolBoxItemBits::NONE, 0);
+ InsertWindow(ED_POS, mxPos.get(), ToolBoxItemBits::NONE, 0);
SetItemText(ED_POS, SwResId(STR_ACCESS_FORMULA_TYPE));
- aPos->SetAccessibleName(SwResId(STR_ACCESS_FORMULA_TYPE));
+ mxPos->set_accessible_name(SwResId(STR_ACCESS_FORMULA_TYPE));
SetAccessibleName(SwResId(STR_ACCESS_FORMULA_TOOLBAR));
InsertSeparator ( 1 );
InsertSeparator ();
@@ -116,14 +120,14 @@ SwInputWindow::SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispat
SetSizePixel( aSize );
// align edit and item vcentered
- Size aPosSize = aPos->GetSizePixel();
+ Size aPosSize = mxPos->GetSizePixel();
aPosSize.setHeight( nMaxHeight );
aEditSize.setHeight( nMaxHeight );
- Point aPosPos = aPos->GetPosPixel();
+ Point aPosPos = mxPos->GetPosPixel();
Point aEditPos = aEdit->GetPosPixel();
aPosPos.setY( (aSize.Height() - nMaxHeight)/2 + 1 );
aEditPos.setY( (aSize.Height() - nMaxHeight)/2 + 1 );
- aPos->SetPosSizePixel( aPosPos, aPosSize );
+ mxPos->SetPosSizePixel( aPosPos, aPosSize );
aEdit->SetPosSizePixel( aEditPos, aEditSize );
}
@@ -146,7 +150,7 @@ void SwInputWindow::dispose()
CleanupUglyHackWithUndo();
- aPos.disposeAndClear();
+ mxPos.disposeAndClear();
aEdit.disposeAndClear();
ToolBox::dispose();
}
@@ -204,11 +208,11 @@ void SwInputWindow::ShowWin()
short nSrch = -1;
while( (nPos = rPos.indexOf( ':',nPos + 1 ) ) != -1 )
nSrch = static_cast<short>(nPos);
- aPos->SetText( rPos.copy( ++nSrch ) );
+ mxPos->set_text( rPos.copy( ++nSrch ) );
aCurrentTableName = pWrtShell->GetTableFormat()->GetName();
}
else
- aPos->SetText(SwResId(STR_TBL_FORMULA));
+ mxPos->set_text(SwResId(STR_TBL_FORMULA));
// Edit current field
OSL_ENSURE(pMgr == nullptr, "FieldManager not deleted");
diff --git a/sw/uiconfig/swriter/ui/poseditbox.ui b/sw/uiconfig/swriter/ui/poseditbox.ui
new file mode 100644
index 000000000000..9ea3238c007a
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/poseditbox.ui
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sc">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="PosEditBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="editable">False</property>
+ <property name="width_chars">8</property>
+ <property name="xalign">0.5</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>