sw/qa/uitest/ui/misc/misc.py                |   11 ++++++
 sw/source/ui/misc/contentcontroldlg.cxx     |   26 ++++++++++++++
 sw/source/uibase/inc/contentcontroldlg.hxx  |    2 +
 sw/uiconfig/swriter/ui/contentcontroldlg.ui |   51 +++++++++++++++++++++++++++-
 4 files changed, 89 insertions(+), 1 deletion(-)

New commits:
commit 8f36736f511215deff3a7d5479f23ad58266b0bc
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Oct 19 08:44:38 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Oct 20 10:55:23 2022 +0200

    sw content controls, alias and tag: add UI
    
    - add 2 new weld::Entry instances to edit these strings + matching
      labels
    
    - extend the grid to have 2 columns, as previously only a checkbox was
      there for all content controls, which only needed a single column, but
      now we want label + entry pairs in later rows
    
    - cover this with a UITest
    
    (cherry picked from commit add110bad816fadeb96e7af0d4689389c04c263e)
    
    Change-Id: Ia5cfb90725d3b5b40eccf15ec7c7823e0e6d6751
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141545
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/uitest/ui/misc/misc.py b/sw/qa/uitest/ui/misc/misc.py
index cf4554ce9638..2b6307cefb61 100644
--- a/sw/qa/uitest/ui/misc/misc.py
+++ b/sw/qa/uitest/ui/misc/misc.py
@@ -10,6 +10,7 @@
 """Covers sw/source/ui/misc/ fixes."""
 
 from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
 from uitest.uihelper.common import type_text
 
 
@@ -23,6 +24,8 @@ class TestTmpdlg(UITestCase):
             portions = paragraph.createEnumeration()
             portion = portions.nextElement()
             contentControl = portion.ContentControl
+            contentControl.Alias = "my alias"
+            contentControl.Tag = "my tag"
             listItems = contentControl.ListItems
             self.assertEqual(len(listItems), 1)
             self.assertEqual(listItems[0][0].Name, "DisplayText")
@@ -32,6 +35,12 @@ class TestTmpdlg(UITestCase):
 
             # Append a new list item.
             with 
self.ui_test.execute_dialog_through_command(".uno:ContentControlProperties") as 
xDialog:
+                xAlias = xDialog.getChild("aliasentry")
+                self.assertEqual(get_state_as_dict(xAlias)['Text'], "my alias")
+                type_text(xAlias, "new alias ")
+                xTag = xDialog.getChild("tagentry")
+                self.assertEqual(get_state_as_dict(xTag)['Text'], "my tag")
+                type_text(xTag, "new tag ")
                 xAdd = xDialog.getChild("add")
                 with self.ui_test.execute_blocking_action(xAdd.executeAction, 
args=('CLICK', ())) as xSubDialog:
                     xDisplayName = xSubDialog.getChild("displayname")
@@ -46,6 +55,8 @@ class TestTmpdlg(UITestCase):
             self.assertEqual(listItems[1][0].Value, "Foo Bar")
             self.assertEqual(listItems[1][1].Name, "Value")
             self.assertEqual(listItems[1][1].Value, "foo-bar")
+            self.assertEqual(contentControl.Alias, "new alias my alias")
+            self.assertEqual(contentControl.Tag, "new tag my tag")
 
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/misc/contentcontroldlg.cxx 
b/sw/source/ui/misc/contentcontroldlg.cxx
index 5e4347e62afb..5770bf1bd6bd 100644
--- a/sw/source/ui/misc/contentcontroldlg.cxx
+++ b/sw/source/ui/misc/contentcontroldlg.cxx
@@ -38,6 +38,8 @@ SwContentControlDlg::SwContentControlDlg(weld::Window* 
pParent, SwWrtShell& rWrt
                           "ContentControlDialog")
     , m_rWrtShell(rWrtShell)
     , 
