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"
277a32b0c8SAndre Fischer #include "Context.hxx"
2895a18594SAndre Fischer #include <unotools/confignode.hxx>
2995a18594SAndre 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 
397a32b0c8SAndre Fischer class Context;
40*f120fe41SAndre Fischer class ContextList;
417a32b0c8SAndre Fischer 
42ff12d537SAndre Fischer /** Read the content of the Sidebar.xcu file and provide access
43ff12d537SAndre Fischer     methods so that the sidebar can easily decide which content panels
44ff12d537SAndre Fischer     to display for a certain context.
45ff12d537SAndre Fischer */
46ff12d537SAndre Fischer class ResourceManager
47ff12d537SAndre Fischer {
48ff12d537SAndre Fischer public:
49ff12d537SAndre Fischer     static ResourceManager& Instance (void);
50ff12d537SAndre Fischer 
51ff12d537SAndre Fischer     const DeckDescriptor* GetBestMatchingDeck (
527a32b0c8SAndre Fischer         const Context& rContext,
53ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
54ff12d537SAndre Fischer 
5595a18594SAndre Fischer     const DeckDescriptor* GetDeckDescriptor (
5695a18594SAndre Fischer         const ::rtl::OUString& rsDeckId) const;
5795a18594SAndre Fischer     const PanelDescriptor* GetPanelDescriptor (
5895a18594SAndre Fischer         const ::rtl::OUString& rsPanelId) const;
5995a18594SAndre Fischer 
6095a18594SAndre Fischer     /** Excluded or include a deck from being displayed in the tab
6195a18594SAndre Fischer         bar.
6295a18594SAndre Fischer         Note that this value is not persistent.
6395a18594SAndre Fischer         The flag can not be set directly at a DeckDescriptor object
6495a18594SAndre Fischer         because the ResourceManager gives access to to them only
6595a18594SAndre Fischer         read-only.
6695a18594SAndre Fischer     */
6795a18594SAndre Fischer     void SetIsDeckEnabled (
6895a18594SAndre Fischer         const ::rtl::OUString& rsDeckId,
6995a18594SAndre Fischer         const bool bIsEnabled);
7095a18594SAndre Fischer 
7195a18594SAndre Fischer     typedef ::std::vector<rtl::OUString> IdContainer;
72*f120fe41SAndre Fischer     class PanelContextDescriptor
73*f120fe41SAndre Fischer     {
74*f120fe41SAndre Fischer     public:
75*f120fe41SAndre Fischer         ::rtl::OUString msId;
76*f120fe41SAndre Fischer         ::rtl::OUString msMenuCommand;
77*f120fe41SAndre Fischer         bool mbIsInitiallyVisible;
78*f120fe41SAndre Fischer     };
79*f120fe41SAndre Fischer     typedef ::std::vector<PanelContextDescriptor> PanelContextDescriptorContainer;
80*f120fe41SAndre Fischer 
8195a18594SAndre Fischer     const IdContainer& GetMatchingDecks (
8295a18594SAndre Fischer         IdContainer& rDeckDescriptors,
837a32b0c8SAndre Fischer         const Context& rContext,
84ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
85ff12d537SAndre Fischer 
86*f120fe41SAndre Fischer     const PanelContextDescriptorContainer& GetMatchingPanels (
87*f120fe41SAndre Fischer         PanelContextDescriptorContainer& rPanelDescriptors,
887a32b0c8SAndre Fischer         const Context& rContext,
89ff12d537SAndre Fischer         const ::rtl::OUString& rsDeckId,
90ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
91ff12d537SAndre Fischer 
9295a18594SAndre Fischer     static ::rtl::OUString GetModuleName (
9395a18594SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
9495a18594SAndre Fischer 
95ff12d537SAndre Fischer private:
96ff12d537SAndre Fischer     ResourceManager (void);
97ff12d537SAndre Fischer     ~ResourceManager (void);
98ff12d537SAndre Fischer     class Deleter;
99ff12d537SAndre Fischer     friend class Deleter;
100ff12d537SAndre Fischer 
10195a18594SAndre Fischer     typedef ::std::vector<DeckDescriptor> DeckContainer;
102ff12d537SAndre Fischer     DeckContainer maDecks;
10395a18594SAndre Fischer     typedef ::std::vector<PanelDescriptor> PanelContainer;
104ff12d537SAndre Fischer     PanelContainer maPanels;
105ff12d537SAndre Fischer     mutable ::std::set<rtl::OUString> maProcessedApplications;
106ff12d537SAndre Fischer 
107ff12d537SAndre Fischer     void ReadDeckList (void);
108ff12d537SAndre Fischer     void ReadPanelList (void);
109*f120fe41SAndre Fischer     void ReadContextList (
110ff12d537SAndre Fischer         const ::utl::OConfigurationNode& rNode,
111*f120fe41SAndre Fischer         ContextList& rContextList,
112*f120fe41SAndre Fischer         const ::rtl::OUString& rsDefaultMenuCommand) const;
113ff12d537SAndre Fischer     void ReadLegacyAddons (
114ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
115ff12d537SAndre Fischer     ::utl::OConfigurationTreeRoot GetLegacyAddonRootNode (
116ff12d537SAndre Fischer         const ::rtl::OUString& rsModuleName) const;
117ff12d537SAndre Fischer     void GetToolPanelNodeNames (
118ff12d537SAndre Fischer         ::std::vector<rtl::OUString>& rMatchingNames,
119ff12d537SAndre Fischer         const ::utl::OConfigurationTreeRoot aRoot) const;
120ff12d537SAndre Fischer };
121ff12d537SAndre Fischer 
122ff12d537SAndre Fischer 
123ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
124ff12d537SAndre Fischer 
125ff12d537SAndre Fischer #endif
126