summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-06-16 15:57:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-06-16 16:59:09 +0100
commit46650cb7c3ed3d48d8fe7b6c6dd6d7357b698afb (patch)
tree1a49659ab9d89a0ae91fc6d8b159e5e7ae04057b
parentfc2a0de9368db335f03461d76491d7fd733697e8 (diff)
Related: fdo#47427 disallow pasting spaces into category box
Change-Id: I4caf4b2ac028629c6ecbd42084346623192df09e
-rw-r--r--extras/source/glade/libreoffice-catalog.xml.in3
-rw-r--r--sw/source/ui/frmdlg/cption.cxx47
-rw-r--r--sw/source/uibase/inc/cption.hxx13
-rw-r--r--sw/uiconfig/swriter/ui/insertcaption.ui13
4 files changed, 25 insertions, 51 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index fc0cd803ea33..7d17202e1933 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 1526eb10bafb..ec81b01e9f71 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 98781e10efb8..0c1787f1d0b4 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 30478e94db18..c7f19dedddb0 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>