1*ff12d537SAndre Fischer /**************************************************************
2*ff12d537SAndre Fischer  *
3*ff12d537SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*ff12d537SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*ff12d537SAndre Fischer  * distributed with this work for additional information
6*ff12d537SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*ff12d537SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*ff12d537SAndre Fischer  * "License"); you may not use this file except in compliance
9*ff12d537SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*ff12d537SAndre Fischer  *
11*ff12d537SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*ff12d537SAndre Fischer  *
13*ff12d537SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*ff12d537SAndre Fischer  * software distributed under the License is distributed on an
15*ff12d537SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ff12d537SAndre Fischer  * KIND, either express or implied.  See the License for the
17*ff12d537SAndre Fischer  * specific language governing permissions and limitations
18*ff12d537SAndre Fischer  * under the License.
19*ff12d537SAndre Fischer  *
20*ff12d537SAndre Fischer  *************************************************************/
21*ff12d537SAndre Fischer 
22*ff12d537SAndre Fischer #ifndef SFX_SIDEBAR_RESOURCE_MANAGER_HXX
23*ff12d537SAndre Fischer #define SFX_SIDEBAR_RESOURCE_MANAGER_HXX
24*ff12d537SAndre Fischer 
25*ff12d537SAndre Fischer #include "DeckDescriptor.hxx"
26*ff12d537SAndre Fischer #include "PanelDescriptor.hxx"
27*ff12d537SAndre Fischer 
28*ff12d537SAndre Fischer #include <set>
29*ff12d537SAndre Fischer #include <boost/shared_ptr.hpp>
30*ff12d537SAndre Fischer 
31*ff12d537SAndre Fischer 
32*ff12d537SAndre Fischer namespace css = ::com::sun::star;
33*ff12d537SAndre Fischer namespace cssu = ::com::sun::star::uno;
34*ff12d537SAndre Fischer 
35*ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
36*ff12d537SAndre Fischer 
37*ff12d537SAndre Fischer /** Read the content of the Sidebar.xcu file and provide access
38*ff12d537SAndre Fischer     methods so that the sidebar can easily decide which content panels
39*ff12d537SAndre Fischer     to display for a certain context.
40*ff12d537SAndre Fischer */
41*ff12d537SAndre Fischer class ResourceManager
42*ff12d537SAndre Fischer {
43*ff12d537SAndre Fischer public:
44*ff12d537SAndre Fischer     static ResourceManager& Instance (void);
45*ff12d537SAndre Fischer 
46*ff12d537SAndre Fischer     const DeckDescriptor* GetBestMatchingDeck (
47*ff12d537SAndre Fischer         const Context& rContext,
48*ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
49*ff12d537SAndre Fischer 
50*ff12d537SAndre Fischer     typedef ::std::vector<DeckDescriptor> DeckContainer;
51*ff12d537SAndre Fischer     typedef ::std::vector<PanelDescriptor> PanelContainer;
52*ff12d537SAndre Fischer 
53*ff12d537SAndre Fischer     const DeckContainer& GetMatchingDecks (
54*ff12d537SAndre Fischer         DeckContainer& rDeckDescriptors,
55*ff12d537SAndre Fischer         const Context& rContext,
56*ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
57*ff12d537SAndre Fischer 
58*ff12d537SAndre Fischer     const PanelContainer& GetMatchingPanels (
59*ff12d537SAndre Fischer         PanelContainer& rPanelDescriptors,
60*ff12d537SAndre Fischer         const Context& rContext,
61*ff12d537SAndre Fischer         const ::rtl::OUString& rsDeckId,
62*ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
63*ff12d537SAndre Fischer 
64*ff12d537SAndre Fischer private:
65*ff12d537SAndre Fischer     ResourceManager (void);
66*ff12d537SAndre Fischer     ~ResourceManager (void);
67*ff12d537SAndre Fischer     class Deleter;
68*ff12d537SAndre Fischer     friend class Deleter;
69*ff12d537SAndre Fischer 
70*ff12d537SAndre Fischer     DeckContainer maDecks;
71*ff12d537SAndre Fischer     PanelContainer maPanels;
72*ff12d537SAndre Fischer     mutable ::std::set<rtl::OUString> maProcessedApplications;
73*ff12d537SAndre Fischer 
74*ff12d537SAndre Fischer     void ReadDeckList (void);
75*ff12d537SAndre Fischer     void ReadPanelList (void);
76*ff12d537SAndre Fischer     void ReadContextList (
77*ff12d537SAndre Fischer         const ::utl::OConfigurationNode& rNode,
78*ff12d537SAndre Fischer         ::std::vector<Context>& rContextContainer) const;
79*ff12d537SAndre Fischer     void ReadLegacyAddons (
80*ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
81*ff12d537SAndre Fischer     ::rtl::OUString GetModuleName (
82*ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame) const;
83*ff12d537SAndre Fischer     ::utl::OConfigurationTreeRoot GetLegacyAddonRootNode (
84*ff12d537SAndre Fischer         const ::rtl::OUString& rsModuleName) const;
85*ff12d537SAndre Fischer     void GetToolPanelNodeNames (
86*ff12d537SAndre Fischer         ::std::vector<rtl::OUString>& rMatchingNames,
87*ff12d537SAndre Fischer         const ::utl::OConfigurationTreeRoot aRoot) const;
88*ff12d537SAndre Fischer };
89*ff12d537SAndre Fischer 
90*ff12d537SAndre Fischer 
91*ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
92*ff12d537SAndre Fischer 
93*ff12d537SAndre Fischer #endif
94