dbaccess/source/core/dataaccess/databasedocument.cxx | 2 dbaccess/source/core/dataaccess/databasedocument.hxx | 5 + extras/source/glade/libreoffice-catalog.xml.in | 13 ---- include/vcl/edit.hxx | 19 +++++- sw/source/ui/dbui/mmaddressblockpage.cxx | 49 ----------------- sw/source/ui/dbui/mmaddressblockpage.hxx | 20 ------- sw/source/ui/frmdlg/cption.cxx | 47 +++------------- sw/source/ui/misc/glossary.cxx | 5 + sw/source/ui/table/instable.cxx | 2 sw/source/ui/table/tabledlg.cxx | 1 sw/source/ui/utlui/swrenamexnameddlg.cxx | 20 ------- sw/source/uibase/cctrl/actctrl.cxx | 54 ------------------- sw/source/uibase/inc/actctrl.hxx | 26 --------- sw/source/uibase/inc/cption.hxx | 13 ++-- sw/source/uibase/inc/glossary.hxx | 3 - sw/source/uibase/inc/instable.hxx | 3 - sw/source/uibase/inc/swrenamexnameddlg.hxx | 11 +-- sw/source/uibase/table/tablepg.hxx | 3 - sw/uiconfig/swriter/ui/addressblockdialog.ui | 2 sw/uiconfig/swriter/ui/autotext.ui | 2 sw/uiconfig/swriter/ui/insertcaption.ui | 13 +++- sw/uiconfig/swriter/ui/newuserindexdialog.ui | 2 sw/uiconfig/swriter/ui/renameautotextdialog.ui | 3 - sw/uiconfig/swriter/ui/renameobjectdialog.ui | 2 vcl/source/control/edit.cxx | 41 ++++++++++++++ 25 files changed, 115 insertions(+), 246 deletions(-)
New commits: commit b7e2a62dec5e9a01b1c83255aedf902f180e4ca0 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jun 16 16:45:46 2014 +0100 and now we can remove SwRestrictedComboBox as well Change-Id: I69aa440ed4ef13e60251bf1aa019208b79b317d2 diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 7d17202..4a16e41 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -463,9 +463,6 @@ <glade-widget-class title="Bookmark Combo" name="swuilo-BookmarkCombo" generic-name="BookmarkComboBox" parent="GtkComboBox" icon-name="widget-gtk-combobox"/> - <glade-widget-class title="Restricted ComboBox" name="swuilo-SwRestrictedComboBox" - generic-name="Restricted ComboBox" parent="GtkComboBox" - icon-name="widget-gtk-combobox"/> <glade-widget-class title="Category Edit" name="swuilo-FEdit" generic-name="CategoryEdit" parent="GtkEntry" icon-name="widget-gtk-textentry"/> diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index 4b76162..406c7f8 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -447,53 +447,6 @@ IMPL_LINK(SwSelectAddressBlockDialog, IncludeHdl_Impl, RadioButton*, pButton) return 0; } -extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwRestrictedComboBox(Window *pParent, VclBuilder::stringmap &rMap) -{ - WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK; - - bool bDropdown = VclBuilder::extractDropdown(rMap); - - if (bDropdown) - nBits |= WB_DROPDOWN; - - SwRestrictedComboBox* pComboBox = new SwRestrictedComboBox(pParent, nBits); - pComboBox->EnableAutoSize(true); - return pComboBox; -} - -void SwRestrictedComboBox::KeyInput(const KeyEvent& rEvt) -{ - bool bCallParent = true; - if(rEvt.GetCharCode()) - { - OUString sKey(rEvt.GetCharCode()); - if( -1 != sForbiddenChars.indexOf(sKey)) - bCallParent = false; - } - if(bCallParent) - ComboBox::KeyInput(rEvt); -} - -void SwRestrictedComboBox::Modify() -{ - Selection aSel = GetSelection(); - OUString sTemp = GetText(); - for(sal_Int32 i = 0; i < sForbiddenChars.getLength(); ++i) - { - sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]); - } - const sal_Int32 nDiff = GetText().getLength() - sTemp.getLength(); - if(nDiff) - { - aSel.setMin(aSel.getMin() - nDiff); - aSel.setMax(aSel.getMin()); - SetText(sTemp); - SetSelection(aSel); - } - if(GetModifyHdl().IsSet()) - GetModifyHdl().Call(this); -} - #define USER_DATA_SALUTATION -1 #define USER_DATA_PUNCTUATION -2 #define USER_DATA_TEXT -3 @@ -503,13 +456,14 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog( Window* pParent, SwMailMergeConfigItem& rConfig, DialogType eType) : SfxModalDialog(pParent, "AddressBlockDialog", "modules/swriter/ui/addressblockdialog.ui") + , m_aTextFilter("<>") , m_rConfigItem(rConfig) , m_eType(eType) { get(m_pOK, "ok"); get(m_pPreviewWIN, "addrpreview"); get(m_pFieldCB, "custom"); - m_pFieldCB->SetForbiddenChars("<>"); + m_pFieldCB->SetTextFilter(&m_aTextFilter); get(m_pFieldFT, "customft"); get(m_pDownIB, "down"); get(m_pRightIB, "right"); diff --git a/sw/source/ui/dbui/mmaddressblockpage.hxx b/sw/source/ui/dbui/mmaddressblockpage.hxx index 0563d5a..c3d0d56 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.hxx +++ b/sw/source/ui/dbui/mmaddressblockpage.hxx @@ -170,23 +170,6 @@ public: void SelectCurrentItem(); }; -// Dialog is used to create custom address blocks as well as custom greeting lines -class SwRestrictedComboBox : public ComboBox -{ - OUString sForbiddenChars; - -protected: - virtual void KeyInput( const KeyEvent& ) SAL_OVERRIDE; - virtual void Modify() SAL_OVERRIDE; -public: - SwRestrictedComboBox(Window* pParent, WinBits nStyle = 0) - : ComboBox( pParent, nStyle ) - { - } - - void SetForbiddenChars(const OUString& rSet){sForbiddenChars = rSet;} - -}; class SwCustomizeAddressBlockDialog : public SfxModalDialog { friend class DDListBox; @@ -214,7 +197,8 @@ private: PushButton* m_pDownIB; FixedText* m_pFieldFT; - SwRestrictedComboBox* m_pFieldCB; + ComboBox* m_pFieldCB; + TextFilter m_aTextFilter; SwAddressPreview* m_pPreviewWIN; diff --git a/sw/uiconfig/swriter/ui/addressblockdialog.ui b/sw/uiconfig/swriter/ui/addressblockdialog.ui index a36e235..0b4fd25 100644 --- a/sw/uiconfig/swriter/ui/addressblockdialog.ui +++ b/sw/uiconfig/swriter/ui/addressblockdialog.ui @@ -247,7 +247,7 @@ </packing> </child> <child> - <object class="swuilo-SwRestrictedComboBox" id="custom"> + <object class="GtkComboBoxText" id="custom"> <property name="can_focus">False</property> <property name="no_show_all">True</property> <property name="has_entry">True</property> commit f219ec6b5e09b55466ce313d73929670cf11a989 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jun 16 16:42:01 2014 +0100 missing SetForbiddenChars call Change-Id: I03a26d49210c3dfe89abd31e5c754fafe2b7acee diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index 00f610a..4b76162 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -509,6 +509,7 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog( get(m_pOK, "ok"); get(m_pPreviewWIN, "addrpreview"); get(m_pFieldCB, "custom"); + m_pFieldCB->SetForbiddenChars("<>"); get(m_pFieldFT, "customft"); get(m_pDownIB, "down"); get(m_pRightIB, "right"); commit 46650cb7c3ed3d48d8fe7b6c6dd6d7357b698afb Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jun 16 15:57:23 2014 +0100 Related: fdo#47427 disallow pasting spaces into category box Change-Id: I4caf4b2ac028629c6ecbd42084346623192df09e diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index fc0cd80..7d17202 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -460,9 +460,6 @@ <glade-widget-class title="Numbering Type ListBox" name="swlo-SwNumberingTypeListBox" generic-name="NumberingTypeListBox" parent="GtkComboBox" icon-name="widget-gtk-combobox"/> - <glade-widget-class title="Category ComboBox" name="swuilo-CategoryBox" - generic-name="CategoryComboBox" parent="GtkComboBox" - icon-name="widget-gtk-combobox"/> <glade-widget-class title="Bookmark Combo" name="swuilo-BookmarkCombo" generic-name="BookmarkComboBox" parent="GtkComboBox" icon-name="widget-gtk-combobox"/> diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx index 1526eb1..ec81b01 100644 --- a/sw/source/ui/frmdlg/cption.cxx +++ b/sw/source/ui/frmdlg/cption.cxx @@ -82,6 +82,15 @@ public: OUString SwCaptionDialog::our_aSepTextSave(": "); // Caption separator text +//Resolves: fdo#47427 disallow typing *or* pasting content into the category box +OUString TextFilterAutoConvert::filter(const OUString &rText) +{ + if (!SwCalc::IsValidVarName(rText)) + return m_sLastGoodText; + m_sLastGoodText = rText; + return rText; +} + SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : SvxStandardDialog( pParent, "InsertCaptionDialog", "modules/swriter/ui/insertcaption.ui" ), m_sNone( SW_RESSTR(SW_STR_NONE) ), @@ -92,6 +101,7 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : { get(m_pTextEdit, "caption_edit"); get(m_pCategoryBox, "category"); + m_pCategoryBox->SetTextFilter(&m_aTextFilter); get(m_pFormatText, "numbering_label"); get(m_pFormatBox, "numbering"); get(m_pNumberingSeparatorFT, "num_separator"); @@ -489,43 +499,6 @@ void SwSequenceOptionDialog::SetCharacterStyle(const OUString& rStyle) m_pLbCharStyle->SelectEntry(rStyle); } -bool CategoryBox::PreNotify( NotifyEvent& rNEvt ) -{ - bool nHandled = false; - if( rNEvt.GetType() == EVENT_KEYINPUT && - rNEvt.GetKeyEvent()->GetCharCode() ) - { - const KeyEvent* pEvent = rNEvt.GetKeyEvent(); - const KeyCode& rKeyCode = pEvent->GetKeyCode(); - const sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE; - - if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN - && nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE) - { - const OUString sText( GetText() ); - Selection aSel( GetSelection() ); - aSel.Justify(); - - const OUString sName = sText.copy(0, aSel.Min()) - + OUString( pEvent->GetCharCode() ) - + sText.copy(aSel.Max()); - - if( !SwCalc::IsValidVarName( sName )) - nHandled = true; - } - } - if(!nHandled) - nHandled = ComboBox::PreNotify( rNEvt ); - return nHandled; -} - -extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeCategoryBox(Window* pParent, VclBuilder::stringmap &) -{ - CategoryBox* pCategoryBox = new CategoryBox(pParent, WB_LEFT | WB_DROPDOWN | WB_VCENTER | WB_3DLOOK | WB_SORT); - pCategoryBox->EnableAutoSize(true); - return pCategoryBox; -} - // #i61007# order of captions void SwCaptionDialog::ApplyCaptionOrder() { diff --git a/sw/source/uibase/inc/cption.hxx b/sw/source/uibase/inc/cption.hxx index 98781e1..0c1787f 100644 --- a/sw/source/uibase/inc/cption.hxx +++ b/sw/source/uibase/inc/cption.hxx @@ -48,20 +48,19 @@ class SwView; #include "optload.hxx" #include "swlbox.hxx" -class CategoryBox : public ComboBox +class TextFilterAutoConvert : public TextFilter { +private: + OUString m_sLastGoodText; public: - CategoryBox( Window* pParent, WinBits nStyle = 0 ) - : ComboBox( pParent, nStyle ) - {} - - virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE; + virtual OUString filter(const OUString &rText) SAL_OVERRIDE; }; class SwCaptionDialog : public SvxStandardDialog { Edit* m_pTextEdit; - CategoryBox* m_pCategoryBox; + ComboBox* m_pCategoryBox; + TextFilterAutoConvert m_aTextFilter; FixedText* m_pFormatText; ListBox* m_pFormatBox; //#i61007# order of captions diff --git a/sw/uiconfig/swriter/ui/insertcaption.ui b/sw/uiconfig/swriter/ui/insertcaption.ui index 30478e9..c7f19de 100644 --- a/sw/uiconfig/swriter/ui/insertcaption.ui +++ b/sw/uiconfig/swriter/ui/insertcaption.ui @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.0 --> +<!-- Generated with glade 3.16.1 --> <interface> <requires lib="gtk+" version="3.0"/> + <!-- interface-requires LibreOffice 1.0 --> <object class="GtkDialog" id="InsertCaptionDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -217,11 +218,15 @@ </packing> </child> <child> - <object class="swuilo-CategoryBox" id="category"> + <object class="GtkComboBoxText" id="category"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="entry_text_column">0</property> - <property name="id_column">1</property> + <property name="has_entry">True</property> + <child internal-child="entry"> + <object class="GtkEntry" id="comboboxtext-entry"> + <property name="can_focus">False</property> + </object> + </child> </object> <packing> <property name="left_attach">1</property> commit fc2a0de9368db335f03461d76491d7fd733697e8 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jun 16 15:08:31 2014 +0100 turn the no-space edit widgets into a editwidget feature especially because most of them don't handle intercepting text getting *pasted* into them right, so start with the one which does that right. Change-Id: If6770798872ed3c72c469656ebf0d4fd76d2171d diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 843df8c..fc0cd80 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 e0d9689..391e825 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 677dc2b..db58caf 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 24ffa27..6cfe916 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 fa6800b..207d8f4 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 582c3b8..d32fd6e 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 4009ead..c20a5b2 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 00d71fd..919a8dd 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 c34dee5..b565b71 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 ce47d8d..d61de33 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 7d41baf..81d3144 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 7ab0258..f8d207a 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 fab9878..d6a3463 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 754ee70..6eba268 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 fda9dd7..88423f4 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 8e98a39..d162def 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 f117e3f..37f6502 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(); commit 4e4a350dff08ef1393cd87d48e095e18bf423821 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jun 16 13:54:14 2014 +0100 we can shrink the NoSpaceEdit down further Change-Id: I0ebb18a8ad2fec70ced535200139e5cd34822c84 diff --git a/sw/source/uibase/cctrl/actctrl.cxx b/sw/source/uibase/cctrl/actctrl.cxx index eb5fe93..4009ead 100644 --- a/sw/source/uibase/cctrl/actctrl.cxx +++ b/sw/source/uibase/cctrl/actctrl.cxx @@ -54,23 +54,6 @@ NoSpaceEdit::NoSpaceEdit(Window* pParent) { } -NoSpaceEdit::~NoSpaceEdit() -{ -} - -void NoSpaceEdit::KeyInput(const KeyEvent& rEvt) -{ - bool bCallParent = true; - if(rEvt.GetCharCode()) - { - OUString sKey(rEvt.GetCharCode()); - if( -1 != sForbiddenChars.indexOf(sKey)) - bCallParent = false; - } - if(bCallParent) - Edit::KeyInput(rEvt); -} - void NoSpaceEdit::Modify() { Selection aSel = GetSelection(); diff --git a/sw/source/uibase/inc/actctrl.hxx b/sw/source/uibase/inc/actctrl.hxx index 0ff4737..00d71fd 100644 --- a/sw/source/uibase/inc/actctrl.hxx +++ b/sw/source/uibase/inc/actctrl.hxx @@ -43,12 +43,10 @@ class SW_DLLPUBLIC NoSpaceEdit : public Edit { OUString sForbiddenChars; protected: - virtual void KeyInput( const KeyEvent& ) SAL_OVERRIDE; - virtual void Modify() SAL_OVERRIDE; + virtual void Modify() SAL_OVERRIDE; public: NoSpaceEdit( Window* pParent ); - virtual ~NoSpaceEdit(); void SetForbiddenChars(const OUString& rSet){sForbiddenChars = rSet;} const OUString& GetForbiddenChars(){return sForbiddenChars;} }; commit 564b8d8ed5243b95772194da33334ad72acf9594 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jun 16 15:59:11 2014 +0100 coverity#983629 Uncaught exception Change-Id: Ie3f8a0a04c136a5ed68486aa5e31284556805510 diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 86a4f15..259d061 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -1016,7 +1016,7 @@ void ODatabaseDocument::impl_throwIOExceptionCausedBySave_throw( const Any& i_rE } void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comphelper::NamedValueCollection& _rArguments, - const StoreType _eType, DocumentGuard& _rGuard ) throw ( IOException, RuntimeException ) + const StoreType _eType, DocumentGuard& _rGuard ) throw (IOException, RuntimeException, std::exception) { OSL_PRECOND( ( _eType == SAVE ) || ( _eType == SAVE_AS ), "ODatabaseDocument::impl_storeAs_throw: you introduced a new type which cannot be handled here!" ); diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx index bd5f946..84c1131 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.hxx +++ b/dbaccess/source/core/dataaccess/databasedocument.hxx @@ -221,8 +221,9 @@ class ODatabaseDocument :public ModelDependentComponent // ModelDepe const StoreType _eType, DocumentGuard& _rGuard ) - throw ( ::com::sun::star::io::IOException - , ::com::sun::star::uno::RuntimeException ); + throw (css::io::IOException, + css::uno::RuntimeException, + std::exception); /** notifies our storage change listeners that our underlying storage changed
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits