cui/inc/strings.hrc                    |    2 +-
 cui/source/dialogs/AdditionsDialog.cxx |   26 ++++++++++++++++++++------
 cui/source/factory/dlgfact.cxx         |    6 +++---
 cui/source/factory/dlgfact.hxx         |    2 +-
 cui/source/inc/AdditionsDialog.hxx     |    3 ++-
 include/sfx2/sfxsids.hrc               |    1 +
 include/vcl/abstdlg.hxx                |    2 +-
 sc/source/ui/view/tabvwshb.cxx         |   21 ++++++++++++++-------
 sd/source/ui/view/drviews2.cxx         |    8 +++++++-
 sfx2/sdi/sfx.sdi                       |    2 +-
 sfx2/source/appl/appuno.cxx            |    1 +
 sw/source/uibase/uiview/viewdlg2.cxx   |   10 +++++++++-
 12 files changed, 61 insertions(+), 23 deletions(-)

New commits:
commit 6e50e03262aa12921f108b502d3c76ce983d54f1
Author:     Yusuf Keten <ketenyu...@gmail.com>
AuthorDate: Sun Jul 19 20:22:23 2020 +0300
Commit:     Muhammet Kara <muhammet.k...@collabora.com>
CommitDate: Tue Jul 21 22:25:13 2020 +0200

    tdf#133026: Additions - Parameter support to UNO Command
    
    After this patch, parameter support to uno command(.uno:AdditionsDialog) 
will be available.
    To use parameter, add "?AdditionsTag:string=YourParameter" to UNO command. 
Parameters are the tags of extensions on webpage.
    
    Change-Id: I0072c7340bda14ee13c21c347e06a04545cba69a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99007
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.k...@collabora.com>

diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index be9c3f7d3a3e..d1b39a67e541 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -398,7 +398,7 @@
 #define RID_SVXSTR_ADDITIONS_SEARCHING              
NC_("RID_SVXSTR_ADDITIONS_SEARCHING", "Searching...")
 #define RID_SVXSTR_ADDITIONS_LOADING                
NC_("RID_SVXSTR_ADDITIONS_LOADING", "Loading...")
 #define RID_SVXSTR_ADDITIONS_NORESULTS              
NC_("ID_SVXSTR_ADDITIONS_NORESULTS", "No results found")
-
+#define RID_SVXSTR_ADDITIONS_DIALOG_TITLE_PREFIX    
NC_("RID_SVXSTR_ADDITIONS_DIALOG_TITLE_PREFIX", "Extensions")
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/AdditionsDialog.cxx 
b/cui/source/dialogs/AdditionsDialog.cxx
index 73b0247b8b0a..975fa57415fd 100644
--- a/cui/source/dialogs/AdditionsDialog.cxx
+++ b/cui/source/dialogs/AdditionsDialog.cxx
@@ -207,7 +207,7 @@ void parseResponse(const std::string& rResponse, 
std::vector<AdditionInfo>& aAdd
                                   RTL_TEXTENCODING_UTF8),
                 
OStringToOUString(OString(arrayElement.child("author").string_value().get()),
                                   RTL_TEXTENCODING_UTF8),
-                
OStringToOUString(OString(arrayElement.child("URL").string_value().get()),
+                
OStringToOUString(OString(arrayElement.child("url").string_value().get()),
                                   RTL_TEXTENCODING_UTF8),
                 
OStringToOUString(OString(arrayElement.child("screenshotURL").string_value().get()),
                                   RTL_TEXTENCODING_UTF8),
@@ -219,13 +219,13 @@ void parseResponse(const std::string& rResponse, 
std::vector<AdditionInfo>& aAdd
                     RTL_TEXTENCODING_UTF8),
                 OStringToOUString(OString(arrayElement.child("releases")
                                               .child(0)
-                                              .child("compatibleVersion")
+                                              .child("compatibility")
                                               .string_value()
                                               .get()),
                                   RTL_TEXTENCODING_UTF8),
                 OStringToOUString(OString(arrayElement.child("releases")
                                               .child(0)
-                                              .child("releaseNumber")
+                                              .child("releaseName")
                                               .string_value()
                                               .get()),
                                   RTL_TEXTENCODING_UTF8),
@@ -414,7 +414,7 @@ void SearchAndParseThread::execute()
     m_pAdditionsDialog->SetProgress(sProgress);
 }
 
-AdditionsDialog::AdditionsDialog(weld::Window* pParent)
+AdditionsDialog::AdditionsDialog(weld::Window* pParent, const OUString& 
sAdditionsTag)
     : GenericDialogController(pParent, "cui/ui/additionsdialog.ui", 
"AdditionsDialog")
     , m_aSearchDataTimer("SearchDataTimer")
     , m_xEntrySearch(m_xBuilder->weld_entry("entrySearch"))
