Bump version to 21.06.18.1
[LibreOffice.git] / include / sfx2 / sidebar / ResourceManager.hxx
blob5f0768ac7fcc589deba170dee6ad1b9a245f1bc2
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 #pragma once
21 #include <unotools/confignode.hxx>
22 #include <map>
23 #include <vector>
24 #include <set>
26 namespace com::sun::star::frame { class XController; }
27 namespace com::sun::star::frame { class XModel; }
28 namespace sfx2::sidebar { class DeckDescriptor; }
29 namespace sfx2::sidebar { class PanelDescriptor; }
31 namespace sfx2::sidebar {
33 class Context;
34 class ContextList;
36 /** Read the content of the Sidebar.xcu file and provide access
37 methods so that the sidebar can easily decide which content panels
38 to display for a certain context.
40 class ResourceManager
42 public:
44 ResourceManager();
45 ~ResourceManager();
47 std::shared_ptr<DeckDescriptor> GetDeckDescriptor(const OUString& rsDeckId) const;
48 std::shared_ptr<PanelDescriptor> GetPanelDescriptor(const OUString& rsPanelId) const;
50 void UpdateModel(const css::uno::Reference<css::frame::XModel>& xModel);
52 void InitDeckContext(const Context& rContex);
53 void SaveDecksSettings(const Context& rContext);
54 void SaveDeckSettings(const DeckDescriptor* pDeckDesc);
55 void SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck);
57 void disposeDecks();
59 class DeckContextDescriptor
61 public:
62 OUString msId;
63 bool mbIsEnabled;
65 typedef std::vector<DeckContextDescriptor> DeckContextDescriptorContainer;
67 class PanelContextDescriptor
69 public:
70 OUString msId;
71 OUString msMenuCommand;
72 bool mbIsInitiallyVisible;
73 bool mbShowForReadOnlyDocuments;
75 typedef std::vector<PanelContextDescriptor> PanelContextDescriptorContainer;
77 const DeckContextDescriptorContainer& GetMatchingDecks(
78 DeckContextDescriptorContainer& rDeckDescriptors,
79 const Context& rContext,
80 const bool bIsDocumentReadOnly,
81 const css::uno::Reference<css::frame::XController>& rxController);
83 const PanelContextDescriptorContainer& GetMatchingPanels(
84 PanelContextDescriptorContainer& rPanelDescriptors,
85 const Context& rContext,
86 const OUString& rsDeckId,
87 const css::uno::Reference<css::frame::XController>& rxController);
89 const OUString& GetLastActiveDeck( const Context& rContext );
90 void SetLastActiveDeck( const Context& rContext, const OUString& rsDeckId );
92 /** Remember the expansions state per panel and context.
94 void StorePanelExpansionState(const OUString& rsPanelId,
95 const bool bExpansionState,
96 const Context& rContext);
98 private:
101 typedef std::vector<std::shared_ptr<DeckDescriptor>> DeckContainer;
102 DeckContainer maDecks;
104 typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer;
105 PanelContainer maPanels;
106 mutable std::set<OUString> maProcessedApplications;
107 std::map<OUString, OUString> maLastActiveDecks;
109 void ReadDeckList();
110 void ReadPanelList();
111 void ReadLastActive();
112 static void ReadContextList(const utl::OConfigurationNode& rNode,
113 ContextList& rContextList,
114 const OUString& rsDefaultMenuCommand);
116 void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController);
117 static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName);
118 static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames,
119 const utl::OConfigurationTreeRoot& aRoot);
120 bool IsDeckEnabled(const OUString& rsDeckId,
121 const Context& rContext,
122 const css::uno::Reference<css::frame::XController>& rxController);
124 std::shared_ptr<DeckDescriptor> ImplGetDeckDescriptor(const OUString& rsDeckId) const;
125 std::shared_ptr<PanelDescriptor> ImplGetPanelDescriptor(const OUString& rsPanelId) const;
128 } // end of namespace sfx2::sidebar
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */