sw/qa/extras/tiledrendering/tiledrendering.cxx |   14 ++++++++++
 sw/source/core/crsr/bookmrk.cxx                |   32 ++++++++++++++++++++++---
 2 files changed, 43 insertions(+), 3 deletions(-)

New commits:
commit 320cba92847242cfaf34966c3fc32c4e76d45f03
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Tue May 5 14:36:16 2020 +0200
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Fri May 8 17:33:59 2020 +0200

    lok: MSForms: Send also the drop down field params to the client code.
    
    Change-Id: Id42f428b7944d97d1b61a5b60d6e0807cb51cc95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93658
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index efe714d74388..c8ecee6fa5b0 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -2599,6 +2599,20 @@ void SwTiledRenderingTest::testDropDownFormFieldButton()
 
         OString sTextArea = 
aTree.get_child("textArea").get_value<std::string>().c_str();
         CPPUNIT_ASSERT_EQUAL(OString("1538, 1418, 1026, 275"), sTextArea);
+
+        boost::property_tree::ptree aItems = 
aTree.get_child("params").get_child("items");
+        CPPUNIT_ASSERT_EQUAL(size_t(6), aItems.size());
+
+        OStringBuffer aItemList;
+        for (auto &item : aItems)
+        {
+            aItemList.append(item.second.get_value<std::string>().c_str());
+            aItemList.append(";");
+        }
+        
CPPUNIT_ASSERT_EQUAL(OString("2019/2020;2020/2021;2021/2022;2022/2023;2023/2024;2024/2025;"),
 aItemList.toString());
+
+        OString sSelected = 
aTree.get_child("params").get_child("selected").get_value<std::string>().c_str();
+        CPPUNIT_ASSERT_EQUAL(OString("1"), sSelected);
     }
 
     // Move the cursor back so the button becomes hidden.
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index a0cb5a6f7c47..6695d8a0aae6 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -43,6 +43,7 @@
 #include <view.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <wrtsh.hxx>
+#include <rtl/strbuf.hxx>
 
 using namespace ::sw::mark;
 using namespace ::com::sun::star;
@@ -722,18 +723,43 @@ namespace sw::mark
             if (!pEditWin)
                 return;
 
-            OString sPayload;
+            OStringBuffer sPayload;
             if (sAction == "show")
             {
                 sPayload = OStringLiteral("{\"action\": \"show\","
                            " \"type\": \"drop-down\", \"textArea\": \"") +
-                           m_aPortionPaintArea.SVRect().toString() + "\"}";
+                           m_aPortionPaintArea.SVRect().toString() + "\",";
+                // Add field params to the message
+                sPayload.append(" \"params\": { \"items\": [");
+
+                // List items
+                auto pParameters = this->GetParameters();
+                auto pListEntriesIter = 
pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
+                css::uno::Sequence<OUString> vListEntries;
+                if (pListEntriesIter != pParameters->end())
+                {
+                    pListEntriesIter->second >>= vListEntries;
+                    for (const OUString& sItem : std::as_const(vListEntries))
+                        sPayload.append("\"" + OUStringToOString(sItem, 
RTL_TEXTENCODING_UTF8) + "\", ");
+                    sPayload.setLength(sPayload.getLength() - 2);
+                }
+                sPayload.append("], ");
+
+                // Selected item
+                OUString sResultKey = ODF_FORMDROPDOWN_RESULT;
+                auto pSelectedItemIter = pParameters->find(sResultKey);
+                if (pSelectedItemIter != pParameters->end())
+                {
+                    sal_Int32 nSelection = -1;
+                    pSelectedItemIter->second >>= nSelection;
+                    sPayload.append("\"selected\": \"" + 
OString::number(nSelection) + "\"}}");
+                }
             }
             else
             {
                 sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
             }
-            
pEditWin->GetView().GetWrtShell().GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON,
 sPayload.getStr());
+            
pEditWin->GetView().GetWrtShell().GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON,
 sPayload.toString().getStr());
         }
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to