@@ -430,8 +430,22 @@ AdditionsDialog::AdditionsDialog(weld::Window* pParent)
     m_xEntrySearch->connect_changed(LINK(this, AdditionsDialog, 
SearchUpdateHdl));
     m_xEntrySearch->connect_focus_out(LINK(this, AdditionsDialog, 
FocusOut_Impl));
 
-    // TODO - Temporary URL
-    OString rURL = "https://yusufketen.com/extensionTest.json";;
+    m_sTag = OUStringToOString(sAdditionsTag, RTL_TEXTENCODING_UTF8);
+
+    OUString titlePrefix = CuiResId(RID_SVXSTR_ADDITIONS_DIALOG_TITLE_PREFIX);
+    if (!m_sTag.isEmpty())
+    {
+        this->set_title(titlePrefix + ": " + sAdditionsTag);
+    }
+    else
+    {
+        this->set_title(titlePrefix);
+        m_sTag = "allextensions"; // Means empty parameter
+    }
+    //FIXME: Temporary URL
+    OString sPrefixURL = "https://yusufketen.com/api/";;
+    OString sSuffixURL = ".json";
+    OString rURL = sPrefixURL + m_sTag + sSuffixURL;
 
     m_pSearchThread
         = new SearchAndParseThread(this, OStringToOUString(rURL, 
RTL_TEXTENCODING_UTF8), true);
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index a31e987202eb..d1cd0a14c9f5 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1684,14 +1684,14 @@ VclPtr<AbstractQrCodeGenDialog> 
AbstractDialogFactory_Impl::CreateQrCodeGenDialo
 }
 
 VclPtr<AbstractAdditionsDialog> 
AbstractDialogFactory_Impl::CreateAdditionsDialog(
-    weld::Window* pParent)
+    weld::Window* pParent, const OUString& sAdditionsTag)
 {
 #if HAVE_FEATURE_EXTENSIONS
     return VclPtr<AbstractAdditionsDialog_Impl>::Create(
-        std::make_unique<AdditionsDialog>(pParent));
+        std::make_unique<AdditionsDialog>(pParent, sAdditionsTag));
 #else
     (void) pParent;
-    return VclPtr<AbstractAdditionsDialog>(nullptr);
+    return VclPtr<AbstractAdditionsDialog>(nullptr, sAdditionsTag);
 #endif
 }
 
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 3c0655f30c08..cc4f90bd82ea 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -982,7 +982,7 @@ public:
                               const css::uno::Reference<css::frame::XModel> 
xModel, bool bEditExisting) override;
 
     virtual VclPtr<AbstractAdditionsDialog>
-    CreateAdditionsDialog(weld::Window* pParent) override;
+    CreateAdditionsDialog(weld::Window* pParent, const OUString& 
sAdditionsTag) override;
 
     virtual VclPtr<AbstractAboutDialog> CreateAboutDialog(weld::Window* 
pParent) override;
 
diff --git a/cui/source/inc/AdditionsDialog.hxx 
b/cui/source/inc/AdditionsDialog.hxx
index 7983c1a0438a..be73c78d96d0 100644
--- a/cui/source/inc/AdditionsDialog.hxx
+++ b/cui/source/inc/AdditionsDialog.hxx
@@ -75,7 +75,8 @@ public:
     std::unique_ptr<weld::Label> m_xLabelProgress;
     ::rtl::Reference<SearchAndParseThread> m_pSearchThread;
 
-    AdditionsDialog(weld::Window* pParent);
+    OString m_sTag;
+    AdditionsDialog(weld::Window* pParent, const OUString& sAdditionsTag);
     ~AdditionsDialog() override;
 
     void SetProgress(const OUString& rProgress);
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 23d7382f062d..91c69e467654 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -271,6 +271,7 @@ class SvxSearchItem;
 #define SID_LOCK_EDITDOC                    (SID_SFX_START + 1738)
 #define SID_REPLACEABLE                     (SID_SFX_START + 1739)
 #define SID_ADDITIONS_DIALOG                (SID_SFX_START + 1740)
+#define SID_ADDITIONS_TAG                   (SID_SFX_START + 1741)
 
 //      SID_SFX_free_END                    (SID_SFX_START + 3999)
 
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index 862aa973f2bc..8f8c334118fd 100644
--- a/include/vcl/abstdlg.hxx
+++ b/include/vcl/abstdlg.hxx
@@ -191,7 +191,7 @@ public:
 
     // create additions dialog
     virtual VclPtr<AbstractAdditionsDialog>
