summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-11-04 02:29:33 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-11-04 02:50:14 +0100
commit49d53fa8a4d0c69a58000d05b903e757e30e6930 (patch)
tree071baed9285e3d0549d19af8c0ff72245ac2bb77 /svx
parent40918d0321f9e9a958fa80f309213e199cf21bce (diff)
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/44280 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/dialog/ClassificationDialog.cxx50
-rw-r--r--svx/uiconfig/ui/classificationdialog.ui2
2 files changed, 48 insertions, 4 deletions
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index 2e8b0c4ad8fc..6c70d97dd83f 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -25,11 +25,55 @@
#include <config_folders.h>
#include <tools/XmlWriter.hxx>
#include <tools/XmlWalker.hxx>
+#include <vcl/builderfactory.hxx>
#include <officecfg/Office/Common.hxx>
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 {
constexpr size_t RECENTLY_USED_LIMIT = 5;
@@ -51,7 +95,7 @@ bool fileExists(OUString const & sFilename)
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")
reType = svx::ClassificationType::CATEGORY;
@@ -296,7 +340,7 @@ void ClassificationDialog::readRecentlyUsed()
// Convert string to classification type, but continue only if
// conversion was successful.
- if (stringToclassificationType(aWalker.attribute("type"), eType))
+ if (stringToClassificationType(aWalker.attribute("type"), eType))
{
aWalker.children();
@@ -617,6 +661,6 @@ IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void)
}
}
-} // end sfx2
+} // end svx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/uiconfig/ui/classificationdialog.ui b/svx/uiconfig/ui/classificationdialog.ui
index b953c003e0ec..40464427568a 100644
--- a/svx/uiconfig/ui/classificationdialog.ui
+++ b/svx/uiconfig/ui/classificationdialog.ui
@@ -294,7 +294,7 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="intellectualPropertyPartEntry">
+ <object class="svxlo-IntellectualPropertyPartEdit" id="intellectualPropertyPartEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>