tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / cui / source / inc / AdditionsDialog.hxx
blobf94eefd3addb0bcf1c86faed3af2fc2de6ced293
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <salhelper/thread.hxx>
14 #include <rtl/ref.hxx>
15 #include <vcl/weld.hxx>
17 // Detect changes on the UI
18 #include <vcl/timer.hxx>
20 // Search and filter
21 #include <i18nutil/searchopt.hxx>
23 // Extension Manager Connection
24 #include <com/sun/star/deployment/XExtensionManager.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
28 #include <com/sun/star/ucb/XProgressHandler.hpp>
29 #include <cppuhelper/implbase.hxx>
31 #include <atomic>
33 class AdditionsDialog;
34 class SearchAndParseThread;
35 class AdditionsItem;
37 struct AdditionInfo
39 OUString sExtensionID;
40 OUString sName;
41 OUString sAuthorName;
42 OUString sExtensionURL;
43 OUString sScreenshotURL;
44 OUString sIntroduction;
45 OUString sDescription;
46 OUString sCompatibleVersion;
47 OUString sReleaseVersion;
48 OUString sLicense;
49 OUString sCommentNumber;
50 OUString sCommentURL;
51 OUString sRating;
52 OUString sDownloadNumber;
53 OUString sDownloadURL;
56 class AdditionsDialog : public weld::GenericDialogController
58 private:
59 Timer m_aSearchDataTimer;
61 DECL_LINK(GearHdl, const OUString&, void);
62 DECL_LINK(SearchUpdateHdl, weld::Entry&, void);
63 DECL_LINK(ImplUpdateDataHdl, Timer*, void);
64 DECL_LINK(FocusOut_Impl, weld::Widget&, void);
65 DECL_LINK(CloseButtonHdl, weld::Button&, void);
67 public:
68 css::uno::Reference<css::deployment::XExtensionManager> m_xExtensionManager;
69 std::unique_ptr<weld::Entry> m_xEntrySearch;
70 std::unique_ptr<weld::Button> m_xButtonClose;
71 std::vector<std::shared_ptr<AdditionsItem>> m_aAdditionsItems; // UI components
72 std::vector<AdditionInfo> m_aAllExtensionsVector; // Stores the all extensions' info
74 std::unique_ptr<weld::ScrolledWindow> m_xContentWindow;
75 std::unique_ptr<weld::Grid> m_xContentGrid;
77 std::unique_ptr<weld::Label> m_xLabelProgress;
78 std::unique_ptr<weld::MenuButton> m_xGearBtn;
80 ::rtl::Reference<SearchAndParseThread> m_pSearchThread;
82 OUString m_sURL;
83 OUString m_sTag;
84 size_t
85 m_nMaxItemCount; // Max number of item which will appear on the list before the press to the show more button.
86 size_t m_nCurrentListItemCount; // Current number of item on the list
87 i18nutil::SearchOptions2 m_searchOptions;
89 AdditionsDialog(weld::Window* pParent, const OUString& sAdditionsTag);
90 ~AdditionsDialog() override;
91 css::uno::Sequence<css::uno::Sequence<css::uno::Reference<css::deployment::XPackage>>>
92 getInstalledExtensions();
93 void SetProgress(const OUString& rProgress);
94 void ClearList();
95 void RefreshUI();
97 static bool sortByComment(const AdditionInfo& a, const AdditionInfo& b);
98 static bool sortByRating(const AdditionInfo& a, const AdditionInfo& b);
99 static bool sortByDownload(const AdditionInfo& a, const AdditionInfo& b);
102 class AdditionsItem
104 public:
105 AdditionsItem(weld::Grid* pParentGrid, AdditionsDialog* pParentDialog,
106 const AdditionInfo& additionInfo);
107 bool getExtensionFile(OUString& sExtensionFile);
109 DECL_LINK(ShowMoreHdl, weld::Button&, void);
110 DECL_LINK(InstallHdl, weld::Button&, void);
112 std::unique_ptr<weld::Builder> m_xBuilder;
113 std::unique_ptr<weld::Widget> m_xContainer;
114 std::unique_ptr<weld::Image> m_xImageScreenshot;
115 std::unique_ptr<weld::Button> m_xButtonInstall;
116 std::unique_ptr<weld::LinkButton> m_xLinkButtonWebsite;
117 std::unique_ptr<weld::Label> m_xLabelName;
118 std::unique_ptr<weld::Label> m_xLabelAuthor;
119 std::unique_ptr<weld::Label> m_xLabelDescription;
120 std::unique_ptr<weld::Label> m_xLabelLicense;
121 std::unique_ptr<weld::Label> m_xLabelVersion;
122 std::unique_ptr<weld::LinkButton> m_xLinkButtonComments;
123 std::unique_ptr<weld::Image> m_xImageVoting1;
124 std::unique_ptr<weld::Image> m_xImageVoting2;
125 std::unique_ptr<weld::Image> m_xImageVoting3;
126 std::unique_ptr<weld::Image> m_xImageVoting4;
127 std::unique_ptr<weld::Image> m_xImageVoting5;
128 std::unique_ptr<weld::Label> m_xLabelDownloadNumber;
129 std::unique_ptr<weld::Button> m_xButtonShowMore;
130 AdditionsDialog* m_pParentDialog;
131 OUString m_sDownloadURL;
132 OUString m_sExtensionID;
135 class SearchAndParseThread : public salhelper::Thread
137 private:
138 AdditionsDialog* m_pAdditionsDialog;
139 std::atomic<bool> m_bExecute;
140 bool m_bIsFirstLoading;
141 bool m_bUITest;
143 void Search();
144 void Append(AdditionInfo& additionInfo);
145 void CheckInstalledExtensions();
147 virtual ~SearchAndParseThread() override;
148 virtual void execute() override;
150 public:
151 SearchAndParseThread(AdditionsDialog* pDialog, bool bIsFirstLoading);
153 void StopExecution() { m_bExecute = false; }
156 class TmpRepositoryCommandEnv
157 : public ::cppu::WeakImplHelper<css::ucb::XCommandEnvironment, css::task::XInteractionHandler,
158 css::ucb::XProgressHandler>
160 public:
161 virtual ~TmpRepositoryCommandEnv() override;
162 TmpRepositoryCommandEnv();
164 // XCommandEnvironment
165 virtual css::uno::Reference<css::task::XInteractionHandler>
166 SAL_CALL getInteractionHandler() override;
167 virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL getProgressHandler() override;
169 // XInteractionHandler
170 virtual void SAL_CALL
171 handle(css::uno::Reference<css::task::XInteractionRequest> const& xRequest) override;
173 // XProgressHandler
174 virtual void SAL_CALL push(css::uno::Any const& Status) override;
175 virtual void SAL_CALL update(css::uno::Any const& Status) override;
176 virtual void SAL_CALL pop() override;
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */