summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-03-13 16:36:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-03-15 21:19:58 +0100
commitecc29989bd58cc54ebeb8b9202399a4e6bd7e4f5 (patch)
tree0921b9cfbdb36bb6a61060ce1c3965cdeb5dbd6b
parent7a342988e010d50e47fa63c500840994c5dc62d8 (diff)
weld sort dialog
rework huge language listbox into a combobox see https://gitlab.gnome.org/GNOME/gtk/issues/94 and the lack of typeahead/search for lists Change-Id: I4a3af695d86bbcb92e5cdd500c4acb7cfaf37f41 Reviewed-on: https://gerrit.libreoffice.org/51340 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svx/langbox.hxx26
-rw-r--r--include/vcl/weld.hxx5
-rw-r--r--svx/source/dialog/langbox.cxx250
-rw-r--r--sw/inc/swabstdlg.hxx2
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx9
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx15
-rw-r--r--sw/source/ui/dialog/swuiexp.cxx1
-rw-r--r--sw/source/ui/misc/srtdlg.cxx387
-rw-r--r--sw/source/uibase/inc/srtdlg.hxx80
-rw-r--r--sw/source/uibase/shells/textsh1.cxx2
-rw-r--r--sw/uiconfig/swriter/ui/sortdialog.ui56
-rw-r--r--vcl/source/app/salvtables.cxx91
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx85
13 files changed, 696 insertions, 313 deletions
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index e26545a6797a..37a9e0061fb2 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -25,6 +25,7 @@
#include <vcl/image.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/combobox.hxx>
+#include <vcl/weld.hxx>
#include <o3tl/typed_flags_set.hxx>
@@ -146,6 +147,31 @@ private:
SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const override;
};
+class SVX_DLLPUBLIC LanguageBox
+{
+private:
+ std::unique_ptr<weld::ComboBoxText> m_xControl;
+ Link<weld::ComboBoxText&, void> m_aChangeHdl;
+ OUString m_aAllString;
+ bool m_bHasLangNone;
+ bool m_bLangNoneIsLangAll;
+ bool m_bWithCheckmark;
+
+ SVX_DLLPRIVATE int ImplTypeToPos(LanguageType eType) const;
+ SVX_DLLPRIVATE void InsertLanguage(const LanguageType nLangType);
+ SVX_DLLPRIVATE void ImplClear();
+ DECL_LINK(ChangeHdl, weld::ComboBoxText&, void);
+public:
+ LanguageBox(weld::ComboBoxText* pControl);
+ void SetLanguageList( SvxLanguageListFlags nLangList,
+ bool bHasLangNone, bool bLangNoneIsLangAll = false,
+ bool bCheckSpellAvail = false );
+ void AddLanguages( const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList );
+ void SelectLanguage( const LanguageType eLangType );
+ LanguageType GetSelectLanguage() const;
+
+ void connect_changed(const Link<weld::ComboBoxText&, void>& rLink) { m_aChangeHdl = rLink; }
+};
class SVX_DLLPUBLIC SvxLanguageComboBox : public ComboBox, public SvxLanguageBoxBase
{
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 6ef22f521a43..98c53f882e2f 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -57,6 +57,8 @@ public:
virtual void set_margin_top(int nMargin) = 0;
virtual void set_margin_bottom(int nMargin) = 0;
+ virtual void set_accessible_name(const OUString& rName) = 0;
+
virtual Container* weld_parent() const = 0;
virtual ~Widget() {}
@@ -170,10 +172,13 @@ public:
virtual void append(const OUString& rId, const OUString& rStr) = 0;
virtual void insert(int pos, const OUString& rId, const OUString& rStr) = 0;
virtual int find_text(const OUString& rStr) const = 0;
+ virtual int find_id(const OUString& rId) const = 0;
virtual int get_count() const = 0;
virtual void make_sorted() = 0;
virtual void clear() = 0;
+ virtual void set_entry_error(bool bError) = 0;
+
void connect_changed(const Link<ComboBoxText&, void>& rLink) { m_aChangeHdl = rLink; }
void set_active(const OUString& rStr) { set_active(find_text(rStr)); }
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index d50c957bdce5..d99b65bd63ec 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -527,6 +527,256 @@ sal_Int32 SvxLanguageBoxBase::GetSavedValueLBB() const
return ImplGetSavedValue();
}
+LanguageType LanguageBox::GetSelectLanguage() const
+{
+ OUString sLang = m_xControl->get_active_id();
+ if (!sLang.isEmpty())
+ return LanguageType(sLang.toInt32());
+ else
+ return LANGUAGE_DONTKNOW;
+}
+
+void LanguageBox::SelectLanguage( const LanguageType eLangType )
+{
+ // If the core uses a LangID of an imported MS document and wants to select
+ // a language that is replaced, we need to select the replacement instead.
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
+
+ sal_Int32 nAt = ImplTypeToPos( nLang );
+
+ if (nAt == -1)
+ {
+ InsertLanguage( nLang ); // on-the-fly-ID
+ nAt = ImplTypeToPos( nLang );
+ }
+
+ if (nAt != -1)
+ m_xControl->set_active(nAt);
+}
+
+void LanguageBox::AddLanguages( const std::vector< LanguageType >& rLanguageTypes,
+ SvxLanguageListFlags nLangList )
+{
+ for ( auto const & nLangType : rLanguageTypes )
+ {
+ if (lcl_isPrerequisite( nLangType, nLangList))
+ {
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType );
+ if (lcl_isScriptTypeRequested( nLang, nLangList))
+ {
+ int nAt = ImplTypeToPos(nLang);
+ if (nAt == -1)
+ InsertLanguage( nLang );
+ }
+ }
+ }
+}
+
+void LanguageBox::ImplClear()
+{
+ m_xControl->clear();
+}
+
+void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
+ bool bHasLangNone, bool bLangNoneIsLangAll, bool bCheckSpellAvail )
+{
+ ImplClear();
+
+ m_bHasLangNone = bHasLangNone;
+ m_bLangNoneIsLangAll = bLangNoneIsLangAll;
+ m_bWithCheckmark = bCheckSpellAvail;
+
+ if ( SvxLanguageListFlags::EMPTY == nLangList )
+ return;
+
+ bool bAddAvailable = (!(nLangList & SvxLanguageListFlags::ONLY_KNOWN) &&
+ ((nLangList & SvxLanguageListFlags::ALL) ||
+ (nLangList & SvxLanguageListFlags::WESTERN) ||
+ (nLangList & SvxLanguageListFlags::CTL) ||
+ (nLangList & SvxLanguageListFlags::CJK)));
+ std::vector< LanguageType > aSpellAvailLang;
+ std::vector< LanguageType > aHyphAvailLang;
+ std::vector< LanguageType > aThesAvailLang;
+ Sequence< sal_Int16 > aSpellUsedLang;
+ std::vector< LanguageType > aHyphUsedLang;
+ std::vector< LanguageType > aThesUsedLang;
+ Reference< XAvailableLocales > xAvail( LinguMgr::GetLngSvcMgr(), UNO_QUERY );
+ if (xAvail.is())
+ {
+ Sequence< css::lang::Locale > aTmp;
+
+ if (bAddAvailable || (SvxLanguageListFlags::SPELL_AVAIL & nLangList))
+ {
+ aTmp = xAvail->getAvailableLocales( SN_SPELLCHECKER );
+ aSpellAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
+ }
+ if (bAddAvailable || (SvxLanguageListFlags::HYPH_AVAIL & nLangList))
+ {
+ aTmp = xAvail->getAvailableLocales( SN_HYPHENATOR );
+ aHyphAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
+ }
+ if (bAddAvailable || (SvxLanguageListFlags::THES_AVAIL & nLangList))
+ {
+ aTmp = xAvail->getAvailableLocales( SN_THESAURUS );
+ aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
+ }
+ }
+ if (SvxLanguageListFlags::SPELL_USED & nLangList)
+ {
+ Reference< XSpellChecker1 > xTmp1( LinguMgr::GetSpellChecker(), UNO_QUERY );
+ if (xTmp1.is())
+ aSpellUsedLang = xTmp1->getLanguages();
+ }
+ if (SvxLanguageListFlags::HYPH_USED & nLangList)
+ {
+ Reference< XHyphenator > xTmp( LinguMgr::GetHyphenator() );
+ if (xTmp.is()) {
+ Sequence < css::lang::Locale > aLocaleSequence( xTmp->getLocales() );
+ aHyphUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
+ }
+ }
+ if (SvxLanguageListFlags::THES_USED & nLangList)
+ {
+ Reference< XThesaurus > xTmp( LinguMgr::GetThesaurus() );
+ if (xTmp.is()) {
+ Sequence < css::lang::Locale > aLocaleSequence( xTmp->getLocales() );
+ aThesUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
+ }
+ }
+
+ std::vector<LanguageType> aKnown;
+ sal_uInt32 nCount;
+ if ( nLangList & SvxLanguageListFlags::ONLY_KNOWN )
+ {
+ aKnown = LocaleDataWrapper::getInstalledLanguageTypes();
+ nCount = aKnown.size();
+ }
+ else
+ {
+ nCount = SvtLanguageTable::GetLanguageEntryCount();
+ }
+ for ( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ LanguageType nLangType;
+ if ( nLangList & SvxLanguageListFlags::ONLY_KNOWN )
+ nLangType = aKnown[i];
+ else
+ nLangType = SvtLanguageTable::GetLanguageTypeAtIndex( i );
+ if ( lcl_isPrerequisite( nLangType, nLangList) &&
+ (lcl_isScriptTypeRequested( nLangType, nLangList) ||
+ (bool(nLangList & SvxLanguageListFlags::FBD_CHARS) &&
+ MsLangId::hasForbiddenCharacters(nLangType)) ||
+ (bool(nLangList & SvxLanguageListFlags::SPELL_AVAIL) &&
+ lcl_SeqHasLang(aSpellAvailLang, nLangType)) ||
+ (bool(nLangList & SvxLanguageListFlags::HYPH_AVAIL) &&
+ lcl_SeqHasLang(aHyphAvailLang, nLangType)) ||
+ (bool(nLangList & SvxLanguageListFlags::THES_AVAIL) &&
+ lcl_SeqHasLang(aThesAvailLang, nLangType)) ||
+ (bool(nLangList & SvxLanguageListFlags::SPELL_USED) &&
+ lcl_SeqHasLang(aSpellUsedLang, static_cast<sal_uInt16>(nLangType))) ||
+ (bool(nLangList & SvxLanguageListFlags::HYPH_USED) &&
+ lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
+ (bool(nLangList & SvxLanguageListFlags::THES_USED) &&
+ lcl_SeqHasLang(aThesUsedLang, nLangType))) )
+ InsertLanguage( nLangType );
+ }
+
+ if (bAddAvailable)
+ {
+ // Spell checkers, hyphenators and thesauri may add language tags
+ // unknown so far.
+ AddLanguages( aSpellAvailLang, nLangList);
+ AddLanguages( aHyphAvailLang, nLangList);
+ AddLanguages( aThesAvailLang, nLangList);
+ }
+
+ if (bHasLangNone)
+ InsertLanguage( LANGUAGE_NONE );
+}
+
+int LanguageBox::ImplTypeToPos(LanguageType eType) const
+{
+ return m_xControl->find_id(OUString::number(static_cast<sal_uInt16>(eType)));
+}
+
+void LanguageBox::InsertLanguage(const LanguageType nLangType)
+{
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage(nLangType);
+ // For obsolete and to be replaced languages check whether an entry of the
+ // replacement already exists and if so don't add an entry with identical
+ // string as would be returned by SvtLanguageTable::GetString().
+ if (nLang != nLangType)
+ {
+ int nAt = ImplTypeToPos( nLang );
+ if (nAt != -1)
+ return;
+ }
+
+ OUString aStrEntry = SvtLanguageTable::GetLanguageString( nLang );
+ if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
+ aStrEntry = m_aAllString;
+
+ LanguageType nRealLang = nLang;
+ if (nRealLang == LANGUAGE_SYSTEM)
+ {
+ nRealLang = MsLangId::resolveSystemLanguageByScriptType(nRealLang, css::i18n::ScriptType::WEAK);
+ aStrEntry += " - ";
+ aStrEntry += SvtLanguageTable::GetLanguageString( nRealLang );
+ }
+ else if (nRealLang == LANGUAGE_USER_SYSTEM_CONFIG)
+ {
+ nRealLang = MsLangId::getSystemLanguage();
+ aStrEntry += " - ";
+ aStrEntry += SvtLanguageTable::GetLanguageString( nRealLang );
+ }
+
+ // aStrEntry = ApplyLreOrRleEmbedding( aStrEntry );
+
+ m_xControl->append(OUString::number(static_cast<sal_uInt16>(nLangType)), aStrEntry);
+}
+
+IMPL_LINK(LanguageBox, ChangeHdl, weld::ComboBoxText&, rControl, void)
+{
+ int nModelPos = rControl.find_text(rControl.get_active_text());
+ if (nModelPos == -1)
+ {
+ rControl.set_entry_error(true);
+ }
+ else
+ {
+ rControl.set_active(nModelPos);
+ rControl.set_entry_error(false);
+ m_aChangeHdl.Call(rControl);
+ }
+}
+
+LanguageBox::LanguageBox(weld::ComboBoxText* pControl)
+ : m_xControl(pControl)
+ , m_aAllString(SvxResId(RID_SVXSTR_LANGUAGE_ALL))
+ , m_bHasLangNone(false)
+ , m_bLangNoneIsLangAll(false)
+ , m_bWithCheckmark(false)
+{
+ m_xControl->make_sorted();
+ m_xControl->connect_changed(LINK(this, LanguageBox, ChangeHdl));
+
+ sal_uInt32 nCount = SvtLanguageTable::GetLanguageEntryCount();
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ LanguageType nLangType = SvtLanguageTable::GetLanguageTypeAtIndex(i);
+
+ bool bInsert = true;
+ if ((LANGUAGE_DONTKNOW == nLangType) || (LANGUAGE_SYSTEM == nLangType))
+ {
+ bInsert = false;
+ }
+
+ if (!bInsert)
+ continue;
+
+ InsertLanguage(nLangType);
+ }
+}
SvxLanguageBox::SvxLanguageBox( vcl::Window* pParent, WinBits nBits )
: ListBox( pParent, nBits )
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index dcdc6d408c8d..0c9a77babacd 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -427,7 +427,7 @@ public:
virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(const OUString &rShortName) = 0;
- virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(vcl::Window * pParent, SwWrtShell &rSh) = 0;
+ virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window * pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(vcl::Window *pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(vcl::Window *pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) = 0;
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index f499678ab988..4ddbae92c8b3 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -100,6 +100,10 @@ short AbstractSwBreakDlg_Impl::Execute()
{
return m_xDlg->execute();
}
+short AbstractSwSortDlg_Impl::Execute()
+{
+ return m_xDlg->execute();
+}
IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl);
short AbstractSwConvertTableDlg_Impl::Execute()
{
@@ -795,10 +799,9 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableHeightDialo
return VclPtr<VclAbstractDialog_Impl>::Create( pDlg );
}
-VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwSortingDialog(vcl::Window *pParent, SwWrtShell &rSh)
+VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh)
{
- VclPtr<Dialog> pDlg = VclPtr<SwSortDlg>::Create( pParent, rSh);
- return VclPtr<VclAbstractDialog_Impl>::Create( pDlg );
+ return VclPtr<AbstractSwSortDlg_Impl>::Create(new SwSortDlg(pParent, rSh));
}
VclPtr<AbstractSplitTableDialog> SwAbstractDialogFactory_Impl::CreateSplitTableDialog(weld::Window *pParent, SwWrtShell &rSh)
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index ca03c363c1a4..b24f08177d0d 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -25,6 +25,7 @@ class SwInsertAbstractDlg;
class SwAsciiFilterDlg;
class Dialog;
class SwBreakDlg;
+class SwSortDlg;
class SfxTabDialog;
class SwConvertTableDlg;
class SwInsertDBColAutoPilot;
@@ -101,6 +102,18 @@ class VclAbstractDialog_Impl : public VclAbstractDialog
DECL_ABSTDLG_BASE(VclAbstractDialog_Impl,Dialog)
};
+class AbstractSwSortDlg_Impl : public VclAbstractDialog
+{
+protected:
+ std::unique_ptr<SwSortDlg> m_xDlg;
+public:
+ explicit AbstractSwSortDlg_Impl(SwSortDlg* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
+};
+
class AbstractSwBreakDlg_Impl : public AbstractSwBreakDlg
{
protected:
@@ -449,7 +462,7 @@ public:
virtual VclPtr<VclAbstractDialog> CreateSwAutoMarkDialog(vcl::Window *pParent, SwWrtShell &rSh) override;
virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(const OUString &rShortName) override;
- virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(vcl::Window * pParent, SwWrtShell &rSh) override;
+ virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window * pParent, SwWrtShell &rSh) override;
virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(vcl::Window *pParent, SwWrtShell &rSh) override;
virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(vcl::Window *pParent, SwWrtShell &rSh) override;
virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) override;
diff --git a/sw/source/ui/dialog/swuiexp.cxx b/sw/source/ui/dialog/swuiexp.cxx
index 4e73ff5fe4c2..b6f412435c33 100644
--- a/sw/source/ui/dialog/swuiexp.cxx
+++ b/sw/source/ui/dialog/swuiexp.cxx
@@ -23,6 +23,7 @@
#include <ascfldlg.hxx>
#include <break.hxx>
#include <convert.hxx>
+#include <srtdlg.hxx>
#include <dbinsdlg.hxx>
#include <DropDownFieldDialog.hxx>
#include <fldtdlg.hxx>
diff --git a/sw/source/ui/misc/srtdlg.cxx b/sw/source/ui/misc/srtdlg.cxx
index abd043a8006e..5aad03cd65ba 100644
--- a/sw/source/ui/misc/srtdlg.cxx
+++ b/sw/source/ui/misc/srtdlg.cxx
@@ -72,16 +72,6 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-static void lcl_ClearLstBoxAndDelUserData( ListBox& rLstBox )
-{
- const sal_Int32 nEnd = rLstBox.GetEntryCount();
- for( sal_Int32 n = 0; n < nEnd; ++n )
- {
- delete static_cast<OUString *>(rLstBox.GetEntryData( n ));
- }
- rLstBox.Clear();
-}
-
// determine lines and columns for table selection
static bool lcl_GetSelTable( SwWrtShell const &rSh, sal_uInt16& rX, sal_uInt16& rY )
{
@@ -108,216 +98,176 @@ static bool lcl_GetSelTable( SwWrtShell const &rSh, sal_uInt16& rX, sal_uInt16&
}
// init list
-SwSortDlg::SwSortDlg(vcl::Window* pParent, SwWrtShell &rShell)
- : SvxStandardDialog(pParent, "SortDialog", "modules/swriter/ui/sortdialog.ui")
+SwSortDlg::SwSortDlg(weld::Window* pParent, SwWrtShell &rShell)
+ : weld::GenericDialogController(pParent, "modules/swriter/ui/sortdialog.ui", "SortDialog")
+ , m_pParent(pParent)
+ , m_xColLbl(m_xBuilder->weld_label("column"))
+ , m_xTypLbl(m_xBuilder->weld_label("keytype"))
+ , m_xKeyCB1(m_xBuilder->weld_check_button("key1"))
+ , m_xColEdt1(m_xBuilder->weld_spin_button("colsb1"))
+ , m_xTypDLB1(m_xBuilder->weld_combo_box_text("typelb1"))
+ , m_xSortUp1RB(m_xBuilder->weld_radio_button("up1"))
+ , m_xSortDn1RB(m_xBuilder->weld_radio_button("down1"))
+ , m_xKeyCB2(m_xBuilder->weld_check_button("key2"))
+ , m_xColEdt2(m_xBuilder->weld_spin_button("colsb2"))
+ , m_xTypDLB2(m_xBuilder->weld_combo_box_text("typelb2"))
+ , m_xSortUp2RB(m_xBuilder->weld_radio_button("up2"))
+ , m_xSortDn2RB(m_xBuilder->weld_radio_button("down2"))
+ , m_xKeyCB3(m_xBuilder->weld_check_button("key3"))
+ , m_xColEdt3(m_xBuilder->weld_spin_button("colsb3"))
+ , m_xTypDLB3(m_xBuilder->weld_combo_box_text("typelb3"))
+ , m_xSortUp3RB(m_xBuilder->weld_radio_button("up3"))
+ , m_xSortDn3RB(m_xBuilder->weld_radio_button("down3"))
+ , m_xColumnRB(m_xBuilder->weld_radio_button("columns"))
+ , m_xRowRB(m_xBuilder->weld_radio_button("rows"))
+ , m_xDelimTabRB(m_xBuilder->weld_radio_button("tabs"))
+ , m_xDelimFreeRB(m_xBuilder->weld_radio_button("character"))
+ , m_xDelimEdt(m_xBuilder->weld_entry("separator"))
+ , m_xDelimPB(m_xBuilder->weld_button("delimpb"))
+ , m_xLangLB(new LanguageBox(m_xBuilder->weld_combo_box_text("langlb")))
+ , m_xCaseCB(m_xBuilder->weld_check_button("matchcase"))
, aColText(SwResId(STR_COL))
, aRowText(SwResId(STR_ROW))
, aNumericText(SwResId(STR_NUMERIC))
, rSh(rShell)
- , pColRes(nullptr)
, nX(99)
, nY(99)
{
- get(m_pColLbl, "column");
- get(m_pTypLbl, "keytype");
-
- get(m_pKeyCB1, "key1");
- get(m_pColEdt1, "colsb1");
- get(m_pTypDLB1, "typelb1");
- get(m_pSortUp1RB, "up1");
- get(m_pSortDn1RB, "down1");
-
- get(m_pKeyCB2, "key2");
- get(m_pColEdt2, "colsb2");
- get(m_pTypDLB2, "typelb2");
- get(m_pSortUp2RB, "up2");
- get(m_pSortDn2RB, "down2");
-
- get(m_pKeyCB3, "key3");
- get(m_pColEdt3, "colsb3");
- get(m_pTypDLB3, "typelb3");
- get(m_pSortUp3RB, "up3");
- get(m_pSortDn3RB, "down3");
-
- get(m_pColumnRB, "columns");
- get(m_pRowRB, "rows");
-
- get(m_pDelimTabRB, "tabs");
- get(m_pDelimFreeRB, "character");
- get(m_pDelimEdt, "separator");
- get(m_pDelimPB, "delimpb");
-
- get(m_pLangLB, "langlb");
- get(m_pCaseCB, "matchcase");
-
- m_pDelimEdt->SetMaxTextLen( 1 );
if(rSh.GetSelectionType() &
(SelectionType::Table|SelectionType::TableCell) )
{
- m_pColumnRB->Check(bCol);
- m_pColLbl->SetText(bCol ? aRowText : aColText);
- m_pRowRB->Check(!bCol);
- m_pDelimTabRB->Enable(false);
- m_pDelimFreeRB->Enable(false);
- m_pDelimEdt->Enable(false);
+ m_xColumnRB->set_active(bCol);
+ m_xColLbl->set_label(bCol ? aRowText : aColText);
+ m_xRowRB->set_active(!bCol);
+ m_xDelimTabRB->set_sensitive(false);
+ m_xDelimFreeRB->set_sensitive(false);
+ m_xDelimEdt->set_sensitive(false);
}
else
{
- m_pColumnRB->Enable(false);
- m_pRowRB->Check();
- m_pColLbl->SetText(aColText);
+ m_xColumnRB->set_sensitive(false);
+ m_xRowRB->set_active(true);
+ m_xColLbl->set_label(aColText);
}
- // Set accessible names here because text of m_pColLbl may be changed
+ // Set accessible names here because text of m_xColLbl may be changed
// by the if-else block above
- m_pColEdt1->SetAccessibleName(m_pColLbl->GetText());
- m_pColEdt2->SetAccessibleName(m_pColLbl->GetText());
- m_pColEdt3->SetAccessibleName(m_pColLbl->GetText());
+ m_xColEdt1->set_accessible_name(m_xColLbl->get_label());
+ m_xColEdt2->set_accessible_name(m_xColLbl->get_label());
+ m_xColEdt3->set_accessible_name(m_xColLbl->get_label());
// initialise
- Link<Button*,void> aLk = LINK(this,SwSortDlg, CheckHdl);
- m_pKeyCB1->SetClickHdl( aLk );
- m_pKeyCB2->SetClickHdl( aLk );
- m_pKeyCB3->SetClickHdl( aLk );
- m_pColumnRB->SetClickHdl( aLk );
- m_pRowRB->SetClickHdl( aLk );
+ Link<weld::ToggleButton&,void> aLk = LINK(this, SwSortDlg, CheckHdl);
+ m_xKeyCB1->connect_toggled( aLk );
+ m_xKeyCB2->connect_toggled( aLk );
+ m_xKeyCB3->connect_toggled( aLk );
+ m_xColumnRB->connect_toggled( aLk );
+ m_xRowRB->connect_toggled( aLk );
- aLk = LINK(this,SwSortDlg, DelimHdl);
- m_pDelimFreeRB->SetClickHdl(aLk);
- m_pDelimTabRB->SetClickHdl(aLk);
+ aLk = LINK(this, SwSortDlg, DelimHdl);
+ m_xDelimFreeRB->connect_toggled(aLk);
+ m_xDelimTabRB->connect_toggled(aLk);
- m_pDelimPB->SetClickHdl( LINK( this, SwSortDlg, DelimCharHdl ));
+ m_xDelimPB->connect_clicked( LINK( this, SwSortDlg, DelimCharHdl ));
- m_pKeyCB1->Check(bCheck1);
- m_pKeyCB2->Check(bCheck2);
- m_pKeyCB3->Check(bCheck3);
+ m_xKeyCB1->set_active(bCheck1);
+ m_xKeyCB2->set_active(bCheck2);
+ m_xKeyCB3->set_active(bCheck3);
- m_pColEdt1->SetValue(nCol1);
- m_pColEdt2->SetValue(nCol2);
- m_pColEdt3->SetValue(nCol3);
+ m_xColEdt1->set_value(nCol1);
+ m_xColEdt2->set_value(nCol2);
+ m_xColEdt3->set_value(nCol3);
// first initialise the language, then select the
if( LANGUAGE_NONE == nLang || LANGUAGE_DONTKNOW == nLang )
nLang = GetAppLanguage();
- m_pLangLB->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, true );
- m_pLangLB->SelectLanguage( nLang );
+ m_xLangLB->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, true );
+ m_xLangLB->SelectLanguage( nLang );
LanguageHdl( nullptr );
- m_pLangLB->SetSelectHdl( LINK( this, SwSortDlg, LanguageListBoxHdl ));
+ m_xLangLB->connect_changed( LINK( this, SwSortDlg, LanguageListBoxHdl ));
- m_pSortUp1RB->Check(bAsc1);
- m_pSortDn1RB->Check(!bAsc1);
- m_pSortUp2RB->Check(bAsc2);
- m_pSortDn2RB->Check(!bAsc2);
- m_pSortUp3RB->Check(bAsc3);
- m_pSortDn3RB->Check(!bAsc3);
+ m_xSortUp1RB->set_active(bAsc1);
+ m_xSortDn1RB->set_active(!bAsc1);
+ m_xSortUp2RB->set_active(bAsc2);
+ m_xSortDn2RB->set_active(!bAsc2);
+ m_xSortUp3RB->set_active(bAsc3);
+ m_xSortDn3RB->set_active(!bAsc3);
- m_pCaseCB->Check( bCsSens );
+ m_xCaseCB->set_active( bCsSens );
- m_pDelimTabRB->Check(cDeli == '\t');
- if(!m_pDelimTabRB->IsChecked())
+ m_xDelimTabRB->set_active(cDeli == '\t');
+ if(!m_xDelimTabRB->get_active())
{
- m_pDelimEdt->SetText(OUString(cDeli));
- m_pDelimFreeRB->Check();
- DelimHdl(m_pDelimFreeRB);
+ m_xDelimEdt->set_text(OUString(cDeli));
+ m_xDelimFreeRB->set_active(true);
+ DelimHdl(*m_xDelimFreeRB);
}
else
- DelimHdl(m_pDelimTabRB);
+ DelimHdl(*m_xDelimTabRB);
if( ::lcl_GetSelTable( rSh, nX, nY) )
{
- sal_uInt16 nMax = m_pRowRB->IsChecked()? nY : nX;
- m_pColEdt1->SetMax(nMax);
- m_pColEdt2->SetMax(nMax);
- m_pColEdt3->SetMax(nMax);
+ sal_uInt16 nMax = m_xRowRB->get_active()? nY : nX;
+ m_xColEdt1->set_max(nMax);
+ m_xColEdt2->set_max(nMax);
+ m_xColEdt3->set_max(nMax);
}
}
-SwSortDlg::~SwSortDlg()
-{
- disposeOnce();
-}
-
-void SwSortDlg::dispose()
-{
- ::lcl_ClearLstBoxAndDelUserData(*m_pTypDLB1);
- ::lcl_ClearLstBoxAndDelUserData(*m_pTypDLB2);
- ::lcl_ClearLstBoxAndDelUserData(*m_pTypDLB3);
- delete pColRes;
- m_pColLbl.clear();
- m_pTypLbl.clear();
- m_pKeyCB1.clear();
- m_pColEdt1.clear();
- m_pTypDLB1.clear();
- m_pSortUp1RB.clear();
- m_pSortDn1RB.clear();
- m_pKeyCB2.clear();
- m_pColEdt2.clear();
- m_pTypDLB2.clear();
- m_pSortUp2RB.clear();
- m_pSortDn2RB.clear();
- m_pKeyCB3.clear();
- m_pColEdt3.clear();
- m_pTypDLB3.clear();
- m_pSortUp3RB.clear();
- m_pSortDn3RB.clear();
- m_pColumnRB.clear();
- m_pRowRB.clear();
- m_pDelimTabRB.clear();
- m_pDelimFreeRB.clear();
- m_pDelimEdt.clear();
- m_pDelimPB.clear();
- m_pLangLB.clear();
- m_pCaseCB.clear();
- SvxStandardDialog::dispose();
-}
-
sal_Unicode SwSortDlg::GetDelimChar() const
{
sal_Unicode cRet = '\t';
- if( !m_pDelimTabRB->IsChecked() )
+ if( !m_xDelimTabRB->get_active() )
{
- OUString aTmp( m_pDelimEdt->GetText() );
+ OUString aTmp(m_xDelimEdt->get_text());
if( !aTmp.isEmpty() )
cRet = aTmp[0];
}
return cRet;
}
+short SwSortDlg::execute()
+{
+ short nRet = run();
+ if (nRet == RET_OK)
+ Apply();
+ return nRet;
+}
+
// pass on to the Core
void SwSortDlg::Apply()
{
// save all settings
- bCheck1 = m_pKeyCB1->IsChecked();
- bCheck2 = m_pKeyCB2->IsChecked();
- bCheck3 = m_pKeyCB3->IsChecked();
-
- nCol1 = static_cast<sal_uInt16>(m_pColEdt1->GetValue());
- nCol2 = static_cast<sal_uInt16>(m_pColEdt2->GetValue());
- nCol3 = static_cast<sal_uInt16>(m_pColEdt3->GetValue());
-
- nType1 = m_pTypDLB1->GetSelectedEntryPos();
- nType2 = m_pTypDLB2->GetSelectedEntryPos();
- nType3 = m_pTypDLB3->GetSelectedEntryPos();
-
- bAsc1 = m_pSortUp1RB->IsChecked();
- bAsc2 = m_pSortUp2RB->IsChecked();
- bAsc3 = m_pSortUp3RB->IsChecked();
- bCol = m_pColumnRB->IsChecked();
- nLang = m_pLangLB->GetSelectLanguage();
+ bCheck1 = m_xKeyCB1->get_active();
+ bCheck2 = m_xKeyCB2->get_active();
+ bCheck3 = m_xKeyCB3->get_active();
+
+ nCol1 = m_xColEdt1->get_value();
+ nCol2 = m_xColEdt2->get_value();
+ nCol3 = m_xColEdt3->get_value();
+
+ nType1 = m_xTypDLB1->get_active();
+ nType2 = m_xTypDLB2->get_active();
+ nType3 = m_xTypDLB3->get_active();
+
+ bAsc1 = m_xSortUp1RB->get_active();
+ bAsc2 = m_xSortUp2RB->get_active();
+ bAsc3 = m_xSortUp3RB->get_active();
+ bCol = m_xColumnRB->get_active();
+ nLang = m_xLangLB->GetSelectLanguage();
cDeli = GetDelimChar();
- bCsSens = m_pCaseCB->IsChecked();
+ bCsSens = m_xCaseCB->get_active();
- void* pUserData;
SwSortOptions aOptions;
if( bCheck1 )
{
- OUString sEntry( m_pTypDLB1->GetSelectedEntry() );
+ OUString sEntry( m_xTypDLB1->get_active_text() );
if( sEntry == aNumericText )
sEntry.clear();
- else if( nullptr != (pUserData = m_pTypDLB1->GetSelectedEntryData()) )
- sEntry = *static_cast<OUString*>(pUserData);
+ else if (!m_xTypDLB1->get_active_id().isEmpty())
+ sEntry = m_xTypDLB1->get_active_id();
aOptions.aKeys.push_back(
o3tl::make_unique<SwSortKey>( nCol1, sEntry,
@@ -326,11 +276,11 @@ void SwSortDlg::Apply()
if( bCheck2 )
{
- OUString sEntry( m_pTypDLB2->GetSelectedEntry() );
+ OUString sEntry( m_xTypDLB2->get_active_text() );
if( sEntry == aNumericText )
sEntry.clear();
- else if( nullptr != (pUserData = m_pTypDLB2->GetSelectedEntryData()) )
- sEntry = *static_cast<OUString*>(pUserData);
+ else if (!m_xTypDLB2->get_active_id().isEmpty())
+ sEntry = m_xTypDLB2->get_active_id();
aOptions.aKeys.push_back(
o3tl::make_unique<SwSortKey>( nCol2, sEntry,
@@ -339,11 +289,11 @@ void SwSortDlg::Apply()
if( bCheck3 )
{
- OUString sEntry( m_pTypDLB3->GetSelectedEntry() );
+ OUString sEntry( m_xTypDLB3->get_active_text() );
if( sEntry == aNumericText )
sEntry.clear();
- else if( nullptr != (pUserData = m_pTypDLB3->GetSelectedEntryData()) )
- sEntry = *static_cast<OUString*>(pUserData);
+ else if (!m_xTypDLB3->get_active_id().isEmpty())
+ sEntry = m_xTypDLB3->get_active_id();
aOptions.aKeys.push_back(
o3tl::make_unique<SwSortKey>( nCol3, sEntry,
@@ -366,95 +316,97 @@ void SwSortDlg::Apply()
rSh.EndAllAction();
}
- if( !bRet )
+ if (!bRet)
{
- vcl::Window* pWin = GetParent();
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr,
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_pParent,
VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_SRTERR)));
xInfoBox->run();
}
}
-IMPL_LINK( SwSortDlg, DelimHdl, Button*, pButton, void )
+IMPL_LINK( SwSortDlg, DelimHdl, weld::ToggleButton&, rButton, void )
{
- bool bEnable = pButton == m_pDelimFreeRB && m_pDelimFreeRB->IsEnabled();
- m_pDelimEdt->Enable( bEnable );
- m_pDelimPB->Enable( bEnable );
+ bool bEnable = &rButton == m_xDelimFreeRB.get() && m_xDelimFreeRB->get_sensitive();
+ m_xDelimEdt->set_sensitive( bEnable );
+ m_xDelimPB->set_sensitive( bEnable );
}
-IMPL_LINK_NOARG(SwSortDlg, DelimCharHdl, Button*, void)
+IMPL_LINK_NOARG(SwSortDlg, DelimCharHdl, weld::Button&, void)
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
if(pFact)
{
SfxAllItemSet aSet( rSh.GetAttrPool() );
aSet.Put( SfxInt32Item( SID_ATTR_CHAR, GetDelimChar() ) );
- ScopedVclPtr<SfxAbstractDialog> pMap(pFact->CreateCharMapDialog( m_pDelimPB, aSet, false ));
+//TODO ScopedVclPtr<SfxAbstractDialog> pMap(pFact->CreateCharMapDialog( m_xDelimPB, aSet, false ));
+ ScopedVclPtr<SfxAbstractDialog> pMap(pFact->CreateCharMapDialog(nullptr, aSet, false));
if( RET_OK == pMap->Execute() )
{
const SfxInt32Item* pItem = SfxItemSet::GetItem<SfxInt32Item>(pMap->GetOutputItemSet(), SID_ATTR_CHAR, false);
if ( pItem )
- m_pDelimEdt->SetText( OUString(sal_Unicode(pItem->GetValue())) );
+ m_xDelimEdt->set_text(OUString(sal_Unicode(pItem->GetValue())));
}
}
}
-IMPL_LINK( SwSortDlg, CheckHdl, Button*, pControl, void )
+IMPL_LINK( SwSortDlg, CheckHdl, weld::ToggleButton&, rControl, void )
{
- if( pControl == m_pRowRB.get())
+ if (&rControl == m_xRowRB.get())
+ {
+ m_xColLbl->set_label(aColText);
+ m_xColEdt1->set_max(nY);
+ m_xColEdt2->set_max(nY);
+ m_xColEdt3->set_max(nY);
+
+ m_xColEdt1->set_accessible_name(aColText);
+ m_xColEdt2->set_accessible_name(aColText);
+ m_xColEdt3->set_accessible_name(aColText);
+ }
+ else if (&rControl == m_xColumnRB.get())
{
- m_pColLbl->SetText(aColText);
- m_pColEdt1->SetMax(nY);
- m_pColEdt2->SetMax(nY);
- m_pColEdt3->SetMax(nY);
-
- m_pColEdt1->SetAccessibleName(aColText);
- m_pColEdt2->SetAccessibleName(aColText);
- m_pColEdt3->SetAccessibleName(aColText);
+ m_xColLbl->set_label(aRowText);
+ m_xColEdt1->set_max(nX);
+ m_xColEdt2->set_max(nX);
+ m_xColEdt3->set_max(nX);
+
+ m_xColEdt1->set_accessible_name(aRowText);
+ m_xColEdt2->set_accessible_name(aRowText);
+ m_xColEdt3->set_accessible_name(aRowText);
}
- else if( pControl == m_pColumnRB.get())
+ else if(!m_xKeyCB1->get_active() &&
+ !m_xKeyCB2->get_active() &&
+ !m_xKeyCB3->get_active())
{
- m_pColLbl->SetText(aRowText);
- m_pColEdt1->SetMax(nX);
- m_pColEdt2->SetMax(nX);
- m_pColEdt3->SetMax(nX);
-
- m_pColEdt1->SetAccessibleName(aRowText);
- m_pColEdt2->SetAccessibleName(aRowText);
- m_pColEdt3->SetAccessibleName(aRowText);
+ rControl.set_active(true);
}
- else if(!m_pKeyCB1->IsChecked() &&
- !m_pKeyCB2->IsChecked() &&
- !m_pKeyCB3->IsChecked())
- static_cast<CheckBox *>(pControl)->Check();
}
-IMPL_LINK( SwSortDlg, LanguageListBoxHdl, ListBox&, rLBox, void )
+IMPL_LINK( SwSortDlg, LanguageListBoxHdl, weld::ComboBoxText&, rLBox, void )
{
LanguageHdl(&rLBox);
}
-void SwSortDlg::LanguageHdl(ListBox const * pLBox)
+void SwSortDlg::LanguageHdl(weld::ComboBoxText const* pLBox)
{
Sequence < OUString > aSeq( GetAppCollator().listCollatorAlgorithms(
- LanguageTag( m_pLangLB->GetSelectLanguage()).getLocale() ));
+ LanguageTag( m_xLangLB->GetSelectLanguage()).getLocale() ));
- if( !pColRes )
- pColRes = new CollatorResource();
+ if (!m_xColRes)
+ m_xColRes.reset(new CollatorResource);
const int nLstBoxCnt = 3;
- ListBox* aLstArr[ nLstBoxCnt ] = { m_pTypDLB1, m_pTypDLB2, m_pTypDLB3 };
+ weld::ComboBoxText* aLstArr[ nLstBoxCnt ] = { m_xTypDLB1.get(), m_xTypDLB2.get(), m_xTypDLB3.get() };
sal_uInt16* const aTypeArr[ nLstBoxCnt ] = { &nType1, &nType2, &nType3 };
OUString aOldStrArr[ nLstBoxCnt ];
for( int n = 0; n < nLstBoxCnt; ++n )
{
- ListBox* pL = aLstArr[ n ];
- void* pUserData = pL->GetSelectedEntryData();
- if (pUserData)
- aOldStrArr[ n ] = *static_cast<OUString*>(pUserData);
- ::lcl_ClearLstBoxAndDelUserData( *pL );
+ weld::ComboBoxText* pL = aLstArr[ n ];
+ OUString sUserData = pL->get_active_id();
+ if (!sUserData.isEmpty())
+ aOldStrArr[ n ] = sUserData;
+ pL->clear();
}
OUString sAlg, sUINm;
@@ -462,27 +414,26 @@ void SwSortDlg::LanguageHdl(ListBox const * pLBox)
for( sal_Int32 nCnt = 0; nCnt <= nEnd; ++nCnt )
{
if( nCnt < nEnd )
- sUINm = pColRes->GetTranslation( sAlg = aSeq[ nCnt ] );
+ sUINm = m_xColRes->GetTranslation( sAlg = aSeq[ nCnt ] );
else
sUINm = sAlg = aNumericText;
for( int n = 0; n < nLstBoxCnt; ++n )
{
- ListBox* pL = aLstArr[ n ];
- const sal_Int32 nInsPos = pL->InsertEntry( sUINm );
- pL->SetEntryData( nInsPos, new OUString( sAlg ));
- if( pLBox && sAlg == aOldStrArr[ n ] )
- pL->SelectEntryPos( nInsPos );
+ weld::ComboBoxText* pL = aLstArr[ n ];
+ pL->append(sAlg, sUINm);
+ if (pLBox && sAlg == aOldStrArr[n])
+ pL->set_active_id(sAlg);
}
}
for( int n = 0; n < nLstBoxCnt; ++n )
{
- ListBox* pL = aLstArr[ n ];
+ weld::ComboBoxText* pL = aLstArr[ n ];
if( !pLBox )
- pL->SelectEntryPos( *aTypeArr[n] );
- else if( LISTBOX_ENTRY_NOTFOUND == pL->GetSelectedEntryPos() )
- pL->SelectEntryPos( 0 );
+ pL->set_active(*aTypeArr[n]);
+ else if (pL->get_active() == -1)
+ pL->set_active(0);
}
}
diff --git a/sw/source/uibase/inc/srtdlg.hxx b/sw/source/uibase/inc/srtdlg.hxx
index d86cf35e4376..6fd8932da096 100644
--- a/sw/source/uibase/inc/srtdlg.hxx
+++ b/sw/source/uibase/inc/srtdlg.hxx
@@ -19,74 +19,70 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SRTDLG_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_SRTDLG_HXX
-#include <vcl/fixed.hxx>
-#include <vcl/button.hxx>
-#include <vcl/field.hxx>
-#include <vcl/lstbox.hxx>
-#include <svx/stddlg.hxx>
+#include <svtools/collatorres.hxx>
#include <svx/langbox.hxx>
+#include <vcl/weld.hxx>
class SwWrtShell;
-class CollatorResource;
-class SwSortDlg : public SvxStandardDialog
+class SwSortDlg : public weld::GenericDialogController
{
- VclPtr<FixedText> m_pColLbl;
- VclPtr<FixedText> m_pTypLbl;
+ weld::Window* m_pParent;
+ std::unique_ptr<weld::Label> m_xColLbl;
+ std::unique_ptr<weld::Label> m_xTypLbl;
- VclPtr<CheckBox> m_pKeyCB1;
- VclPtr<NumericField> m_pColEdt1;
- VclPtr<ListBox> m_pTypDLB1;
- VclPtr<RadioButton> m_pSortUp1RB;
- VclPtr<RadioButton> m_pSortDn1RB;
+ std::unique_ptr<weld::CheckButton> m_xKeyCB1;
+ std::unique_ptr<weld::SpinButton> m_xColEdt1;
+ std::unique_ptr<weld::ComboBoxText> m_xTypDLB1;
+ std::unique_ptr<weld::RadioButton> m_xSortUp1RB;
+ std::unique_ptr<weld::RadioButton> m_xSortDn1RB;
- VclPtr<CheckBox> m_pKeyCB2;
- VclPtr<NumericField> m_pColEdt2;
- VclPtr<ListBox> m_pTypDLB2;
- VclPtr<RadioButton> m_pSortUp2RB;
- VclPtr<RadioButton> m_pSortDn2RB;
+ std::unique_ptr<weld::CheckButton> m_xKeyCB2;
+ std::unique_ptr<weld::SpinButton> m_xColEdt2;
+ std::unique_ptr<weld::ComboBoxText> m_xTypDLB2;
+ std::unique_ptr<weld::RadioButton> m_xSortUp2RB;
+ std::unique_ptr<weld::RadioButton> m_xSortDn2RB;
- VclPtr<CheckBox> m_pKeyCB3;
- VclPtr<NumericField> m_pColEdt3;
- VclPtr<ListBox> m_pTypDLB3;
- VclPtr<RadioButton> m_pSortUp3RB;
- VclPtr<RadioButton> m_pSortDn3RB;
+ std::unique_ptr<weld::CheckButton> m_xKeyCB3;
+ std::unique_ptr<weld::SpinButton> m_xColEdt3;
+ std::unique_ptr<weld::ComboBoxText> m_xTypDLB3;
+ std::unique_ptr<weld::RadioButton> m_xSortUp3RB;
+ std::unique_ptr<weld::RadioButton> m_xSortDn3RB;
- VclPtr<RadioButton> m_pColumnRB;
- VclPtr<RadioButton> m_pRowRB;
+ std::unique_ptr<weld::RadioButton> m_xColumnRB;
+ std::unique_ptr<weld::RadioButton> m_xRowRB;
- VclPtr<RadioButton> m_pDelimTabRB;
- VclPtr<RadioButton> m_pDelimFreeRB;
- VclPtr<Edit> m_pDelimEdt;
- VclPtr<PushButton> m_pDelimPB;
+ std::unique_ptr<weld::RadioButton> m_xDelimTabRB;
+ std::unique_ptr<weld::RadioButton> m_xDelimFreeRB;
+ std::unique_ptr<weld::Entry> m_xDelimEdt;
+ std::unique_ptr<weld::Button> m_xDelimPB;
- VclPtr<SvxLanguageBox> m_pLangLB;
+ std::unique_ptr<LanguageBox> m_xLangLB;
- VclPtr<CheckBox> m_pCaseCB;
+ std::unique_ptr<weld::CheckButton> m_xCaseCB;
OUString aColText;
OUString aRowText;
OUString aNumericText;
SwWrtShell &rSh;
- CollatorResource* pColRes;
+ std::unique_ptr<CollatorResource> m_xColRes;
sal_uInt16 nX;
sal_uInt16 nY;
- virtual void Apply() override;
+ void Apply();
sal_Unicode GetDelimChar() const;
- DECL_LINK( CheckHdl, Button*, void );
- DECL_LINK( DelimHdl, Button*, void );
- DECL_LINK( LanguageListBoxHdl, ListBox&, void );
- void LanguageHdl(ListBox const *);
- DECL_LINK(DelimCharHdl, Button*,void);
+ DECL_LINK(CheckHdl, weld::ToggleButton&, void);
+ DECL_LINK(DelimHdl, weld::ToggleButton&, void );
+ DECL_LINK(LanguageListBoxHdl, weld::ComboBoxText&, void);
+ void LanguageHdl(weld::ComboBoxText const*);
+ DECL_LINK(DelimCharHdl, weld::Button&,void);
public:
- SwSortDlg(vcl::Window * pParent, SwWrtShell &rSh);
- virtual ~SwSortDlg() override;
- virtual void dispose() override;
+ SwSortDlg(weld::Window * pParent, SwWrtShell &rSh);
+ short execute();
};
#endif
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index ebe37818f216..cac6f2f6363f 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -787,7 +787,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
case FN_SORTING_DLG:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwSortingDialog(GetView().GetWindow(), rWrtSh));
+ ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwSortingDialog(GetView().GetFrameWeld(), rWrtSh));
pDlg->Execute();
rReq.Done();
}
diff --git a/sw/uiconfig/swriter/ui/sortdialog.ui b/sw/uiconfig/swriter/ui/sortdialog.ui
index 3fb403fdd857..529932f06bfb 100644
--- a/sw/uiconfig/swriter/ui/sortdialog.ui
+++ b/sw/uiconfig/swriter/ui/sortdialog.ui
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.20.2 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">99</property>
@@ -10,10 +9,27 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="lower">1</property>
+ <property name="upper">99</property>
+ <property name="value">1</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="lower">1</property>
+ <property name="upper">99</property>
+ <property name="value">1</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkDialog" id="SortDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="sortdialog|SortDialog">Sort</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -162,7 +178,6 @@
<property name="yalign">0.50999999046325684</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">down1</property>
<accessibility>
<relation type="member-of" target="key1"/>
</accessibility>
@@ -211,7 +226,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">down2</property>
<accessibility>
<relation type="member-of" target="key2"/>
</accessibility>
@@ -260,7 +274,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">down3</property>
<accessibility>
<relation type="member-of" target="key3"/>
</accessibility>
@@ -347,6 +360,7 @@
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="invisible_char">•</property>
+ <property name="activates_default">True</property>
<property name="adjustment">adjustment1</property>
<accessibility>
<relation type="labelled-by" target="column"/>
@@ -364,7 +378,8 @@
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="invisible_char">•</property>
- <property name="adjustment">adjustment1</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment2</property>
<accessibility>
<relation type="labelled-by" target="column"/>
<relation type="member-of" target="key2"/>
@@ -381,7 +396,8 @@
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="invisible_char">•</property>
- <property name="adjustment">adjustment1</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment3</property>
<accessibility>
<relation type="labelled-by" target="column"/>
<relation type="member-of" target="key3"/>
@@ -393,12 +409,11 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="typelb1">
+ <object class="GtkComboBoxText" id="typelb1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
- <property name="entry_text_column">0</property>
<accessibility>
<relation type="labelled-by" target="keytype"/>
<relation type="member-of" target="key1"/>
@@ -415,13 +430,12 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="typelb2">
+ <object class="GtkComboBoxText" id="typelb2">
<property name="width_request">130</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
- <property name="button_sensitivity">off</property>
<accessibility>
<relation type="labelled-by" target="keytype"/>
<relation type="member-of" target="key2"/>
@@ -438,7 +452,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="typelb3">
+ <object class="GtkComboBoxText" id="typelb3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
@@ -516,7 +530,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">rows</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -530,7 +543,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">columns</property>
</object>
@@ -587,7 +599,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">character</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -602,7 +613,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">tabs</property>
<accessibility>
@@ -625,8 +635,11 @@
<object class="GtkEntry" id="separator">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="max_length">1</property>
<property name="invisible_char">•</property>
+ <property name="activates_default">True</property>
<property name="width_chars">1</property>
+ <property name="max_width_chars">1</property>
<accessibility>
<relation type="labelled-by" target="character"/>
</accessibility>
@@ -705,9 +718,15 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="svxcorelo-SvxLanguageBox" id="langlb">
+ <object class="GtkComboBoxText" id="langlb">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -789,5 +808,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 0d5dee9c3fbf..15d44f892a76 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -299,6 +299,11 @@ public:
m_xWidget->set_margin_bottom(nMargin);
}
+ virtual void set_accessible_name(const OUString& rName) override
+ {
+ m_xWidget->SetAccessibleName(rName);
+ }
+
virtual weld::Container* weld_parent() const override;
virtual ~SalInstanceWidget() override
@@ -1197,25 +1202,19 @@ IMPL_LINK(SalInstanceDrawingArea, MouseReleaseHdl, const Point&, rPos, void)
m_aMouseReleaseHdl.Call(rPos);
}
-//ComboBox and ListBox have the same apis, ComboBoxes in LibreOffice have an edit box and ListBoxes
+//ComboBox and ListBox have similiar apis, ComboBoxes in LibreOffice have an edit box and ListBoxes
//don't. This distinction isn't there in Gtk. Use a template to sort this problem out.
template <class vcl_type>
class SalInstanceComboBoxText : public SalInstanceContainer, public virtual weld::ComboBoxText
{
-private:
+protected:
VclPtr<vcl_type> m_xComboBoxText;
- static void LinkStubSetSelectHdl(void* instance, vcl_type&)
- {
- return static_cast<SalInstanceComboBoxText*>(instance)->signal_changed();
- }
-
public:
SalInstanceComboBoxText(vcl_type* pComboBoxText, bool bTakeOwnership)
: SalInstanceContainer(pComboBoxText, bTakeOwnership)
, m_xComboBoxText(pComboBoxText)
{
- m_xComboBoxText->SetSelectHdl(LINK(this, SalInstanceComboBoxText, SetSelectHdl));
}
virtual int get_active() const override
@@ -1312,6 +1311,19 @@ public:
return nRet;
}
+ virtual int find_id(const OUString& rStr) const override
+ {
+ for (int i = 0; i < get_count(); ++i)
+ {
+ const OUString* pId = getEntryData(i);
+ if (!pId)
+ continue;
+ if (*pId == rStr)
+ return i;
+ }
+ return -1;
+ }
+
virtual void clear() override
{
for (int i = 0; i < get_count(); ++i)
@@ -1329,11 +1341,68 @@ public:
virtual ~SalInstanceComboBoxText() override
{
- m_xComboBoxText->SetSelectHdl(Link<vcl_type&, void>());
clear();
}
};
+class SalInstanceComboBoxTextWithoutEdit : public SalInstanceComboBoxText<ListBox>
+{
+private:
+ DECL_LINK(SelectHdl, ListBox&, void);
+
+public:
+ SalInstanceComboBoxTextWithoutEdit(ListBox* pListBox, bool bTakeOwnership)
+ : SalInstanceComboBoxText<ListBox>(pListBox, bTakeOwnership)
+ {
+ m_xComboBoxText->SetSelectHdl(LINK(this, SalInstanceComboBoxTextWithoutEdit, SelectHdl));
+ }
+
+ virtual void set_entry_error(bool /*bError*/) override
+ {
+ assert(false);
+ }
+
+ virtual ~SalInstanceComboBoxTextWithoutEdit() override
+ {
+ m_xComboBoxText->SetSelectHdl(Link<ListBox&, void>());
+ }
+};
+
+IMPL_LINK_NOARG(SalInstanceComboBoxTextWithoutEdit, SelectHdl, ListBox&, void)
+{
+ return signal_changed();
+}
+
+class SalInstanceComboBoxTextWithEdit : public SalInstanceComboBoxText<ComboBox>
+{
+private:
+ DECL_LINK(ChangeHdl, Edit&, void);
+public:
+ SalInstanceComboBoxTextWithEdit(ComboBox* pComboBoxText, bool bTakeOwnership)
+ : SalInstanceComboBoxText<ComboBox>(pComboBoxText, bTakeOwnership)
+ {
+ m_xComboBoxText->SetModifyHdl(LINK(this, SalInstanceComboBoxTextWithEdit, ChangeHdl));
+ }
+
+ virtual void set_entry_error(bool bError) override
+ {
+ if (bError)
+ m_xComboBoxText->SetControlForeground(Color(0xf0, 0, 0));
+ else
+ m_xComboBoxText->SetControlForeground();
+ }
+
+ virtual ~SalInstanceComboBoxTextWithEdit() override
+ {
+ m_xComboBoxText->SetModifyHdl(Link<Edit&, void>());
+ }
+};
+
+IMPL_LINK_NOARG(SalInstanceComboBoxTextWithEdit, ChangeHdl, Edit&, void)
+{
+ signal_changed();
+}
+
class SalInstanceBuilder : public weld::Builder
{
private:
@@ -1437,9 +1506,9 @@ public:
vcl::Window* pComboBoxText = m_xBuilder->get<vcl::Window>(id);
ComboBox* pComboBox = dynamic_cast<ComboBox*>(pComboBoxText);
if (pComboBox)
- return new SalInstanceComboBoxText<ComboBox>(pComboBox, bTakeOwnership);
+ return new SalInstanceComboBoxTextWithEdit(pComboBox, bTakeOwnership);
ListBox* pListBox = dynamic_cast<ListBox*>(pComboBoxText);
- return pListBox ? new SalInstanceComboBoxText<ListBox>(pListBox, bTakeOwnership) : nullptr;
+ return pListBox ? new SalInstanceComboBoxTextWithoutEdit(pListBox, bTakeOwnership) : nullptr;
}
virtual weld::TreeView* weld_tree_view(const OString &id, bool bTakeOwnership) override
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 4a24e5d03357..a7c0ac3824e6 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1310,6 +1310,14 @@ public:
gtk_widget_set_margin_bottom(m_pWidget, nMargin);
}
+ virtual void set_accessible_name(const OUString& rName) override
+ {
+ AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
+ if (!pAtkObject)
+ return;
+ atk_object_set_description(pAtkObject, OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr());
+ }
+
virtual weld::Container* weld_parent() const override;
virtual OString get_buildable_name() const override
@@ -2622,12 +2630,51 @@ private:
return sRet;
}
+ int find(const OUString& rStr, int col) const
+ {
+ GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText));
+ GtkTreeIter iter;
+ if (!gtk_tree_model_get_iter_first(pModel, &iter))
+ return -1;
+
+ OString aStr(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
+ int nRet = 0;
+ do
+ {
+ gchar* pStr;
+ gtk_tree_model_get(pModel, &iter, col, &pStr, -1);
+ const bool bEqual = strcmp(pStr, aStr.getStr()) == 0;
+ g_free(pStr);
+ if (bEqual)
+ return nRet;
+ ++nRet;
+ } while (gtk_tree_model_iter_next(pModel, &iter));
+
+ return -1;
+ }
+
+ void setup_completion()
+ {
+ GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText));
+ if (GTK_IS_ENTRY(pChild))
+ {
+ GtkEntry* pEntry = GTK_ENTRY(pChild);
+ GtkEntryCompletion* pCompletion = gtk_entry_completion_new();
+ gtk_entry_completion_set_model(pCompletion, gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)));
+ gtk_entry_completion_set_text_column(pCompletion, 0);
+ gtk_entry_completion_set_inline_selection(pCompletion, true);
+ gtk_entry_set_completion(pEntry, pCompletion);
+ g_object_unref(pCompletion);
+ }
+ }
+
public:
GtkInstanceComboBoxText(GtkComboBoxText* pComboBoxText, bool bTakeOwnership)
: GtkInstanceContainer(GTK_CONTAINER(pComboBoxText), bTakeOwnership)
, m_pComboBoxText(pComboBoxText)
, m_nSignalId(g_signal_connect(m_pComboBoxText, "changed", G_CALLBACK(signalChanged), this))
{
+ setup_completion();
}
virtual int get_active() const override
@@ -2638,7 +2685,7 @@ public:
virtual OUString get_active_id() const override
{
const gchar* pText = gtk_combo_box_get_active_id(GTK_COMBO_BOX(m_pComboBoxText));
- return OUString(pText, strlen(pText), RTL_TEXTENCODING_UTF8);
+ return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8);
}
virtual void set_active_id(const OUString& rStr) override
@@ -2707,31 +2754,20 @@ public:
virtual int find_text(const OUString& rStr) const override
{
- GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText));
- GtkTreeIter iter;
- if (!gtk_tree_model_get_iter_first(pModel, &iter))
- return -1;
-
- OString aStr(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
- int nRet = 0;
- do
- {
- gchar* pStr;
- gtk_tree_model_get(pModel, &iter, 0, &pStr, -1);
- const bool bEqual = strcmp(pStr, aStr.getStr()) == 0;
- g_free(pStr);
- if (bEqual)
- return nRet;
- ++nRet;
- } while (gtk_tree_model_iter_next(pModel, &iter));
+ return find(rStr, 0);
+ }
- return -1;
+ virtual int find_id(const OUString& rId) const override
+ {
+ return find(rId, 1);
}
virtual void clear() override
{
+ disable_notify_events();
GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText));
gtk_list_store_clear(GTK_LIST_STORE(pModel));
+ enable_notify_events();
}
virtual void make_sorted() override
@@ -2745,6 +2781,17 @@ public:
gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING);
}
+ virtual void set_entry_error(bool bError) override
+ {
+ GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText));
+ assert(GTK_IS_ENTRY(pChild));
+ GtkEntry* pEntry = GTK_ENTRY(pChild);
+ if (bError)
+ gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-error");
+ else
+ gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr);
+ }
+
virtual void disable_notify_events() override
{
g_signal_handler_block(m_pComboBoxText, m_nSignalId);