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 
28 #include <set>
29 #include <boost/shared_ptr.hpp>
30 
31 
32 namespace css = ::com::sun::star;
33 namespace cssu = ::com::sun::star::uno;
34 
35 namespace sfx2 { namespace sidebar {
36 
37 /** Read the content of the Sidebar.xcu file and provide access
38     methods so that the sidebar can easily decide which content panels
39     to display for a certain context.
40 */
41 class ResourceManager
42 {
43 public:
44     static ResourceManager& Instance (void);
45 
46     const DeckDescriptor* GetBestMatchingDeck (
47         const Context& rContext,
48         const cssu::Reference<css::frame::XFrame>& rxFrame);
49 
50     typedef ::std::vector<DeckDescriptor> DeckContainer;
51     typedef ::std::vector<PanelDescriptor> PanelContainer;
52 
53     const DeckContainer& GetMatchingDecks (
54         DeckContainer& rDeckDescriptors,
55         const Context& rContext,
56         const cssu::Reference<css::frame::XFrame>& rxFrame);
57 
58     const PanelContainer& GetMatchingPanels (
59         PanelContainer& rPanelDescriptors,
60         const Context& rContext,
61         const ::rtl::OUString& rsDeckId,
62         const cssu::Reference<css::frame::XFrame>& rxFrame);
63 
64 private:
65     ResourceManager (void);
66     ~ResourceManager (void);
67     class Deleter;
68     friend class Deleter;
69 
70     DeckContainer maDecks;
71     PanelContainer maPanels;
72     mutable ::std::set<rtl::OUString> maProcessedApplications;
73 
74     void ReadDeckList (void);
75     void ReadPanelList (void);
76     void ReadContextList (
77         const ::utl::OConfigurationNode& rNode,
78         ::std::vector<Context>& rContextContainer) const;
79     void ReadLegacyAddons (
80         const cssu::Reference<css::frame::XFrame>& rxFrame);
81     ::rtl::OUString GetModuleName (
82         const cssu::Reference<css::frame::XFrame>& rxFrame) const;
83     ::utl::OConfigurationTreeRoot GetLegacyAddonRootNode (
84         const ::rtl::OUString& rsModuleName) const;
85     void GetToolPanelNodeNames (
86         ::std::vector<rtl::OUString>& rMatchingNames,
87         const ::utl::OConfigurationTreeRoot aRoot) const;
88 };
89 
90 
91 } } // end of namespace sfx2::sidebar
92 
93 #endif
94