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 SD_FRAMEWORK_RESOURCE_FACTORY_MANAGER_HXX 29 #define SD_FRAMEWORK_RESOURCE_FACTORY_MANAGER_HXX 30 31 #include <com/sun/star/drawing/framework/XControllerManager.hpp> 32 #include <com/sun/star/drawing/framework/XModuleController.hpp> 33 #include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp> 34 #include <com/sun/star/util/XURLTransformer.hpp> 35 #include <osl/mutex.hxx> 36 #include <comphelper/stl_types.hxx> 37 #include <hash_map> 38 39 namespace css = ::com::sun::star; 40 41 namespace sd { namespace framework { 42 43 /** Container of resource factories of the drawing framework. 44 */ 45 class ResourceFactoryManager 46 { 47 public: 48 ResourceFactoryManager ( 49 const css::uno::Reference<css::drawing::framework::XControllerManager>& rxManager); 50 51 ~ResourceFactoryManager (void); 52 53 /** Register a resource factory for one type of resource. 54 @param rsURL 55 The type of the resource that will be created by the factory. 56 @param rxFactory 57 The factory that will create resource objects of the specfied type. 58 */ 59 void AddFactory ( 60 const ::rtl::OUString& rsURL, 61 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory) 62 throw (css::uno::RuntimeException); 63 64 /** Unregister the specifed factory. 65 @param rsURL 66 Unregister only the factory for this URL. When the same factory 67 is registered for other URLs then these remain registered. 68 */ 69 void RemoveFactoryForURL( 70 const ::rtl::OUString& rsURL) 71 throw (css::uno::RuntimeException); 72 73 /** Unregister the specified factory. 74 @param rxFactory 75 Unregister the this factory for all URLs that it has been 76 registered for. 77 */ 78 void RemoveFactoryForReference( 79 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory) 80 throw (css::uno::RuntimeException); 81 82 /** Return a factory that can create resources specified by the given URL. 83 @param rsCompleteURL 84 This URL specifies the type of the resource. It may contain arguments. 85 @return 86 When a factory for the specified URL has been registered by a 87 previous call to AddFactory() then a reference to that factory 88 is returned. Otherwise an empty reference is returned. 89 */ 90 css::uno::Reference<css::drawing::framework::XResourceFactory> GetFactory ( 91 const ::rtl::OUString& rsURL) 92 throw (css::uno::RuntimeException); 93 94 private: 95 ::osl::Mutex maMutex; 96 typedef ::std::hash_map< 97 ::rtl::OUString, 98 css::uno::Reference<css::drawing::framework::XResourceFactory>, 99 ::comphelper::UStringHash, 100 ::comphelper::UStringEqual> FactoryMap; 101 FactoryMap maFactoryMap; 102 103 typedef ::std::vector< 104 ::std::pair< 105 rtl::OUString, 106 css::uno::Reference<css::drawing::framework::XResourceFactory> > > 107 FactoryPatternList; 108 FactoryPatternList maFactoryPatternList; 109 110 css::uno::Reference<css::drawing::framework::XControllerManager> mxControllerManager; 111 css::uno::Reference<css::util::XURLTransformer> mxURLTransformer; 112 113 /** Look up the factory for the given URL. 114 @param rsURLBase 115 The css::tools::URL.Main part of a URL. Arguments have to be 116 stripped off by the caller. 117 @return 118 When the factory has not yet been added then return NULL. 119 */ 120 css::uno::Reference<css::drawing::framework::XResourceFactory> FindFactory ( 121 const ::rtl::OUString& rsURLBase) 122 throw (css::uno::RuntimeException); 123 }; 124 125 126 } } // end of namespace sd::framework 127 128 #endif 129