Kaydet (Commit) 49d53fa8 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

TSCP: limit the input to the IPPart entry field

Limit the input keys to the IPPart entry field. The limit is by
default set to free-form with the configuration key. When the
limitation is activated it is only possible to input chars '/',
';', ' ' (space) and delete.

Change-Id: Id3eb7e0198fb60e07894d6ff22a32351cca9d589
Reviewed-on: https://gerrit.libreoffice.org/44280Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 40918d03
...@@ -677,8 +677,12 @@ ...@@ -677,8 +677,12 @@
generic-name="Text View" parent="GtkTextView" generic-name="Text View" parent="GtkTextView"
icon-name="widget-gtk-textentry"/> icon-name="widget-gtk-textentry"/>
<glade-widget-class title="Text View" name="svxlo-ClassificationEditView" <glade-widget-class title="Classifcation Text View" name="svxlo-ClassificationEditView"
generic-name="Text View" parent="GtkTextView" generic-name="Classifcation Text View" parent="GtkTextView"
icon-name="widget-gtk-textentry"/>
<glade-widget-class title="IntellectualPropertyPartEdit" name="svxlo-IntellectualPropertyPartEdit"
generic-name="IntellectualPropertyPartEdit" parent="GtkEntry"
icon-name="widget-gtk-textentry"/> icon-name="widget-gtk-textentry"/>
<glade-widget-class title="Combo Image Button" name="sclo-ScExtIButton" <glade-widget-class title="Combo Image Button" name="sclo-ScExtIButton"
......
...@@ -25,6 +25,15 @@ ...@@ -25,6 +25,15 @@
namespace svx { namespace svx {
class IntellectualPropertyPartEdit : public Edit
{
public:
IntellectualPropertyPartEdit(vcl::Window* pParent);
protected:
virtual void KeyInput(const KeyEvent &rKEvt) override;
};
class SVX_DLLPUBLIC ClassificationDialog : public ModalDialog class SVX_DLLPUBLIC ClassificationDialog : public ModalDialog
{ {
private: private:
...@@ -39,7 +48,7 @@ private: ...@@ -39,7 +48,7 @@ private:
VclPtr<ListBox> m_pIntellectualPropertyPartListBox; VclPtr<ListBox> m_pIntellectualPropertyPartListBox;
VclPtr<ListBox> m_pIntellectualPropertyPartNumberListBox; VclPtr<ListBox> m_pIntellectualPropertyPartNumberListBox;
VclPtr<PushButton> m_pIntellectualPropertyPartAddButton; VclPtr<PushButton> m_pIntellectualPropertyPartAddButton;
VclPtr<Edit> m_pIntellectualPropertyPartEdit; VclPtr<IntellectualPropertyPartEdit> m_pIntellectualPropertyPartEdit;
VclPtr<VclExpander> m_pIntellectualPropertyExpander; VclPtr<VclExpander> m_pIntellectualPropertyExpander;
SfxClassificationHelper maHelper; SfxClassificationHelper maHelper;
......
...@@ -541,5 +541,7 @@ ...@@ -541,5 +541,7 @@
</prop> </prop>
<prop oor:name="AdvancedClassificationDialogIntellectualPropertySectionExpanded" oor:type="xs:boolean"> <prop oor:name="AdvancedClassificationDialogIntellectualPropertySectionExpanded" oor:type="xs:boolean">
</prop> </prop>
<prop oor:name="AdvancedClassificationDialogIntellectualPropertyTextInputIsFreeForm" oor:type="xs:boolean">
</prop>
</node> </node>
</oor:component-data> </oor:component-data>
...@@ -6399,6 +6399,12 @@ ...@@ -6399,6 +6399,12 @@
</info> </info>
<value>true</value> <value>true</value>
</prop> </prop>
<prop oor:name="AdvancedClassificationDialogIntellectualPropertyTextInputIsFreeForm" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies if the intellectual property text is free-form or limited to ';', '/' and ' ' characters.</desc>
</info>
<value>true</value>
</prop>
</group> </group>
</component> </component>
</oor:component-schema> </oor:component-schema>
...@@ -25,11 +25,55 @@ ...@@ -25,11 +25,55 @@
#include <config_folders.h> #include <config_folders.h>
#include <tools/XmlWriter.hxx> #include <tools/XmlWriter.hxx>
#include <tools/XmlWalker.hxx> #include <tools/XmlWalker.hxx>
#include <vcl/builderfactory.hxx>
#include <officecfg/Office/Common.hxx> #include <officecfg/Office/Common.hxx>
namespace svx { namespace svx {
IntellectualPropertyPartEdit::IntellectualPropertyPartEdit(vcl::Window* pParent)
: Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK|WB_TABSTOP)
{
}
VCL_BUILDER_FACTORY(IntellectualPropertyPartEdit)
void IntellectualPropertyPartEdit::KeyInput(const KeyEvent& rKeyEvent)
{
bool bTextIsFreeForm = officecfg::Office::Common::Classification::AdvancedClassificationDialogIntellectualPropertyTextInputIsFreeForm::get();
if (bTextIsFreeForm)
{
Edit::KeyInput(rKeyEvent);
}
else
{
// Ignore key combination with modifier keys
if (rKeyEvent.GetKeyCode().IsMod3()
|| rKeyEvent.GetKeyCode().IsMod2()
|| rKeyEvent.GetKeyCode().IsMod1())
{
return;
}
switch (rKeyEvent.GetKeyCode().GetCode())
{
// Allowed characters
case KEY_BACKSPACE:
case KEY_DELETE:
case KEY_DIVIDE:
case KEY_SEMICOLON:
case KEY_SPACE:
Edit::KeyInput(rKeyEvent);
return;
// Anything else is ignored
default:
break;
}
}
}
namespace { namespace {
constexpr size_t RECENTLY_USED_LIMIT = 5; constexpr size_t RECENTLY_USED_LIMIT = 5;
...@@ -51,7 +95,7 @@ bool fileExists(OUString const & sFilename) ...@@ -51,7 +95,7 @@ bool fileExists(OUString const & sFilename)
return osl::FileBase::E_None == eRC; return osl::FileBase::E_None == eRC;
} }
bool stringToclassificationType(OString const & rsType, svx::ClassificationType & reType) bool stringToClassificationType(OString const & rsType, svx::ClassificationType & reType)
{ {
if (rsType == "CATEGORY") if (rsType == "CATEGORY")
reType = svx::ClassificationType::CATEGORY; reType = svx::ClassificationType::CATEGORY;
...@@ -296,7 +340,7 @@ void ClassificationDialog::readRecentlyUsed() ...@@ -296,7 +340,7 @@ void ClassificationDialog::readRecentlyUsed()
// Convert string to classification type, but continue only if // Convert string to classification type, but continue only if
// conversion was successful. // conversion was successful.
if (stringToclassificationType(aWalker.attribute("type"), eType)) if (stringToClassificationType(aWalker.attribute("type"), eType))
{ {
aWalker.children(); aWalker.children();
...@@ -617,6 +661,6 @@ IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void) ...@@ -617,6 +661,6 @@ IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void)
} }
} }
} // end sfx2 } // end svx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="intellectualPropertyPartEntry"> <object class="svxlo-IntellectualPropertyPartEdit" id="intellectualPropertyPartEntry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
</object> </object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment