use insert function instead of for loop
[LibreOffice.git] / desktop / source / deployment / gui / dp_gui_theextmgr.hxx
blob13c329d6d142013cae252a99d3d2c9188f6fc2a1
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 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <cppuhelper/implbase.hxx>
24 #include <com/sun/star/container/XNameAccess.hpp>
25 #include <com/sun/star/deployment/XExtensionManager.hpp>
26 #include <com/sun/star/frame/XDesktop2.hpp>
27 #include <com/sun/star/frame/XTerminateListener.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <com/sun/star/util/XModifyListener.hpp>
31 #include "dp_gui.h"
32 #include "dp_gui_dialog2.hxx"
35 namespace dp_gui {
38 class ExtensionCmdQueue;
41 class TheExtensionManager :
42 public ::cppu::WeakImplHelper< css::frame::XTerminateListener,
43 css::util::XModifyListener >
45 private:
46 css::uno::Reference< css::uno::XComponentContext > m_xContext;
47 css::uno::Reference< css::frame::XDesktop2 > m_xDesktop;
48 css::uno::Reference< css::deployment::XExtensionManager > m_xExtensionManager;
49 css::uno::Reference< css::container::XNameAccess > m_xNameAccessNodes;
50 css::uno::Reference< css::awt::XWindow > m_xParent;
51 std::shared_ptr<ExtMgrDialog> m_xExtMgrDialog;
52 std::unique_ptr<UpdateRequiredDialog> m_xUpdReqDialog;
53 std::unique_ptr<ExtensionCmdQueue> m_xExecuteCmdQueue;
55 OUString m_sGetExtensionsURL;
56 bool m_bModified;
57 bool m_bExtMgrDialogExecuting;
59 public:
60 static ::rtl::Reference<TheExtensionManager> s_ExtMgr;
62 TheExtensionManager( css::uno::Reference< css::awt::XWindow > xParent,
63 const css::uno::Reference< css::uno::XComponentContext > &xContext );
64 virtual ~TheExtensionManager() override;
66 void createDialog( const bool bCreateUpdDlg );
67 sal_Int16 execute();
69 bool isModified() const { return m_bModified; }
70 void clearModified() { m_bModified = false; }
72 weld::Window* getDialog()
74 if (m_xExtMgrDialog)
75 return m_xExtMgrDialog->getDialog();
76 if (m_xUpdReqDialog)
77 return m_xUpdReqDialog->getDialog();
78 return nullptr;
80 DialogHelper* getDialogHelper()
82 if (m_xExtMgrDialog)
83 return m_xExtMgrDialog.get();
84 return m_xUpdReqDialog.get();
86 ExtensionCmdQueue* getCmdQueue() const { return m_xExecuteCmdQueue.get(); }
88 void SetText( const OUString &rTitle );
89 void Show();
90 void ToTop();
91 void Close();
92 bool isVisible();
95 void checkUpdates();
96 bool installPackage( const OUString &rPackageURL, bool bWarnUser = false );
97 void createPackageList();
99 void terminateDialog();
101 // Tools
102 bool supportsOptions( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const;
103 static PackageState getPackageState( const css::uno::Reference< css::deployment::XPackage > &xPackage );
104 const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_xContext; }
105 const css::uno::Reference< css::deployment::XExtensionManager >& getExtensionManager() const { return m_xExtensionManager; }
106 bool isReadOnly( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const;
109 static ::rtl::Reference<TheExtensionManager> get(
110 css::uno::Reference< css::uno::XComponentContext> const & xContext,
111 css::uno::Reference< css::awt::XWindow> const & xParent = nullptr,
112 OUString const & view = OUString() );
114 // XEventListener
115 virtual void SAL_CALL disposing( css::lang::EventObject const & evt ) override;
117 // XTerminateListener
118 virtual void SAL_CALL queryTermination( css::lang::EventObject const & evt ) override;
119 virtual void SAL_CALL notifyTermination( css::lang::EventObject const & evt ) override;
121 // XModifyListener
122 virtual void SAL_CALL modified( css::lang::EventObject const & evt ) override;
125 } // namespace dp_gui
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */