summaryrefslogtreecommitdiff
path: root/cui/source/dialogs/AdditionsDialog.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/dialogs/AdditionsDialog.cxx')
-rw-r--r--cui/source/dialogs/AdditionsDialog.cxx48
1 files changed, 22 insertions, 26 deletions
diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx
index e1788a42b995..4d39ad937664 100644
--- a/cui/source/dialogs/AdditionsDialog.cxx
+++ b/cui/source/dialogs/AdditionsDialog.cxx
@@ -29,7 +29,7 @@
#include <rtl/bootstrap.hxx>
#include <tools/urlobj.hxx>
#include <tools/stream.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/processfactory.hxx>
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
@@ -54,18 +54,14 @@
#include <orcus/json_parser.hpp>
#include <orcus/config.hpp>
+#include <bitmaps.hlst>
+
#define PAGE_SIZE 30
using namespace css;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::XComponentContext;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::Exception;
-using ::com::sun::star::graphic::GraphicProvider;
-using ::com::sun::star::graphic::XGraphicProvider;
using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::beans::PropertyValue;
-using ::com::sun::star::graphic::XGraphic;
using namespace com::sun::star;
using namespace ::com::sun::star::uno;
@@ -134,7 +130,7 @@ void parseResponse(const std::string& rResponse, std::vector<AdditionInfo>& aAdd
{
aJsonDoc.load(rResponse, aConfig);
}
- catch (const orcus::json::parse_error&)
+ catch (const orcus::parse_error&)
{
TOOLS_WARN_EXCEPTION("cui.dialogs", "Invalid JSON file from the extensions API");
return;
@@ -229,7 +225,7 @@ bool getPreviewFile(const AdditionInfo& aAdditionInfo, OUString& sPreviewFile)
return true;
}
-void LoadImage(const OUString& rPreviewFile, std::shared_ptr<AdditionsItem> pCurrentItem)
+void LoadImage(std::u16string_view rPreviewFile, std::shared_ptr<AdditionsItem> pCurrentItem)
{
const sal_Int8 Margin = 6;
@@ -279,6 +275,11 @@ SearchAndParseThread::SearchAndParseThread(AdditionsDialog* pDialog, const bool
, m_bExecute(true)
, m_bIsFirstLoading(isFirstLoading)
{
+ // if we are running a UITest, e.g. UITest_sw_options then
+ // don't attempt to downloading anything
+ static const bool bUITest = getenv("LIBO_TEST_UNIT");
+
+ m_bUITest = bUITest;
}
SearchAndParseThread::~SearchAndParseThread() {}
@@ -288,7 +289,8 @@ void SearchAndParseThread::Append(AdditionInfo& additionInfo)
if (!m_bExecute)
return;
OUString aPreviewFile;
- bool bResult = getPreviewFile(additionInfo, aPreviewFile); // info vector json data
+ bool bResult
+ = !m_bUITest && getPreviewFile(additionInfo, aPreviewFile); // info vector json data
if (!bResult)
{
@@ -402,7 +404,7 @@ void SearchAndParseThread::execute()
if (m_bIsFirstLoading)
{
- std::string sResponse = ucbGet(m_pAdditionsDialog->m_sURL);
+ std::string sResponse = !m_bUITest ? ucbGet(m_pAdditionsDialog->m_sURL) : "";
parseResponse(sResponse, m_pAdditionsDialog->m_aAllExtensionsVector);
std::sort(m_pAdditionsDialog->m_aAllExtensionsVector.begin(),
m_pAdditionsDialog->m_aAllExtensionsVector.end(),
@@ -427,7 +429,6 @@ AdditionsDialog::AdditionsDialog(weld::Window* pParent, const OUString& sAdditio
, m_aSearchDataTimer("AdditionsDialog SearchDataTimer")
, m_xEntrySearch(m_xBuilder->weld_entry("entrySearch"))
, m_xButtonClose(m_xBuilder->weld_button("buttonClose"))
- , m_xMenuButtonSettings(m_xBuilder->weld_menu_button("buttonGear"))
, m_xContentWindow(m_xBuilder->weld_scrolled_window("contentWindow"))
, m_xContentGrid(m_xBuilder->weld_container("contentGrid"))
, m_xLabelProgress(m_xBuilder->weld_label("labelProgress"))
@@ -483,8 +484,7 @@ AdditionsDialog::AdditionsDialog(weld::Window* pParent, const OUString& sAdditio
INetURLObject::EncodeMechanism::All);
//FIXME: Temporary URL - v0 is not using actual api
- OUString rURL = "https://extensions.libreoffice.org/api/v0/" + sEncodedURLPart + ".json";
- m_sURL = rURL;
+ m_sURL = "https://extensions.libreoffice.org/api/v0/" + sEncodedURLPart + ".json";
m_xExtensionManager
= deployment::ExtensionManager::get(::comphelper::getProcessComponentContext());
@@ -604,19 +604,15 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial
, m_xLinkButtonWebsite(m_xBuilder->weld_link_button("btnWebsite"))
, m_xLabelName(m_xBuilder->weld_label("lbName"))
, m_xLabelAuthor(m_xBuilder->weld_label("labelAuthor"))
- , m_xLabelDesc(m_xBuilder->weld_label("labelDesc")) // no change (print description)
, m_xLabelDescription(m_xBuilder->weld_label("labelDescription"))
, m_xLabelLicense(m_xBuilder->weld_label("lbLicenseText"))
, m_xLabelVersion(m_xBuilder->weld_label("lbVersionText"))
- , m_xLabelComments(m_xBuilder->weld_label("labelComments")) // no change
, m_xLinkButtonComments(m_xBuilder->weld_link_button("linkButtonComments"))
, m_xImageVoting1(m_xBuilder->weld_image("imageVoting1"))
, m_xImageVoting2(m_xBuilder->weld_image("imageVoting2"))
, m_xImageVoting3(m_xBuilder->weld_image("imageVoting3"))
, m_xImageVoting4(m_xBuilder->weld_image("imageVoting4"))
, m_xImageVoting5(m_xBuilder->weld_image("imageVoting5"))
- , m_xLabelNoVoting(m_xBuilder->weld_label("votingLabel"))
- , m_xImageDownloadNumber(m_xBuilder->weld_image("imageDownloadNumber"))
, m_xLabelDownloadNumber(m_xBuilder->weld_label("labelDownloadNumber"))
, m_xButtonShowMore(m_xBuilder->weld_button("buttonShowMore"))
, m_pParentDialog(pParentDialog)
@@ -635,8 +631,8 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial
if (additionInfo.sName.getLength() > maxExtensionNameLength)
{
- OUString sShortName = additionInfo.sName.copy(0, maxExtensionNameLength - 3);
- sExtensionName = sShortName + "...";
+ std::u16string_view sShortName = additionInfo.sName.subView(0, maxExtensionNameLength - 3);
+ sExtensionName = OUString::Concat(sShortName) + "...";
}
else
{
@@ -649,19 +645,19 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial
switch (std::isnan(aExtensionRating) ? 0 : int(std::clamp(aExtensionRating, 0.0, 5.0)))
{
case 5:
- m_xImageVoting5->set_from_icon_name("cmd/sc_stars-full.png");
+ m_xImageVoting5->set_from_icon_name(RID_SVXBMP_STARS_FULL);
[[fallthrough]];
case 4:
- m_xImageVoting4->set_from_icon_name("cmd/sc_stars-full.png");
+ m_xImageVoting4->set_from_icon_name(RID_SVXBMP_STARS_FULL);
[[fallthrough]];
case 3:
- m_xImageVoting3->set_from_icon_name("cmd/sc_stars-full.png");
+ m_xImageVoting3->set_from_icon_name(RID_SVXBMP_STARS_FULL);
[[fallthrough]];
case 2:
- m_xImageVoting2->set_from_icon_name("cmd/sc_stars-full.png");
+ m_xImageVoting2->set_from_icon_name(RID_SVXBMP_STARS_FULL);
[[fallthrough]];
case 1:
- m_xImageVoting1->set_from_icon_name("cmd/sc_stars-full.png");
+ m_xImageVoting1->set_from_icon_name(RID_SVXBMP_STARS_FULL);
break;
}
@@ -851,7 +847,7 @@ void TmpRepositoryCommandEnv::update(uno::Any const& /*Status */) {}
void TmpRepositoryCommandEnv::pop() {}
-IMPL_LINK(AdditionsDialog, GearHdl, const OString&, rIdent, void)
+IMPL_LINK(AdditionsDialog, GearHdl, const OUString&, rIdent, void)
{
if (rIdent == "gear_sort_voting")
{