Resolves: tdf#132626 entry_insert_text works on the newly typed region

but in this case we want to work on the whole entry string to see
if it forms a legal result

Change-Id: I818c7d6b8efc53d00a7ea68b2e1e0ad386ed0b20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93796
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 4320d71a..b12a896 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -97,12 +97,6 @@ OUString TextFilterAutoConvert::filter(const OUString &rText)
    return rText;
}

IMPL_LINK(SwCaptionDialog, TextFilterHdl, OUString&, rTest, bool)
{
    rTest = m_aTextFilter.filter(rTest);
    return true;
}

SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, SwView &rV)
    : SfxDialogController(pParent, "modules/swriter/ui/insertcaption.ui", "InsertCaptionDialog")
    , m_sNone(SwResId(SW_STR_NONE))
@@ -126,8 +120,6 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, SwView &rV)
    , m_xOptionButton(m_xBuilder->weld_button("options"))
    , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
{
    m_xCategoryBox->connect_entry_insert_text(LINK(this, SwCaptionDialog, TextFilterHdl));

    //#i61007# order of captions
    ApplyCaptionOrder();
    SwWrtShell &rSh = rView.GetWrtShell();
@@ -366,6 +358,13 @@ IMPL_LINK_NOARG(SwCaptionDialog, ModifyEntryHdl, weld::Entry&, void)

IMPL_LINK_NOARG(SwCaptionDialog, ModifyComboHdl, weld::ComboBox&, void)
{
    OUString sText = m_xCategoryBox->get_active_text();
    OUString sAllowedText = m_aTextFilter.filter(sText);
    if (sText != sAllowedText)
    {
        m_xCategoryBox->set_entry_text(sAllowedText);
        m_xCategoryBox->select_entry_region(sAllowedText.getLength(), sAllowedText.getLength());
    }
    ModifyHdl();
}

diff --git a/sw/source/uibase/inc/cption.hxx b/sw/source/uibase/inc/cption.hxx
index 58fffc2..e12244e 100644
--- a/sw/source/uibase/inc/cption.hxx
+++ b/sw/source/uibase/inc/cption.hxx
@@ -64,7 +64,6 @@ class SwCaptionDialog : public SfxDialogController
    DECL_LINK(ModifyComboHdl, weld::ComboBox&, void);
    DECL_LINK(OptionHdl, weld::Button&, void);
    DECL_LINK(CaptionHdl, weld::Button&, void);
    DECL_LINK(TextFilterHdl, OUString&, bool);

    void Apply();