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;
40f120fe41SAndre 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 
5195a18594SAndre Fischer     const DeckDescriptor* GetDeckDescriptor (
5295a18594SAndre Fischer         const ::rtl::OUString& rsDeckId) const;
5395a18594SAndre Fischer     const PanelDescriptor* GetPanelDescriptor (
5495a18594SAndre Fischer         const ::rtl::OUString& rsPanelId) const;
5595a18594SAndre Fischer 
5695a18594SAndre Fischer     /** Excluded or include a deck from being displayed in the tab
5795a18594SAndre Fischer         bar.
5895a18594SAndre Fischer         Note that this value is not persistent.
5995a18594SAndre Fischer         The flag can not be set directly at a DeckDescriptor object
6095a18594SAndre Fischer         because the ResourceManager gives access to to them only
6195a18594SAndre Fischer         read-only.
6295a18594SAndre Fischer     */
6395a18594SAndre Fischer     void SetIsDeckEnabled (
6495a18594SAndre Fischer         const ::rtl::OUString& rsDeckId,
6595a18594SAndre Fischer         const bool bIsEnabled);
6695a18594SAndre Fischer 
6713e1c3b4SAndre Fischer     class DeckContextDescriptor
6813e1c3b4SAndre Fischer     {
6913e1c3b4SAndre Fischer     public:
7013e1c3b4SAndre Fischer         ::rtl::OUString msId;
7113e1c3b4SAndre Fischer         bool mbIsEnabled;
7213e1c3b4SAndre Fischer     };
7313e1c3b4SAndre Fischer     typedef ::std::vector<DeckContextDescriptor> DeckContextDescriptorContainer;
7413e1c3b4SAndre Fischer 
75f120fe41SAndre Fischer     class PanelContextDescriptor
76f120fe41SAndre Fischer     {
77f120fe41SAndre Fischer     public:
78f120fe41SAndre Fischer         ::rtl::OUString msId;
79f120fe41SAndre Fischer         ::rtl::OUString msMenuCommand;
80f120fe41SAndre Fischer         bool mbIsInitiallyVisible;
8113e1c3b4SAndre Fischer         bool mbShowForReadOnlyDocuments;
82f120fe41SAndre Fischer     };
83f120fe41SAndre Fischer     typedef ::std::vector<PanelContextDescriptor> PanelContextDescriptorContainer;
84f120fe41SAndre Fischer 
8513e1c3b4SAndre Fischer     const DeckContextDescriptorContainer& GetMatchingDecks (
8613e1c3b4SAndre Fischer         DeckContextDescriptorContainer& rDeckDescriptors,
877a32b0c8SAndre Fischer         const Context& rContext,
8813e1c3b4SAndre Fischer         const bool bIsDocumentReadOnly,
89ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
90ff12d537SAndre Fischer 
91f120fe41SAndre Fischer     const PanelContextDescriptorContainer& GetMatchingPanels (
92f120fe41SAndre Fischer         PanelContextDescriptorContainer& rPanelDescriptors,
937a32b0c8SAndre Fischer         const Context& rContext,
94ff12d537SAndre Fischer         const ::rtl::OUString& rsDeckId,
95ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
96ff12d537SAndre Fischer 
97*7e429a12SAndre Fischer     /** Remember the expansions state per panel and context.
98*7e429a12SAndre Fischer         This is not persistent past application end.
99*7e429a12SAndre Fischer     */
100*7e429a12SAndre Fischer     void StorePanelExpansionState (
101*7e429a12SAndre Fischer         const ::rtl::OUString& rsPanelId,
102*7e429a12SAndre Fischer         const bool bExpansionState,
103*7e429a12SAndre Fischer         const Context& rContext);
104*7e429a12SAndre Fischer 
10595a18594SAndre Fischer     static ::rtl::OUString GetModuleName (
10695a18594SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
10795a18594SAndre Fischer 
108ff12d537SAndre Fischer private:
109ff12d537SAndre Fischer     ResourceManager (void);
110ff12d537SAndre Fischer     ~ResourceManager (void);
111ff12d537SAndre Fischer     class Deleter;
112ff12d537SAndre Fischer     friend class Deleter;
113ff12d537SAndre Fischer 
11495a18594SAndre Fischer     typedef ::std::vector<DeckDescriptor> DeckContainer;
115ff12d537SAndre Fischer     DeckContainer maDecks;
11695a18594SAndre Fischer     typedef ::std::vector<PanelDescriptor> PanelContainer;
117ff12d537SAndre Fischer     PanelContainer maPanels;
118ff12d537SAndre Fischer     mutable ::std::set<rtl::OUString> maProcessedApplications;
119ff12d537SAndre Fischer 
120ff12d537SAndre Fischer     void ReadDeckList (void);
121ff12d537SAndre Fischer     void ReadPanelList (void);
122f120fe41SAndre Fischer     void ReadContextList (
123ff12d537SAndre Fischer         const ::utl::OConfigurationNode& rNode,
124f120fe41SAndre Fischer         ContextList& rContextList,
125f120fe41SAndre Fischer         const ::rtl::OUString& rsDefaultMenuCommand) const;
126ff12d537SAndre Fischer     void ReadLegacyAddons (
127ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
128ff12d537SAndre Fischer     ::utl::OConfigurationTreeRoot GetLegacyAddonRootNode (
129ff12d537SAndre Fischer         const ::rtl::OUString& rsModuleName) const;
130ff12d537SAndre Fischer     void GetToolPanelNodeNames (
131ff12d537SAndre Fischer         ::std::vector<rtl::OUString>& rMatchingNames,
132ff12d537SAndre Fischer         const ::utl::OConfigurationTreeRoot aRoot) const;
13313e1c3b4SAndre Fischer     bool IsDeckEnabled (
13413e1c3b4SAndre Fischer         const ::rtl::OUString& rsDeckId,
13513e1c3b4SAndre Fischer         const Context& rContext,
13613e1c3b4SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame) const;
137ff12d537SAndre Fischer };
138ff12d537SAndre Fischer 
139ff12d537SAndre Fischer 
140ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
141ff12d537SAndre Fischer 
142ff12d537SAndre Fischer #endif
143