summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extras/source/glade/libreoffice-catalog.xml.in7
-rw-r--r--include/vcl/edit.hxx19
-rw-r--r--sw/source/ui/misc/glossary.cxx5
-rw-r--r--sw/source/ui/table/instable.cxx2
-rw-r--r--sw/source/ui/table/tabledlg.cxx1
-rw-r--r--sw/source/ui/utlui/swrenamexnameddlg.cxx20
-rw-r--r--sw/source/uibase/cctrl/actctrl.cxx37
-rw-r--r--sw/source/uibase/inc/actctrl.hxx24
-rw-r--r--sw/source/uibase/inc/glossary.hxx3
-rw-r--r--sw/source/uibase/inc/instable.hxx3
-rw-r--r--sw/source/uibase/inc/swrenamexnameddlg.hxx11
-rw-r--r--sw/source/uibase/table/tablepg.hxx3
-rw-r--r--sw/uiconfig/swriter/ui/autotext.ui2
-rw-r--r--sw/uiconfig/swriter/ui/newuserindexdialog.ui2
-rw-r--r--sw/uiconfig/swriter/ui/renameautotextdialog.ui3
-rw-r--r--sw/uiconfig/swriter/ui/renameobjectdialog.ui2
-rw-r--r--vcl/source/control/edit.cxx41
17 files changed, 81 insertions, 104 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 843df8cab96a..fc0cd803ea33 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -42,9 +42,6 @@
<glade-widget-class title="Thesaurus Edit" name="cuilo-ReplaceEdit"
generic-name="ReplaceEdit" parent="GtkEntry"
icon-name="widget-gtk-textentry"/>
- <glade-widget-class title="TableName Edit" name="swlo-TableNameEdit"
- generic-name="TableNameEdit" parent="GtkEntry"
- icon-name="widget-gtk-textentry"/>
<glade-widget-class title="Thesaurus Lookup" name="cuilo-LookUpComboBox"
generic-name="LookUpComboBox" parent="GtkEntry"
icon-name="widget-gtk-comboboxtext"/>
@@ -618,10 +615,6 @@
generic-name="Reference Edit" parent="GtkEntry"
icon-name="widget-gtk-textentry"/>
- <glade-widget-class title="NoSpace Edit" name="swlo-NoSpaceEdit"
- generic-name="NoSpace Edit" parent="GtkEntry"
- icon-name="widget-gtk-textentry"/>
-
<glade-widget-class title="Another NoSpace Edit" name="cuilo-SvxNoSpaceEdit"
generic-name="Another NoSpace Edit" parent="GtkEntry"
icon-name="widget-gtk-textentry">
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index e0d968950b6c..391e825437c0 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -41,24 +41,34 @@ struct Impl_IMEInfos;
// - Edit-Types -
-
-
#define EDIT_NOLIMIT SAL_MAX_INT32
#define EDIT_UPDATEDATA_TIMEOUT 350
typedef OUString (*FncGetSpecialChars)( Window* pWin, const Font& rFont );
+class VCL_DLLPUBLIC TextFilter
+{
+private:
+ OUString sForbiddenChars;
+public:
+ void SetForbiddenChars(const OUString& rSet) { sForbiddenChars = rSet; }
+ const OUString& GetForbiddenChars() { return sForbiddenChars; }
-// - Edit -
+ virtual OUString filter(const OUString &rText);
+ TextFilter(const OUString &rForbiddenChars = OUString(" "));
+ virtual ~TextFilter();
+};
enum AutocompleteAction{ AUTOCOMPLETE_KEYINPUT, AUTOCOMPLETE_TABFORWARD, AUTOCOMPLETE_TABBACKWARD };
+// - Edit -
class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropClient
{
private:
Edit* mpSubEdit;
Timer* mpUpdateDataTimer;
+ TextFilter* mpFilterText;
DDInfo* mpDDInfo;
Impl_IMEInfos* mpIMEInfos;
OUStringBuffer maText;
@@ -116,6 +126,7 @@ private:
SAL_DLLPRIVATE long ImplGetTextYPosition() const;
SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > ImplGetInputSequenceChecker();
SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator() const;
+ SAL_DLLPRIVATE void filterText();
protected:
using Control::ImplInitSettings;
@@ -252,6 +263,8 @@ public:
virtual Selection GetSurroundingTextSelection() const SAL_OVERRIDE;
virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
+ void SetTextFilter(TextFilter* pFilter) { mpFilterText = pFilter; }
+
// returns the minimum size a bordered Edit should have given the current
// global style settings (needed by sc's inputwin.cxx)
static Size GetMinimumEditSize();
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 677dc2b2d2ae..db58cafe8834 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -116,7 +116,8 @@ struct GroupUserData
class SwNewGlosNameDlg : public ModalDialog
{
Edit* m_pNewName;
- NoSpaceEdit* m_pNewShort;
+ TextFilter m_aNoSpaceFilter;
+ Edit* m_pNewShort;
OKButton* m_pOk;
Edit* m_pOldName;
Edit* m_pOldShort;
@@ -142,6 +143,7 @@ SwNewGlosNameDlg::SwNewGlosNameDlg(Window* pParent,
{
get(m_pNewName, "newname");
get(m_pNewShort, "newsc");
+ m_pNewShort->SetTextFilter(&m_aNoSpaceFilter);
get(m_pOk, "ok");
get(m_pOldName, "oldname");
get(m_pOldShort, "oldsc");
@@ -185,6 +187,7 @@ SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
get(m_pNameED, "name");
get(m_pShortNameLbl, "shortnameft");
get(m_pShortNameEdit, "shortname");
+ m_pShortNameEdit->SetTextFilter(&m_aNoSpaceFilter);
get(m_pCategoryBox, "category");
get(m_pFileRelCB, "relfile");
get(m_pNetRelCB, "relnet");
diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx
index 24ffa27a21b4..6cfe91602781 100644
--- a/sw/source/ui/table/instable.cxx
+++ b/sw/source/ui/table/instable.cxx
@@ -71,11 +71,13 @@ void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rC
SwInsTableDlg::SwInsTableDlg( SwView& rView )
: SfxModalDialog(rView.GetWindow(), "InsertTableDialog", "modules/swriter/ui/inserttable.ui")
+ , m_aTextFilter(" .<>")
, pShell(&rView.GetWrtShell())
, pTAutoFmt(0)
, nEnteredValRepeatHeaderNF(-1)
{
get(m_pNameEdit, "nameedit");
+ m_pNameEdit->SetTextFilter(&m_aTextFilter);
get(m_pColNF, "colspin");
get(m_pRowNF, "rowspin");
get(m_pHeaderCB, "headercb");
diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index fa6800b3ff53..207d8f4d265e 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -63,6 +63,7 @@ using namespace ::com::sun::star;
SwFormatTablePage::SwFormatTablePage(Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "FormatTablePage", "modules/swriter/ui/formattablepage.ui", &rSet)
+ , m_aTextFilter(" .<>")
, pTblData(0)
, nSaveWidth(0)
, nMinTableWidth(MINLAY)
diff --git a/sw/source/ui/utlui/swrenamexnameddlg.cxx b/sw/source/ui/utlui/swrenamexnameddlg.cxx
index 582c3b8bb698..d32fd6eb3a65 100644
--- a/sw/source/ui/utlui/swrenamexnameddlg.cxx
+++ b/sw/source/ui/utlui/swrenamexnameddlg.cxx
@@ -56,11 +56,11 @@ SwRenameXNamedDlg::SwRenameXNamedDlg( Window* pWin,
uno::Reference< container::XNameAccess > & xNA )
: ModalDialog(pWin, "RenameObjectDialog",
"modules/swriter/ui/renameobjectdialog.ui")
- , m_sRemoveWarning(SW_RESSTR(STR_REMOVE_WARNING))
, xNamed(xN)
, xNameAccess(xNA)
{
get(m_pNewNameED, "entry");
+ m_pNewNameED->SetTextFilter(&m_aTextFilter);
get(m_pOk, "ok");
OUString sTmp(GetText());
@@ -88,26 +88,10 @@ IMPL_LINK_NOARG(SwRenameXNamedDlg, OkHdl)
return 0;
}
-IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, NoSpaceEdit*, pEdit)
+IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, Edit*, pEdit)
{
OUString sTmp(pEdit->GetText());
- // prevent from pasting illegal characters
- const sal_Int32 nLen = sTmp.getLength();
- OUString sMsg;
- for(sal_Int32 i = 0; i < pEdit->GetForbiddenChars().getLength(); ++i)
- {
- const sal_Int32 nTmpLen = sTmp.getLength();
- sTmp = comphelper::string::remove(sTmp, pEdit->GetForbiddenChars()[i]);
- if(sTmp.getLength() != nTmpLen)
- sMsg += OUString(pEdit->GetForbiddenChars()[i]);
- }
- if(sTmp.getLength() != nLen)
- {
- pEdit->SetText(sTmp);
- InfoBox(this, m_sRemoveWarning + sMsg).Execute();
- }
-
m_pOk->Enable(!sTmp.isEmpty()
&& !xNameAccess->hasByName(sTmp)
&& (!xSecondAccess.is() || !xSecondAccess->hasByName(sTmp))
diff --git a/sw/source/uibase/cctrl/actctrl.cxx b/sw/source/uibase/cctrl/actctrl.cxx
index 4009eadf9f2b..c20a5b23a38e 100644
--- a/sw/source/uibase/cctrl/actctrl.cxx
+++ b/sw/source/uibase/cctrl/actctrl.cxx
@@ -48,31 +48,6 @@ bool NumEditAction::Notify( NotifyEvent& rNEvt )
return nHandled;
}
-NoSpaceEdit::NoSpaceEdit(Window* pParent)
- : Edit(pParent, WB_BORDER|WB_TABSTOP)
- , sForbiddenChars(OUString(" "))
-{
-}
-
-void NoSpaceEdit::Modify()
-{
- Selection aSel = GetSelection();
- OUString sTemp = GetText();
- for(sal_uInt16 i = 0; i < sForbiddenChars.getLength(); i++)
- {
- sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]);
- }
- sal_Int32 nDiff = GetText().getLength() - sTemp.getLength();
- if(nDiff)
- {
- aSel.setMin(aSel.getMin() - nDiff);
- aSel.setMax(aSel.getMin());
- SetText(sTemp);
- SetSelection(aSel);
- }
- Edit::Modify();
-}
-
void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
{
const KeyCode aKeyCode = rEvt.GetKeyCode();
@@ -87,18 +62,6 @@ void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
Edit::KeyInput(rEvt);
}
-extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &rMap)
-{
- VclBuilder::ensureDefaultWidthChars(rMap);
- return new TableNameEdit(pParent);
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNoSpaceEdit(Window *pParent, VclBuilder::stringmap &rMap)
-{
- VclBuilder::ensureDefaultWidthChars(rMap);
- return new NoSpaceEdit(pParent);
-}
-
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReturnActionEdit(Window *pParent, VclBuilder::stringmap &rMap)
{
VclBuilder::ensureDefaultWidthChars(rMap);
diff --git a/sw/source/uibase/inc/actctrl.hxx b/sw/source/uibase/inc/actctrl.hxx
index 00d71fd5baef..919a8dd16f6a 100644
--- a/sw/source/uibase/inc/actctrl.hxx
+++ b/sw/source/uibase/inc/actctrl.hxx
@@ -38,30 +38,6 @@ public:
const Link& GetActionHdl() const { return aActionLink; }
};
-// Edit that doesn't accept spaces
-class SW_DLLPUBLIC NoSpaceEdit : public Edit
-{
- OUString sForbiddenChars;
-protected:
- virtual void Modify() SAL_OVERRIDE;
-
-public:
- NoSpaceEdit( Window* pParent );
- void SetForbiddenChars(const OUString& rSet){sForbiddenChars = rSet;}
- const OUString& GetForbiddenChars(){return sForbiddenChars;}
-};
-
-// No space and no full stop
-class TableNameEdit : public NoSpaceEdit
-{
-public:
- TableNameEdit(Window* pWin)
- : NoSpaceEdit(pWin)
- {
- SetForbiddenChars(OUString(" .<>"));
- }
-};
-
// call a link when KEY_RETURN is pressed
class SW_DLLPUBLIC ReturnActionEdit : public Edit
{
diff --git a/sw/source/uibase/inc/glossary.hxx b/sw/source/uibase/inc/glossary.hxx
index c34dee5d7d27..b565b71fb7ad 100644
--- a/sw/source/uibase/inc/glossary.hxx
+++ b/sw/source/uibase/inc/glossary.hxx
@@ -91,7 +91,8 @@ class SwGlossaryDlg : public SvxStandardDialog
CheckBox* m_pInsertTipCB;
Edit* m_pNameED;
FixedText* m_pShortNameLbl;
- NoSpaceEdit* m_pShortNameEdit;
+ TextFilter m_aNoSpaceFilter;
+ Edit* m_pShortNameEdit;
SwGlTreeListBox* m_pCategoryBox;
CheckBox* m_pFileRelCB;
CheckBox* m_pNetRelCB;
diff --git a/sw/source/uibase/inc/instable.hxx b/sw/source/uibase/inc/instable.hxx
index ce47d8d30776..d61de339f2b8 100644
--- a/sw/source/uibase/inc/instable.hxx
+++ b/sw/source/uibase/inc/instable.hxx
@@ -34,7 +34,8 @@ struct SwInsertTableOptions;
class SwInsTableDlg : public SfxModalDialog
{
- TableNameEdit* m_pNameEdit;
+ Edit* m_pNameEdit;
+ TextFilter m_aTextFilter;
NumericField* m_pColNF;
NumericField* m_pRowNF;
diff --git a/sw/source/uibase/inc/swrenamexnameddlg.hxx b/sw/source/uibase/inc/swrenamexnameddlg.hxx
index 7d41baf60894..81d314449172 100644
--- a/sw/source/uibase/inc/swrenamexnameddlg.hxx
+++ b/sw/source/uibase/inc/swrenamexnameddlg.hxx
@@ -32,10 +32,9 @@
class SwRenameXNamedDlg : public ModalDialog
{
- NoSpaceEdit* m_pNewNameED;
- OKButton* m_pOk;
-
- OUString m_sRemoveWarning;
+ Edit* m_pNewNameED;
+ TextFilter m_aTextFilter;
+ OKButton* m_pOk;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > & xNamed;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & xNameAccess;
@@ -43,7 +42,7 @@ class SwRenameXNamedDlg : public ModalDialog
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xThirdAccess;
DECL_LINK(OkHdl, void *);
- DECL_LINK(ModifyHdl, NoSpaceEdit*);
+ DECL_LINK(ModifyHdl, Edit*);
public:
SwRenameXNamedDlg( Window* pParent,
@@ -52,7 +51,7 @@ public:
void SetForbiddenChars(const OUString& rSet)
{
- m_pNewNameED->SetForbiddenChars(rSet);
+ m_aTextFilter.SetForbiddenChars(rSet);
}
void SetAlternativeAccess(
diff --git a/sw/source/uibase/table/tablepg.hxx b/sw/source/uibase/table/tablepg.hxx
index 7ab02588644e..f8d207af61e6 100644
--- a/sw/source/uibase/table/tablepg.hxx
+++ b/sw/source/uibase/table/tablepg.hxx
@@ -37,7 +37,8 @@ struct TColumn
class SwFormatTablePage : public SfxTabPage
{
- TableNameEdit* m_pNameED;
+ Edit* m_pNameED;
+ TextFilter m_aTextFilter;
FixedText* m_pWidthFT;
PercentField m_aWidthMF;
CheckBox* m_pRelWidthCB;
diff --git a/sw/uiconfig/swriter/ui/autotext.ui b/sw/uiconfig/swriter/ui/autotext.ui
index fab9878c1472..d6a3463dcead 100644
--- a/sw/uiconfig/swriter/ui/autotext.ui
+++ b/sw/uiconfig/swriter/ui/autotext.ui
@@ -276,7 +276,7 @@
</packing>
</child>
<child>
- <object class="swlo-NoSpaceEdit" id="shortname">
+ <object class="GtkEntry" id="shortname">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
diff --git a/sw/uiconfig/swriter/ui/newuserindexdialog.ui b/sw/uiconfig/swriter/ui/newuserindexdialog.ui
index 754ee70cea17..6eba268f9fc0 100644
--- a/sw/uiconfig/swriter/ui/newuserindexdialog.ui
+++ b/sw/uiconfig/swriter/ui/newuserindexdialog.ui
@@ -109,7 +109,7 @@
</packing>
</child>
<child>
- <object class="swlo-NoSpaceEdit" id="entry">
+ <object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
diff --git a/sw/uiconfig/swriter/ui/renameautotextdialog.ui b/sw/uiconfig/swriter/ui/renameautotextdialog.ui
index fda9dd794847..88423f44a176 100644
--- a/sw/uiconfig/swriter/ui/renameautotextdialog.ui
+++ b/sw/uiconfig/swriter/ui/renameautotextdialog.ui
@@ -201,10 +201,9 @@
</packing>
</child>
<child>
- <object class="swlo-NoSpaceEdit" id="newsc">
+ <object class="GtkEntry" id="newsc">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="invisible_char">●</property>
<property name="width_chars">6</property>
<property name="invisible_char_set">True</property>
</object>
diff --git a/sw/uiconfig/swriter/ui/renameobjectdialog.ui b/sw/uiconfig/swriter/ui/renameobjectdialog.ui
index 8e98a39a984b..d162def49cfa 100644
--- a/sw/uiconfig/swriter/ui/renameobjectdialog.ui
+++ b/sw/uiconfig/swriter/ui/renameobjectdialog.ui
@@ -109,7 +109,7 @@
</packing>
</child>
<child>
- <object class="swlo-NoSpaceEdit" id="entry">
+ <object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index f117e3f73d9d..37f65027f961 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -276,6 +276,7 @@ void Edit::ImplInitEditData()
{
mpSubEdit = NULL;
mpUpdateDataTimer = NULL;
+ mpFilterText = NULL;
mnXOffset = 0;
mnAlign = EDIT_ALIGN_LEFT;
mnMaxTextLen = EDIT_NOLIMIT;
@@ -2334,8 +2335,48 @@ void Edit::ImplHideDDCursor()
}
}
+TextFilter::TextFilter(const OUString &rForbiddenChars)
+ : sForbiddenChars(rForbiddenChars)
+{
+}
+
+TextFilter::~TextFilter()
+{
+}
+
+OUString TextFilter::filter(const OUString &rText)
+{
+ OUString sTemp(rText);
+ for (sal_uInt16 i = 0; i < sForbiddenChars.getLength(); ++i)
+ {
+ sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]);
+ }
+ return sTemp;
+}
+
+void Edit::filterText()
+{
+ Selection aSel = GetSelection();
+ OUString sOrig = GetText();
+ OUString sNew = mpFilterText->filter(GetText());
+ if (sOrig != sNew)
+ {
+ sal_Int32 nDiff = sOrig.getLength() - sNew.getLength();
+ if (nDiff)
+ {
+ aSel.setMin(aSel.getMin() - nDiff);
+ aSel.setMax(aSel.getMin());
+ }
+ SetText(sNew);
+ SetSelection(aSel);
+ }
+}
+
void Edit::Modify()
{
+ if (mpFilterText)
+ filterText();
+
if ( mbIsSubEdit )
{
((Edit*)GetParent())->Modify();