Kaydet (Commit) 3bd10306 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SwCaptionOptPage

Change-Id: I3373a39d6d8b39717b7aec69544a9d2957db15d8
Reviewed-on: https://gerrit.libreoffice.org/65010
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 27995e63
......@@ -662,8 +662,6 @@ sw/source/uibase/dbui/mmconfigitem.cxx:111
SwMailMergeConfigItem_Impl m_aNeutralGreetingLines std::vector<OUString>
sw/source/uibase/inc/fldmgr.hxx:78
SwInsertField_Data m_aDBDataSource const css::uno::Any
sw/source/uibase/inc/optload.hxx:106
CaptionComboBox aDefault const class rtl::OUString
toolkit/source/awt/vclxtoolkit.cxx:434
(anonymous namespace)::VCLXToolkit mxSelection css::uno::Reference<css::datatransfer::clipboard::XClipboard>
ucb/source/ucp/gio/gio_mount.hxx:46
......
......@@ -353,10 +353,6 @@
generic-name="SelectionListBox" parent="VclComboBoxText"
icon-name="widget-gtk-comboboxtext"/>
<glade-widget-class title="CaptionComboBox" name="swuilo-CaptionComboBox"
generic-name="CaptionComboBox" parent="VclComboBoxText"
icon-name="widget-gtk-comboboxtext"/>
<glade-widget-class title="PropertyControl" name="sdlo-PropertyControl"
generic-name="PropertyControl" parent="VclComboBoxText"
icon-name="widget-gtk-comboboxtext"/>
......
......@@ -313,6 +313,7 @@ private:
protected:
Link<ComboBox&, void> m_aChangeHdl;
Link<ComboBox&, bool> m_aEntryActivateHdl;
Link<OUString&, bool> m_aEntryInsertTextHdl;
void signal_changed() { m_aChangeHdl.Call(*this); }
......@@ -379,6 +380,11 @@ public:
virtual bool get_popup_shown() const = 0;
void connect_entry_insert_text(const Link<OUString&, bool>& rLink)
{
m_aEntryInsertTextHdl = rLink;
}
// callback returns true to indicated no further processing of activate wanted
void connect_entry_activate(const Link<ComboBox&, bool>& rLink) { m_aEntryActivateHdl = rLink; }
......@@ -413,10 +419,7 @@ protected:
void signal_row_activated() { m_aRowActivatedHdl.Call(*this); }
bool signal_expanding(TreeIter& rIter) { return m_aExpandingHdl.Call(rIter); }
// arg is pair<row,col>
void signal_radio_toggled(const std::pair<int, int>& rRowCol)
{
m_aRadioToggleHdl.Call(rRowCol);
}
void signal_toggled(const std::pair<int, int>& rRowCol) { m_aRadioToggleHdl.Call(rRowCol); }
public:
virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId,
......@@ -459,7 +462,7 @@ public:
void connect_changed(const Link<TreeView&, void>& rLink) { m_aChangeHdl = rLink; }
void connect_row_activated(const Link<TreeView&, void>& rLink) { m_aRowActivatedHdl = rLink; }
void connect_radio_toggled(const Link<const std::pair<int, int>&, void>& rLink)
void connect_toggled(const Link<const std::pair<int, int>&, void>& rLink)
{
m_aRadioToggleHdl = rLink;
}
......
......@@ -405,7 +405,6 @@ constructor_map = {
custom_widgets = [
'ArgEdit',
'BookmarksBox',
'CaptionComboBox',
'CategoryListBox',
'ClassificationEditView',
'ColorConfigCtrl',
......
This diff is collapsed.
......@@ -550,7 +550,7 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent,
for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
aRadioColumns.push_back(i + 1);
m_xHeaderTree->set_toggle_columns_as_radio(aRadioColumns);
m_xHeaderTree->connect_radio_toggled(LINK(this, SwAddStylesDlg_Impl, RadioToggleOnHdl));
m_xHeaderTree->connect_toggled(LINK(this, SwAddStylesDlg_Impl, RadioToggleOnHdl));
std::vector<int> aWidths;
aWidths.push_back(m_xHeaderTree->get_approximate_digit_width() * 30);
......
......@@ -21,10 +21,12 @@
#include <sfx2/tabdlg.hxx>
#include <vcl/customweld.hxx>
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/field.hxx>
#include <vcl/weld.hxx>
#include <svx/strarray.hxx>
#include <sfx2/basedlgs.hxx>
#include <svx/checklbx.hxx>
......@@ -99,16 +101,6 @@ public:
SwCaptionOptDlg(vcl::Window* pParent, const SfxItemSet& rSet);
};
class CaptionComboBox : public ComboBox
{
protected:
virtual void KeyInput( const KeyEvent& ) override;
public:
CaptionComboBox(vcl::Window* pParent, WinBits nStyle);
virtual ~CaptionComboBox() override;
};
class SwCaptionPreview : public vcl::Window
{
private:
......@@ -123,32 +115,25 @@ public:
virtual Size GetOptimalSize() const override;
};
class SwCaptionOptPage : public SfxTabPage
class CaptionPreview : public weld::CustomWidgetController
{
private:
VclPtr<SvxCheckListBox> m_pCheckLB;
VclPtr<ListBox> m_pLbCaptionOrder;
VclPtr<SwCaptionPreview> m_pPreview;
VclPtr<VclContainer> m_pSettingsGroup;
VclPtr<CaptionComboBox> m_pCategoryBox;
VclPtr<FixedText> m_pFormatText;
VclPtr<ListBox> m_pFormatBox;
//#i61007# order of captions
VclPtr<FixedText> m_pNumberingSeparatorFT;
VclPtr<Edit> m_pNumberingSeparatorED;
VclPtr<FixedText> m_pTextText;
VclPtr<Edit> m_pTextEdit;
VclPtr<ListBox> m_pPosBox;
OUString maText;
bool mbFontInitialized;
vcl::Font maFont;
VclPtr<VclContainer> m_pNumCapt;
VclPtr<ListBox> m_pLbLevel;
VclPtr<Edit> m_pEdDelim;
void ApplySettings(vcl::RenderContext& rRenderContext);
VclPtr<VclContainer> m_pCategory;
VclPtr<ListBox> m_pCharStyleLB;
VclPtr<CheckBox> m_pApplyBorderCB;
public:
CaptionPreview();
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
void SetPreviewText(const OUString& rText);
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
};
class SwCaptionOptPage : public SfxTabPage
{
private:
OUString const m_sSWTable;
OUString const m_sSWFrame;
OUString const m_sSWGraphic;
......@@ -166,31 +151,62 @@ private:
OUString const m_sNone;
int m_nPrevSelectedEntry;
std::unique_ptr<SwFieldMgr> pMgr;
bool bHTMLMode;
TextFilterAutoConvert m_aTextFilter;
DECL_LINK(SelectHdl, ComboBox&, void);
DECL_LINK(SelectListBoxHdl, ListBox&, void);
DECL_LINK(ModifyHdl, Edit&, void);
DECL_LINK( OrderHdl, ListBox&, void );
DECL_LINK(ShowEntryHdl, SvTreeListBox*, void);
DECL_LINK(SaveEntryHdl, SvTreeListBox*, void);
CaptionPreview m_aPreview;
std::unique_ptr<weld::TreeView> m_xCheckLB;
std::unique_ptr<weld::ComboBox> m_xLbCaptionOrder;
std::unique_ptr<weld::Widget> m_xSettingsGroup;
std::unique_ptr<weld::ComboBox> m_xCategoryBox;
std::unique_ptr<weld::Label> m_xFormatText;
std::unique_ptr<weld::ComboBox> m_xFormatBox;
//#i61007# order of captions
std::unique_ptr<weld::Label> m_xNumberingSeparatorFT;
std::unique_ptr<weld::Entry> m_xNumberingSeparatorED;
std::unique_ptr<weld::Label> m_xTextText;
std::unique_ptr<weld::Entry> m_xTextEdit;
std::unique_ptr<weld::ComboBox> m_xPosBox;
std::unique_ptr<weld::Widget> m_xNumCapt;
std::unique_ptr<weld::ComboBox> m_xLbLevel;
std::unique_ptr<weld::Entry> m_xEdDelim;
std::unique_ptr<weld::Widget> m_xCategory;
std::unique_ptr<weld::ComboBox> m_xCharStyleLB;
std::unique_ptr<weld::CheckButton> m_xApplyBorderCB;
std::unique_ptr<weld::CustomWeld> m_xPreview;
typedef std::pair<int, int> row_col;
DECL_LINK(SelectHdl, weld::ComboBox&, void);
DECL_LINK(SelectListBoxHdl, weld::ComboBox&, void);
DECL_LINK(ModifyEntryHdl, weld::Entry&, void);
DECL_LINK(ModifyComboHdl, weld::ComboBox&, void);
DECL_LINK(OrderHdl, weld::ComboBox&, void );
DECL_LINK(ShowEntryHdl, weld::TreeView&, void);
DECL_LINK(ToggleEntryHdl, const row_col&, void);
DECL_LINK(TextFilterHdl, OUString&, bool);
void ModifyHdl();
void UpdateEntry(int nRow);
void DelUserData();
void SetOptions(const sal_uLong nPos, const SwCapObjType eType, const SvGlobalName *pOleId = nullptr);
void SaveEntry(SvTreeListEntry const * pEntry);
void SaveEntry(int nEntry);
void InvalidatePreview();
public:
SwCaptionOptPage( vcl::Window* pParent,
const SfxItemSet& rSet );
virtual ~SwCaptionOptPage() override;
SwCaptionOptPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~SwCaptionOptPage() override;
virtual void dispose() override;
static VclPtr<SfxTabPage> Create( TabPageParent pParent,
const SfxItemSet* rAttrSet);
static VclPtr<SfxTabPage> Create(TabPageParent pParent,
const SfxItemSet* rAttrSet);
virtual bool FillItemSet( SfxItemSet* rSet ) override;
virtual void Reset( const SfxItemSet* rSet ) override;
......
......@@ -1625,15 +1625,8 @@ public:
}
};
class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry
namespace
{
private:
VclPtr<Edit> m_xEntry;
DECL_LINK(ChangeHdl, Edit&, void);
DECL_LINK(CursorListener, VclWindowEvent&, void);
DECL_LINK(ActivateHdl, Edit&, bool);
class WeldTextFilter : public TextFilter
{
private:
......@@ -1656,6 +1649,16 @@ private:
return sText;
}
};
}
class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry
{
private:
VclPtr<Edit> m_xEntry;
DECL_LINK(ChangeHdl, Edit&, void);
DECL_LINK(CursorListener, VclWindowEvent&, void);
DECL_LINK(ActivateHdl, Edit&, bool);
WeldTextFilter m_aTextFilter;
public:
......@@ -1852,6 +1855,7 @@ public:
pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1 ), HEADERBAR_FULLSIZE);
pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl));
}
m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
}
......@@ -2420,7 +2424,7 @@ IMPL_LINK(SalInstanceTreeView, ToggleHdl, SvLBoxButtonData*, pData, void)
{
int nRow = m_xTreeView->GetAbsPos(pEntry);
int nCol = i - 1; // less dummy/expander column
signal_radio_toggled(std::make_pair(nRow, nCol));
signal_toggled(std::make_pair(nRow, nCol));
break;
}
}
......@@ -3183,12 +3187,15 @@ class SalInstanceComboBoxWithEdit : public SalInstanceComboBox<ComboBox>
private:
DECL_LINK(ChangeHdl, Edit&, void);
DECL_LINK(EntryActivateHdl, Edit&, bool);
WeldTextFilter m_aTextFilter;
public:
SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, bool bTakeOwnership)
: SalInstanceComboBox<::ComboBox>(pComboBox, bTakeOwnership)
, m_aTextFilter(m_aEntryInsertTextHdl)
{
m_xComboBox->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit, ChangeHdl));
m_xComboBox->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxWithEdit, EntryActivateHdl));
m_xComboBox->SetTextFilter(&m_aTextFilter);
}
virtual bool has_entry() const override
......@@ -3267,6 +3274,7 @@ public:
virtual ~SalInstanceComboBoxWithEdit() override
{
m_xComboBox->SetTextFilter(nullptr);
m_xComboBox->SetEntryActivateHdl(Link<Edit&, bool>());
m_xComboBox->SetModifyHdl(Link<Edit&, void>());
}
......
......@@ -4892,14 +4892,14 @@ private:
return bRet;
}
static void signalToggled(GtkCellRendererToggle* pCell, const gchar *path, gpointer widget)
static void signalCellToggled(GtkCellRendererToggle* pCell, const gchar *path, gpointer widget)
{
GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
void* pData = g_object_get_data(G_OBJECT(pCell), "g-lo-CellIndex");
pThis->signal_toggled(path, reinterpret_cast<sal_IntPtr>(pData));
pThis->signal_cell_toggled(path, reinterpret_cast<sal_IntPtr>(pData));
}
void signal_toggled(const gchar *path, int nCol)
void signal_cell_toggled(const gchar *path, int nCol)
{
GtkTreePath *tree_path = gtk_tree_path_new_from_string(path);
......@@ -4912,11 +4912,8 @@ private:
bRet = !bRet;
gtk_tree_store_set(m_pTreeStore, &iter, nCol, bRet, -1);
if (std::find(m_aRadioIndexes.begin(), m_aRadioIndexes.end(), nCol) != m_aRadioIndexes.end())
{
int nRow = gtk_tree_path_get_indices(tree_path)[0];
signal_radio_toggled(std::make_pair(nRow, nCol));
}
int nRow = gtk_tree_path_get_indices(tree_path)[0];
signal_toggled(std::make_pair(nRow, nCol));
gtk_tree_path_free(tree_path);
}
......@@ -4951,7 +4948,7 @@ public:
if (m_nToggleCol == -1)
m_nToggleCol = nIndex;
g_object_set_data(G_OBJECT(pCellRenderer), "g-lo-CellIndex", reinterpret_cast<gpointer>(nIndex));
g_signal_connect(G_OBJECT(pCellRenderer), "toggled", G_CALLBACK(signalToggled), this);
g_signal_connect(G_OBJECT(pCellRenderer), "toggled", G_CALLBACK(signalCellToggled), this);
}
else if (GTK_IS_CELL_RENDERER_PIXBUF(pCellRenderer))
{
......@@ -6342,8 +6339,33 @@ private:
gulong m_nChangedSignalId;
gulong m_nPopupShownSignalId;
gulong m_nKeyPressEventSignalId;
gulong m_nEntryInsertTextSignalId;
gulong m_nEntryActivateSignalId;
static void signalEntryInsertText(GtkEntry* pEntry, const gchar* pNewText, gint nNewTextLength,
gint* position, gpointer widget)
{
GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget);
SolarMutexGuard aGuard;
pThis->signal_entry_insert_text(pEntry, pNewText, nNewTextLength, position);
}
void signal_entry_insert_text(GtkEntry* pEntry, const gchar* pNewText, gint nNewTextLength, gint* position)
{
if (!m_aEntryInsertTextHdl.IsSet())
return;
OUString sText(pNewText, nNewTextLength, RTL_TEXTENCODING_UTF8);
const bool bContinue = m_aEntryInsertTextHdl.Call(sText);
if (bContinue && !sText.isEmpty())
{
OString sFinalText(OUStringToOString(sText, RTL_TEXTENCODING_UTF8));
g_signal_handlers_block_by_func(pEntry, gpointer(signalEntryInsertText), this);
gtk_editable_insert_text(GTK_EDITABLE(pEntry), sFinalText.getStr(), sFinalText.getLength(), position);
g_signal_handlers_unblock_by_func(pEntry, gpointer(signalEntryInsertText), this);
}
g_signal_stop_emission_by_name(pEntry, "insert-text");
}
static void signalChanged(GtkComboBox*, gpointer widget)
{
GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget);
......@@ -6645,11 +6667,13 @@ public:
if (GtkEntry* pEntry = get_entry())
{
setup_completion(pEntry);
m_nEntryInsertTextSignalId = g_signal_connect(pEntry, "insert-text", G_CALLBACK(signalEntryInsertText), this);
m_nEntryActivateSignalId = g_signal_connect(pEntry, "activate", G_CALLBACK(signalEntryActivate), this);
m_nKeyPressEventSignalId = 0;
}
else
{
m_nEntryInsertTextSignalId = 0;
m_nEntryActivateSignalId = 0;
m_nKeyPressEventSignalId = g_signal_connect(m_pWidget, "key-press-event", G_CALLBACK(signalKeyPress), this);
}
......@@ -6902,7 +6926,10 @@ public:
virtual void disable_notify_events() override
{
if (GtkEntry* pEntry = get_entry())
{
g_signal_handler_block(pEntry, m_nEntryInsertTextSignalId);
g_signal_handler_block(pEntry, m_nEntryActivateSignalId);
}
else
g_signal_handler_block(m_pComboBox, m_nKeyPressEventSignalId);
g_signal_handler_block(m_pComboBox, m_nChangedSignalId);
......@@ -6916,7 +6943,10 @@ public:
g_signal_handler_unblock(m_pComboBox, m_nPopupShownSignalId);
g_signal_handler_unblock(m_pComboBox, m_nChangedSignalId);
if (GtkEntry* pEntry = get_entry())
{
g_signal_handler_unblock(pEntry, m_nEntryActivateSignalId);
g_signal_handler_unblock(pEntry, m_nEntryInsertTextSignalId);
}
else
g_signal_handler_unblock(m_pComboBox, m_nKeyPressEventSignalId);
}
......@@ -6959,7 +6989,10 @@ public:
virtual ~GtkInstanceComboBox() override
{
if (GtkEntry* pEntry = get_entry())
{
g_signal_handler_disconnect(pEntry, m_nEntryInsertTextSignalId);
g_signal_handler_disconnect(pEntry, m_nEntryActivateSignalId);
}
else
g_signal_handler_disconnect(m_pComboBox, m_nKeyPressEventSignalId);
g_signal_handler_disconnect(m_pComboBox, m_nChangedSignalId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment