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 class ContextList; 41 42 /** Read the content of the Sidebar.xcu file and provide access 43 methods so that the sidebar can easily decide which content panels 44 to display for a certain context. 45 */ 46 class ResourceManager 47 { 48 public: 49 static ResourceManager& Instance (void); 50 51 const DeckDescriptor* GetDeckDescriptor ( 52 const ::rtl::OUString& rsDeckId) const; 53 const PanelDescriptor* GetPanelDescriptor ( 54 const ::rtl::OUString& rsPanelId) const; 55 56 /** Excluded or include a deck from being displayed in the tab 57 bar. 58 Note that this value is not persistent. 59 The flag can not be set directly at a DeckDescriptor object 60 because the ResourceManager gives access to to them only 61 read-only. 62 */ 63 void SetIsDeckEnabled ( 64 const ::rtl::OUString& rsDeckId, 65 const bool bIsEnabled); 66 67 class DeckContextDescriptor 68 { 69 public: 70 ::rtl::OUString msId; 71 bool mbIsEnabled; 72 }; 73 typedef ::std::vector<DeckContextDescriptor> DeckContextDescriptorContainer; 74 75 class PanelContextDescriptor 76 { 77 public: 78 ::rtl::OUString msId; 79 ::rtl::OUString msMenuCommand; 80 bool mbIsInitiallyVisible; 81 bool mbShowForReadOnlyDocuments; 82 }; 83 typedef ::std::vector<PanelContextDescriptor> PanelContextDescriptorContainer; 84 85 const DeckContextDescriptorContainer& GetMatchingDecks ( 86 DeckContextDescriptorContainer& rDeckDescriptors, 87 const Context& rContext, 88 const bool bIsDocumentReadOnly, 89 const cssu::Reference<css::frame::XFrame>& rxFrame); 90 91 const PanelContextDescriptorContainer& GetMatchingPanels ( 92 PanelContextDescriptorContainer& rPanelDescriptors, 93 const Context& rContext, 94 const ::rtl::OUString& rsDeckId, 95 const cssu::Reference<css::frame::XFrame>& rxFrame); 96 97 static ::rtl::OUString GetModuleName ( 98 const cssu::Reference<css::frame::XFrame>& rxFrame); 99 100 private: 101 ResourceManager (void); 102 ~ResourceManager (void); 103 class Deleter; 104 friend class Deleter; 105 106 typedef ::std::vector<DeckDescriptor> DeckContainer; 107 DeckContainer maDecks; 108 typedef ::std::vector<PanelDescriptor> PanelContainer; 109 PanelContainer maPanels; 110 mutable ::std::set<rtl::OUString> maProcessedApplications; 111 112 void ReadDeckList (void); 113 void ReadPanelList (void); 114 void ReadContextList ( 115 const ::utl::OConfigurationNode& rNode, 116 ContextList& rContextList, 117 const ::rtl::OUString& rsDefaultMenuCommand) const; 118 void ReadLegacyAddons ( 119 const cssu::Reference<css::frame::XFrame>& rxFrame); 120 ::utl::OConfigurationTreeRoot GetLegacyAddonRootNode ( 121 const ::rtl::OUString& rsModuleName) const; 122 void GetToolPanelNodeNames ( 123 ::std::vector<rtl::OUString>& rMatchingNames, 124 const ::utl::OConfigurationTreeRoot aRoot) const; 125 bool IsDeckEnabled ( 126 const ::rtl::OUString& rsDeckId, 127 const Context& rContext, 128 const cssu::Reference<css::frame::XFrame>& rxFrame) const; 129 }; 130 131 132 } } // end of namespace sfx2::sidebar 133 134 #endif 135