[Libreoffice-commits] core.git: extras/source include/svx officecfg/registry svx/source svx/uiconfig

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Sat Nov 4 01:50:45 UTC 2017


 extras/source/glade/libreoffice-catalog.xml.in             |    8 +-
 include/svx/ClassificationDialog.hxx                       |   11 ++
 officecfg/registry/data/org/openoffice/Office/Common.xcu   |    2 
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    6 +
 svx/source/dialog/ClassificationDialog.cxx                 |   50 ++++++++++++-
 svx/uiconfig/ui/classificationdialog.ui                    |    2 
 6 files changed, 72 insertions(+), 7 deletions(-)

New commits:
commit 49d53fa8a4d0c69a58000d05b903e757e30e6930
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sat Nov 4 02:29:33 2017 +0900

    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 at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 8fb5d4c803c7..85a65eaf3df1 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -677,8 +677,12 @@
                         generic-name="Text View" parent="GtkTextView"
                         icon-name="widget-gtk-textentry"/>
 
-    <glade-widget-class title="Text View" name="svxlo-ClassificationEditView"
-                        generic-name="Text View" parent="GtkTextView"
+    <glade-widget-class title="Classifcation Text View" name="svxlo-ClassificationEditView"
+                        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"/>
 
     <glade-widget-class title="Combo Image Button" name="sclo-ScExtIButton"
diff --git a/include/svx/ClassificationDialog.hxx b/include/svx/ClassificationDialog.hxx
index 59502eca4286..164701d2c3a4 100644
--- a/include/svx/ClassificationDialog.hxx
+++ b/include/svx/ClassificationDialog.hxx
@@ -25,6 +25,15 @@
 
 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
 {
 private:
@@ -39,7 +48,7 @@ private:
     VclPtr<ListBox> m_pIntellectualPropertyPartListBox;
     VclPtr<ListBox> m_pIntellectualPropertyPartNumberListBox;
     VclPtr<PushButton> m_pIntellectualPropertyPartAddButton;
-    VclPtr<Edit> m_pIntellectualPropertyPartEdit;
+    VclPtr<IntellectualPropertyPartEdit> m_pIntellectualPropertyPartEdit;
     VclPtr<VclExpander> m_pIntellectualPropertyExpander;
 
     SfxClassificationHelper maHelper;
diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu
index c6bbd2d46058..33c1db97f618 100644
--- a/officecfg/registry/data/org/openoffice/Office/Common.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu
@@ -541,5 +541,7 @@
       </prop>
       <prop oor:name="AdvancedClassificationDialogIntellectualPropertySectionExpanded" oor:type="xs:boolean">
       </prop>
+      <prop oor:name="AdvancedClassificationDialogIntellectualPropertyTextInputIsFreeForm" oor:type="xs:boolean">
+      </prop>
   </node>
 </oor:component-data>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index fe7f8e806a7b..22c92a7124fa 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -6399,6 +6399,12 @@
         </info>
         <value>true</value>
       </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>
   </component>
 </oor:component-schema>
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>


More information about the Libreoffice-commits mailing list