1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef BASIC_DIALOGCONTAINER_HXX 29 #define BASIC_DIALOGCONTAINER_HXX 30 31 #include "namecont.hxx" 32 33 #ifndef _COM_SUN_STAR_AWT_XSTRINGRESOURCESUPPLIER_HPP_ 34 #include <com/sun/star/resource/XStringResourceSupplier.hpp> 35 #endif 36 #include "com/sun/star/resource/XStringResourcePersistence.hpp" 37 38 #include <cppuhelper/implbase1.hxx> 39 #include <comphelper/uno3.hxx> 40 41 namespace basic 42 { 43 44 //============================================================================ 45 46 class SfxDialogLibraryContainer : public SfxLibraryContainer 47 { 48 // Methods to distinguish between different library types 49 virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName ); 50 virtual SfxLibrary* SAL_CALL implCreateLibraryLink 51 ( const ::rtl::OUString& aName, const ::rtl::OUString& aLibInfoFileURL, 52 const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ); 53 virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ); 54 virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; 55 virtual void SAL_CALL writeLibraryElement 56 ( 57 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, 58 const ::rtl::OUString& aElementName, 59 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput 60 ) 61 throw(::com::sun::star::uno::Exception); 62 63 virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement 64 ( 65 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, 66 const ::rtl::OUString& aElementName, 67 const ::rtl::OUString& aFile, 68 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ); 69 70 virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ); 71 72 virtual SfxLibraryContainer* createInstanceImpl( void ); 73 74 virtual void onNewRootStorage(); 75 76 virtual const sal_Char* SAL_CALL getInfoFileName() const; 77 virtual const sal_Char* SAL_CALL getOldInfoFileName() const; 78 virtual const sal_Char* SAL_CALL getLibElementFileExtension() const; 79 virtual const sal_Char* SAL_CALL getLibrariesDir() const; 80 81 public: 82 SfxDialogLibraryContainer( void ); 83 SfxDialogLibraryContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); 84 85 // Methods XStorageBasedLibraryContainer 86 virtual void SAL_CALL storeLibrariesToStorage( 87 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& RootStorage ) 88 throw (::com::sun::star::uno::RuntimeException); 89 90 // Resource handling 91 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourcePersistence > 92 implCreateStringResource( class SfxDialogLibrary* pDialog ); 93 94 // Methods XServiceInfo 95 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 96 throw (::com::sun::star::uno::RuntimeException); 97 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 98 throw (::com::sun::star::uno::RuntimeException); 99 100 // Service 101 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(); 102 static ::rtl::OUString getImplementationName_static(); 103 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create 104 ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xServiceManager ) 105 throw( ::com::sun::star::uno::Exception ); 106 }; 107 108 //============================================================================ 109 110 typedef ::cppu::ImplHelper1 < ::com::sun::star::resource::XStringResourceSupplier 111 > SfxDialogLibrary_BASE; 112 113 class SfxDialogLibrary :public SfxLibrary 114 ,public SfxDialogLibrary_BASE 115 { 116 SfxDialogLibraryContainer* m_pParent; 117 ::com::sun::star::uno::Reference 118 < ::com::sun::star::resource::XStringResourcePersistence> m_xStringResourcePersistence; 119 ::rtl::OUString m_aName; 120 121 // Provide modify state including resources 122 virtual sal_Bool isModified( void ); 123 virtual void storeResources( void ); 124 virtual void storeResourcesAsURL( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ); 125 virtual void storeResourcesToURL( const ::rtl::OUString& URL, 126 const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); 127 virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference 128 < ::com::sun::star::embed::XStorage >& xStorage ); 129 130 public: 131 SfxDialogLibrary 132 ( 133 ModifiableHelper& _rModifiable, 134 const ::rtl::OUString& aName, 135 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, 136 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, 137 SfxDialogLibraryContainer* pParent 138 ); 139 140 SfxDialogLibrary 141 ( 142 ModifiableHelper& _rModifiable, 143 const ::rtl::OUString& aName, 144 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, 145 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, 146 const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly, 147 SfxDialogLibraryContainer* pParent 148 ); 149 150 DECLARE_XINTERFACE() 151 DECLARE_XTYPEPROVIDER() 152 153 // XStringResourceSupplier 154 virtual ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > 155 SAL_CALL getStringResource( ) throw (::com::sun::star::uno::RuntimeException); 156 157 ::rtl::OUString getName( void ) 158 { return m_aName; } 159 160 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourcePersistence > 161 getStringResourcePersistence( void ) 162 { 163 return m_xStringResourcePersistence; 164 } 165 166 static bool containsValidDialog( const ::com::sun::star::uno::Any& aElement ); 167 168 protected: 169 virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; 170 }; 171 172 } // namespace basic 173 174 #endif 175 176