m_xShowingPlaceHolderCB(m_xBuilder->weld_check_button("showing_place_holder"))
+    , m_xAlias(m_xBuilder->weld_entry("aliasentry"))
+    , m_xTag(m_xBuilder->weld_entry("tagentry"))
     , m_xCheckboxFrame(m_xBuilder->weld_frame("checkboxframe"))
     , m_xCheckedState(m_xBuilder->weld_entry("checkboxcheckedentry"))
     , m_xCheckedStateBtn(m_xBuilder->weld_button("btncheckboxchecked"))
@@ -94,6 +96,18 @@ SwContentControlDlg::SwContentControlDlg(weld::Window* 
pParent, SwWrtShell& rWrt
     m_xShowingPlaceHolderCB->set_state(eShowingPlaceHolder);
     m_xShowingPlaceHolderCB->save_state();
 
+    if (!m_pContentControl->GetAlias().isEmpty())
+    {
+        m_xAlias->set_text(m_pContentControl->GetAlias());
+        m_xAlias->save_value();
+    }
+
+    if (!m_pContentControl->GetTag().isEmpty())
+    {
+        m_xTag->set_text(m_pContentControl->GetTag());
+        m_xTag->save_value();
+    }
+
     if (m_pContentControl->GetCheckbox())
     {
         m_xCheckedState->set_text(m_pContentControl->GetCheckedState());
@@ -176,6 +190,18 @@ IMPL_LINK_NOARG(SwContentControlDlg, OkHdl, weld::Button&, 
void)
         bChanged = true;
     }
 
+    if (m_xAlias->get_value_changed_from_saved())
+    {
+        m_pContentControl->SetAlias(m_xAlias->get_text());
+        bChanged = true;
+    }
+
+    if (m_xTag->get_value_changed_from_saved())
+    {
+        m_pContentControl->SetTag(m_xTag->get_text());
+        bChanged = true;
+    }
+
     if (m_xCheckedState->get_value_changed_from_saved())
     {
         m_pContentControl->SetCheckedState(m_xCheckedState->get_text());
diff --git a/sw/source/uibase/inc/contentcontroldlg.hxx 
b/sw/source/uibase/inc/contentcontroldlg.hxx
index 7654e3d6befb..df4830e7cd9f 100644
--- a/sw/source/uibase/inc/contentcontroldlg.hxx
+++ b/sw/source/uibase/inc/contentcontroldlg.hxx
@@ -37,6 +37,8 @@ class SwContentControlDlg final : public SfxDialogController
     std::vector<SwContentControlListItem> m_aSavedListItems;
 
     std::unique_ptr<weld::CheckButton> m_xShowingPlaceHolderCB;
+    std::unique_ptr<weld::Entry> m_xAlias;
+    std::unique_ptr<weld::Entry> m_xTag;
     std::unique_ptr<weld::Frame> m_xCheckboxFrame;
     std::unique_ptr<weld::Entry> m_xCheckedState;
     std::unique_ptr<weld::Button> m_xCheckedStateBtn;
diff --git a/sw/uiconfig/swriter/ui/contentcontroldlg.ui 
b/sw/uiconfig/swriter/ui/contentcontroldlg.ui
index ef6b2081426c..caf30206c961 100644
--- a/sw/uiconfig/swriter/ui/contentcontroldlg.ui
+++ b/sw/uiconfig/swriter/ui/contentcontroldlg.ui
@@ -91,7 +91,7 @@
           </packing>
         </child>
         <child>
-          <!-- n-columns=1 n-rows=1 -->
+          <!-- n-columns=2 n-rows=3 -->
           <object class="GtkGrid">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
@@ -111,6 +111,55 @@
               <packing>
                 <property name="left-attach">0</property>
                 <property name="top-attach">0</property>
+                <property name="width">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="aliaslabel">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="label" translatable="yes" 
context="contentcontroldlg|aliaslabel">Title:</property>
+                <property name="mnemonic-widget">aliasentry</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="taglabel">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="label" translatable="yes" 
context="contentcontroldlg|taglabel">Tag:</property>
+                <property name="mnemonic-widget">tagentry</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="aliasentry">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="truncate-multiline">True</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="tagentry">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="truncate-multiline">True</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">2</property>
               </packing>
             </child>
           </object>

Reply via email to