Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / sfx2 / sidebar / ResourceManager.hxx
blobc5456525f34d26000320dd8a2ac37dd6c73101fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_RESOURCEMANAGER_HXX
20 #define INCLUDED_SFX2_SOURCE_SIDEBAR_RESOURCEMANAGER_HXX
22 #include "DeckDescriptor.hxx"
23 #include "PanelDescriptor.hxx"
24 #include <sfx2/sidebar/Context.hxx>
25 #include <unotools/confignode.hxx>
26 #include <com/sun/star/frame/XController.hpp>
27 #include <set>
28 #include <svtools/miscopt.hxx>
30 namespace sfx2 { namespace sidebar {
32 class Context;
33 class ContextList;
35 /** Read the content of the Sidebar.xcu file and provide access
36 methods so that the sidebar can easily decide which content panels
37 to display for a certain context.
39 class ResourceManager
41 public:
43 ResourceManager();
44 ~ResourceManager();
46 std::shared_ptr<DeckDescriptor> GetDeckDescriptor(const OUString& rsDeckId) const;
47 std::shared_ptr<PanelDescriptor> GetPanelDescriptor(const OUString& rsPanelId) const;
49 void UpdateModel(const css::uno::Reference<css::frame::XModel>& xModel);
51 void InitDeckContext(const Context& rContex);
52 void SaveDecksSettings(const Context& rContext);
53 void SaveDeckSettings(const DeckDescriptor* pDeckDesc);
55 void disposeDecks();
57 class DeckContextDescriptor
59 public:
60 OUString msId;
61 bool mbIsEnabled;
63 typedef std::vector<DeckContextDescriptor> DeckContextDescriptorContainer;
65 class PanelContextDescriptor
67 public:
68 OUString msId;
69 OUString msMenuCommand;
70 bool mbIsInitiallyVisible;
71 bool mbShowForReadOnlyDocuments;
73 typedef std::vector<PanelContextDescriptor> PanelContextDescriptorContainer;
75 const DeckContextDescriptorContainer& GetMatchingDecks(
76 DeckContextDescriptorContainer& rDeckDescriptors,
77 const Context& rContext,
78 const bool bIsDocumentReadOnly,
79 const css::uno::Reference<css::frame::XController>& rxController);
81 const PanelContextDescriptorContainer& GetMatchingPanels(
82 PanelContextDescriptorContainer& rPanelDescriptors,
83 const Context& rContext,
84 const OUString& rsDeckId,
85 const css::uno::Reference<css::frame::XController>& rxController);
87 /** Remember the expansions state per panel and context.
89 void StorePanelExpansionState(const OUString& rsPanelId,
90 const bool bExpansionState,
91 const Context& rContext);
93 private:
96 typedef std::vector<std::shared_ptr<DeckDescriptor>> DeckContainer;
97 DeckContainer maDecks;
99 typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer;
100 PanelContainer maPanels;
101 mutable std::set<rtl::OUString> maProcessedApplications;
103 SvtMiscOptions maMiscOptions;
105 void ReadDeckList();
106 void ReadPanelList();
107 static void ReadContextList(const utl::OConfigurationNode& rNode,
108 ContextList& rContextList,
109 const OUString& rsDefaultMenuCommand);
111 void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController);
112 static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName);
113 static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames,
114 const utl::OConfigurationTreeRoot& aRoot);
115 bool IsDeckEnabled(const OUString& rsDeckId,
116 const Context& rContext,
117 const css::uno::Reference<css::frame::XController>& rxController);
119 std::shared_ptr<DeckDescriptor> ImplGetDeckDescriptor(const OUString& rsDeckId) const;
120 std::shared_ptr<PanelDescriptor> ImplGetPanelDescriptor(const OUString& rsPanelId) const;
123 } } // end of namespace sfx2::sidebar
125 #endif
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */