1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_DP_GUI_THEEXTMGR_HXX 25 #define INCLUDED_DP_GUI_THEEXTMGR_HXX 26 27 #include "comphelper/sequence.hxx" 28 29 #include "cppuhelper/implbase2.hxx" 30 31 #include "com/sun/star/container/XNameAccess.hpp" 32 #include "com/sun/star/deployment/XExtensionManager.hpp" 33 #include "com/sun/star/deployment/ExtensionManager.hpp" 34 #include "com/sun/star/frame/XDesktop.hpp" 35 #include "com/sun/star/frame/XTerminateListener.hpp" 36 #include "com/sun/star/uno/XComponentContext.hpp" 37 #include "com/sun/star/util/XModifyListener.hpp" 38 39 #include "dp_gui.h" 40 #include "dp_gui_dialog2.hxx" 41 #include "dp_gui_updatedata.hxx" 42 43 //============================================================================== 44 namespace dp_gui { 45 46 //------------------------------------------------------------------------------ 47 class ExtensionCmdQueue; 48 49 //------------------------------------------------------------------------------ 50 class TheExtensionManager : 51 public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XTerminateListener, 52 ::com::sun::star::util::XModifyListener > 53 { 54 private: 55 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 56 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop; 57 ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; 58 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; 59 60 Window *m_pParent; 61 ExtMgrDialog *m_pExtMgrDialog; 62 UpdateRequiredDialog *m_pUpdReqDialog; 63 ExtensionCmdQueue *m_pExecuteCmdQueue; 64 65 ::rtl::OUString m_sGetExtensionsURL; 66 67 void createPackageList(); 68 69 public: 70 static ::rtl::Reference<TheExtensionManager> s_ExtMgr; 71 72 TheExtensionManager( Window * pParent, 73 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext ); 74 ~TheExtensionManager(); 75 76 void createDialog( const bool bCreateUpdDlg ); 77 sal_Int16 execute(); 78 getDialog()79 Dialog* getDialog() { return m_pExtMgrDialog ? (Dialog*) m_pExtMgrDialog : (Dialog*) m_pUpdReqDialog; } getDialogHelper()80 DialogHelper* getDialogHelper() { return m_pExtMgrDialog ? (DialogHelper*) m_pExtMgrDialog : (DialogHelper*) m_pUpdReqDialog; } getCmdQueue() const81 ExtensionCmdQueue* getCmdQueue() const { return m_pExecuteCmdQueue; } 82 83 void SetText( const ::rtl::OUString &rTitle ); 84 void Show(); 85 void ToTop( sal_uInt16 nFlags ); 86 bool Close(); 87 bool isVisible(); 88 89 //----------------- 90 bool checkUpdates( bool showUpdateOnly, bool parentVisible ); 91 bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false ); 92 93 bool queryTermination(); 94 void terminateDialog(); 95 96 // Tools 97 bool supportsOptions( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; 98 PackageState getPackageState( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; getContext() const99 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } getExtensionManager() const100 ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; } 101 bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; 102 103 //----------------- 104 static ::rtl::Reference<TheExtensionManager> get( 105 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xContext, 106 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> const & xParent = 0, 107 ::rtl::OUString const & view = ::rtl::OUString() ); 108 109 // XEventListener 110 virtual void SAL_CALL disposing( ::com::sun::star::lang::EventObject const & evt ) 111 throw (::com::sun::star::uno::RuntimeException); 112 113 // XTerminateListener 114 virtual void SAL_CALL queryTermination( ::com::sun::star::lang::EventObject const & evt ) 115 throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); 116 virtual void SAL_CALL notifyTermination( ::com::sun::star::lang::EventObject const & evt ) 117 throw (::com::sun::star::uno::RuntimeException); 118 119 // XModifyListener 120 virtual void SAL_CALL modified( ::com::sun::star::lang::EventObject const & evt ) 121 throw (::com::sun::star::uno::RuntimeException); 122 }; 123 124 } // namespace dp_gui 125 126 #endif 127 128