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 #ifndef SFX_SIDEBAR_RESOURCE_MANAGER_HXX 23 #define SFX_SIDEBAR_RESOURCE_MANAGER_HXX 24 25 #include "DeckDescriptor.hxx" 26 #include "PanelDescriptor.hxx" 27 #include "Context.hxx" 28 #include <unotools/confignode.hxx> 29 #include <com/sun/star/frame/XFrame.hpp> 30 #include <set> 31 #include <boost/shared_ptr.hpp> 32 33 34 namespace css = ::com::sun::star; 35 namespace cssu = ::com::sun::star::uno; 36 37 namespace sfx2 { namespace sidebar { 38 39 class Context; 40 41 /** Read the content of the Sidebar.xcu file and provide access 42 methods so that the sidebar can easily decide which content panels 43 to display for a certain context. 44 */ 45 class ResourceManager 46 { 47 public: 48 static ResourceManager& Instance (void); 49 50 const DeckDescriptor* GetBestMatchingDeck ( 51 const Context& rContext, 52 const cssu::Reference<css::frame::XFrame>& rxFrame); 53 54 const DeckDescriptor* GetDeckDescriptor ( 55 const ::rtl::OUString& rsDeckId) const; 56 const PanelDescriptor* GetPanelDescriptor ( 57 const ::rtl::OUString& rsPanelId) const; 58 59 /** Excluded or include a deck from being displayed in the tab 60 bar. 61 Note that this value is not persistent. 62 The flag can not be set directly at a DeckDescriptor object 63 because the ResourceManager gives access to to them only 64 read-only. 65 */ 66 void SetIsDeckEnabled ( 67 const ::rtl::OUString& rsDeckId, 68 const bool bIsEnabled); 69 70 typedef ::std::vector<rtl::OUString> IdContainer; 71 72 const IdContainer& GetMatchingDecks ( 73 IdContainer& rDeckDescriptors, 74 const Context& rContext, 75 const cssu::Reference<css::frame::XFrame>& rxFrame); 76 77 const IdContainer& GetMatchingPanels ( 78 IdContainer& rPanelDescriptors, 79 const Context& rContext, 80 const ::rtl::OUString& rsDeckId, 81 const cssu::Reference<css::frame::XFrame>& rxFrame); 82 83 static ::rtl::OUString GetModuleName ( 84 const cssu::Reference<css::frame::XFrame>& rxFrame); 85 86 private: 87 ResourceManager (void); 88 ~ResourceManager (void); 89 class Deleter; 90 friend class Deleter; 91 92 typedef ::std::vector<DeckDescriptor> DeckContainer; 93 DeckContainer maDecks; 94 typedef ::std::vector<PanelDescriptor> PanelContainer; 95 PanelContainer maPanels; 96 mutable ::std::set<rtl::OUString> maProcessedApplications; 97 98 void ReadDeckList (void); 99 void ReadPanelList (void); 100 void ReadContextMatcher ( 101 const ::utl::OConfigurationNode& rNode, 102 ContextMatcher& rContextMatcher) const; 103 void ReadLegacyAddons ( 104 const cssu::Reference<css::frame::XFrame>& rxFrame); 105 ::utl::OConfigurationTreeRoot GetLegacyAddonRootNode ( 106 const ::rtl::OUString& rsModuleName) const; 107 void GetToolPanelNodeNames ( 108 ::std::vector<rtl::OUString>& rMatchingNames, 109 const ::utl::OConfigurationTreeRoot aRoot) const; 110 }; 111 112 113 } } // end of namespace sfx2::sidebar 114 115 #endif 116