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 BASIC_DIALOGCONTAINER_HXX 25 #define BASIC_DIALOGCONTAINER_HXX 26 27 #include "namecont.hxx" 28 29 #ifndef _COM_SUN_STAR_AWT_XSTRINGRESOURCESUPPLIER_HPP_ 30 #include <com/sun/star/resource/XStringResourceSupplier.hpp> 31 #endif 32 #include "com/sun/star/resource/XStringResourcePersistence.hpp" 33 34 #include <cppuhelper/implbase1.hxx> 35 #include <comphelper/uno3.hxx> 36 37 namespace basic 38 { 39 40 //============================================================================ 41 42 class SfxDialogLibraryContainer : public SfxLibraryContainer 43 { 44 // Methods to distinguish between different library types 45 virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName ); 46 virtual SfxLibrary* SAL_CALL implCreateLibraryLink 47 ( const ::rtl::OUString& aName, const ::rtl::OUString& aLibInfoFileURL, 48 const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ); 49 virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ); 50 virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; 51 virtual void SAL_CALL writeLibraryElement 52 ( 53 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, 54 const ::rtl::OUString& aElementName, 55 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput 56 ) 57 throw(::com::sun::star::uno::Exception); 58 59 virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement 60 ( 61 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, 62 const ::rtl::OUString& aElementName, 63 const ::rtl::OUString& aFile, 64 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ); 65 66 virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ); 67 68 virtual SfxLibraryContainer* createInstanceImpl( void ); 69 70 virtual void onNewRootStorage(); 71 72 virtual const sal_Char* SAL_CALL getInfoFileName() const; 73 virtual const sal_Char* SAL_CALL getOldInfoFileName() const; 74 virtual const sal_Char* SAL_CALL getLibElementFileExtension() const; 75 virtual const sal_Char* SAL_CALL getLibrariesDir() const; 76 77 public: 78 SfxDialogLibraryContainer( void ); 79 SfxDialogLibraryContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); 80 81 // Methods XStorageBasedLibraryContainer 82 virtual void SAL_CALL storeLibrariesToStorage( 83 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& RootStorage ) 84 throw (::com::sun::star::uno::RuntimeException); 85 86 // Resource handling 87 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourcePersistence > 88 implCreateStringResource( class SfxDialogLibrary* pDialog ); 89 90 // Methods XServiceInfo 91 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 92 throw (::com::sun::star::uno::RuntimeException); 93 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 94 throw (::com::sun::star::uno::RuntimeException); 95 96 // Service 97 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(); 98 static ::rtl::OUString getImplementationName_static(); 99 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create 100 ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xServiceManager ) 101 throw( ::com::sun::star::uno::Exception ); 102 }; 103 104 //============================================================================ 105 106 typedef ::cppu::ImplHelper1 < ::com::sun::star::resource::XStringResourceSupplier 107 > SfxDialogLibrary_BASE; 108 109 class SfxDialogLibrary :public SfxLibrary 110 ,public SfxDialogLibrary_BASE 111 { 112 SfxDialogLibraryContainer* m_pParent; 113 ::com::sun::star::uno::Reference 114 < ::com::sun::star::resource::XStringResourcePersistence> m_xStringResourcePersistence; 115 ::rtl::OUString m_aName; 116 117 // Provide modify state including resources 118 virtual sal_Bool isModified( void ); 119 virtual void storeResources( void ); 120 virtual void storeResourcesAsURL( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ); 121 virtual void storeResourcesToURL( const ::rtl::OUString& URL, 122 const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); 123 virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference 124 < ::com::sun::star::embed::XStorage >& xStorage ); 125 126 public: 127 SfxDialogLibrary 128 ( 129 ModifiableHelper& _rModifiable, 130 const ::rtl::OUString& aName, 131 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, 132 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, 133 SfxDialogLibraryContainer* pParent 134 ); 135 136 SfxDialogLibrary 137 ( 138 ModifiableHelper& _rModifiable, 139 const ::rtl::OUString& aName, 140 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF, 141 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, 142 const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly, 143 SfxDialogLibraryContainer* pParent 144 ); 145 146 DECLARE_XINTERFACE() 147 DECLARE_XTYPEPROVIDER() 148 149 // XStringResourceSupplier 150 virtual ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > 151 SAL_CALL getStringResource( ) throw (::com::sun::star::uno::RuntimeException); 152 getName(void)153 ::rtl::OUString getName( void ) 154 { return m_aName; } 155 156 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourcePersistence > getStringResourcePersistence(void)157 getStringResourcePersistence( void ) 158 { 159 return m_xStringResourcePersistence; 160 } 161 162 static bool containsValidDialog( const ::com::sun::star::uno::Any& aElement ); 163 164 protected: 165 virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; 166 }; 167 168 } // namespace basic 169 170 #endif 171 172