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