-        CreateAdditionsDialog(weld::Window* pParent) = 0;
+        CreateAdditionsDialog(weld::Window* pParent, const OUString& 
sAdditionsTag) = 0;
 
     // create info dialog to show tip-of-the-day
     virtual VclPtr<AbstractTipOfTheDayDialog>
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 01f91d325a2a..7f0542420d39 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -42,6 +42,7 @@
 #include <sfx2/viewfrm.hxx>
 #include <svtools/soerr.hxx>
 #include <svl/rectitem.hxx>
+#include <svl/stritem.hxx>
 #include <svl/slstitm.hxx>
 #include <svl/whiter.hxx>
 #include <unotools/moduleoptions.hxx>
@@ -413,16 +414,22 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                 break;
             }
 
-        case SID_ADDITIONS_DIALOG:
+            case SID_ADDITIONS_DIALOG:
             {
-            VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
-            ScopedVclPtr<AbstractAdditionsDialog> pDialog(
-                pFact->CreateAdditionsDialog(pWin->GetFrameWeld()));
-            pDialog->Execute();
-            break;
+                OUString sAdditionsTag = "";
+
+                const SfxStringItem* pStringArg = 
rReq.GetArg<SfxStringItem>(SID_ADDITIONS_TAG);
+                if (pStringArg)
+                    sAdditionsTag = pStringArg->GetValue();
+
+                VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
+                ScopedVclPtr<AbstractAdditionsDialog> pDialog(
+                    pFact->CreateAdditionsDialog(pWin->GetFrameWeld(), 
sAdditionsTag));
+                pDialog->Execute();
+                break;
             }
 
-        case SID_OBJECTRESIZE:
+            case SID_OBJECTRESIZE:
             {
                 //         the server would like to change the client size
 
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 322829ac152a..8bd95fb43ce8 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -3492,9 +3492,15 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_ADDITIONS_DIALOG:
         {
+            OUString sAdditionsTag = "";
+
+            const SfxStringItem* pStringArg = 
rReq.GetArg<SfxStringItem>(SID_ADDITIONS_TAG);
+            if (pStringArg)
+                sAdditionsTag = pStringArg->GetValue();
+
             VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
             ScopedVclPtr<AbstractAdditionsDialog> pDlg(
-                pFact->CreateAdditionsDialog(GetFrameWeld()));
+                pFact->CreateAdditionsDialog(GetFrameWeld(), sAdditionsTag));
             pDlg->Execute();
             Cancel();
             rReq.Ignore ();
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 19a60a227460..888a0e4b41da 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -5626,7 +5626,7 @@ SfxVoidItem UnicodeNotationToggle 
SID_UNICODE_NOTATION_TOGGLE
 ]
 
 SfxVoidItem AdditionsDialog SID_ADDITIONS_DIALOG
-()
+(SfxStringItem AdditionsTag SID_ADDITIONS_TAG)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 7f0617a66c67..da8d333c935b 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -90,6 +90,7 @@ SfxFormalArgument const aFormalArgs[] = {
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoEmbDataSet", 
SID_NO_EMBEDDED_DS },
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "IsRedactMode", 
SID_IS_REDACT_MODE },
     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "RedactionStyle", 
SID_REDACTION_STYLE },
+    { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "AdditionsTag", 
SID_ADDITIONS_TAG },
 };
 
 sal_uInt16 const nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
diff --git a/sw/source/uibase/uiview/viewdlg2.cxx 
b/sw/source/uibase/uiview/viewdlg2.cxx
index b993aa555046..ff0c3764f6e4 100644
--- a/sw/source/uibase/uiview/viewdlg2.cxx
+++ b/sw/source/uibase/uiview/viewdlg2.cxx
@@ -41,6 +41,8 @@
 
 #include <memory>
 
+#include <svl/stritem.hxx>
+
 using namespace css;
 
 void SwView::ExecDlgExt(SfxRequest const &rReq)
@@ -76,9 +78,15 @@ void SwView::ExecDlgExt(SfxRequest const &rReq)
         }
         case SID_ADDITIONS_DIALOG:
         {
+            OUString sAdditionsTag = "";
+
+            const SfxStringItem* pStringArg = 
rReq.GetArg<SfxStringItem>(SID_ADDITIONS_TAG);
+            if (pStringArg)
+                sAdditionsTag = pStringArg->GetValue();
+
             VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
             ScopedVclPtr<AbstractAdditionsDialog> pDialog(
-                pFact->CreateAdditionsDialog(GetFrameWeld()));
+                pFact->CreateAdditionsDialog(GetFrameWeld(), sAdditionsTag));
             pDialog->Execute();
             break;
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to