Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cui / source / inc / treeopt.hxx
blob74ca73944b66d41c1c8401fd530a4e130ea6e793
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <memory>
26 #include <sfx2/basedlgs.hxx>
27 #include <svtools/restartdialog.hxx>
28 #include <utility>
30 class SfxModule;
31 class SfxShell;
33 // struct OrderedEntry ---------------------------------------------------
35 struct OrderedEntry
37 sal_Int32 m_nIndex;
38 OUString m_sId;
40 OrderedEntry( sal_Int32 nIndex, OUString aId ) :
41 m_nIndex( nIndex ), m_sId(std::move( aId )) {}
45 // struct Module ---------------------------------------------------------
47 struct Module
49 bool m_bActive;
50 std::vector< std::unique_ptr<OrderedEntry> > m_aNodeList;
52 Module() : m_bActive( false ) {}
55 // struct OptionsLeaf ----------------------------------------------------
57 struct OptionsLeaf
59 OUString m_sLabel;
60 OUString m_sPageURL;
61 OUString m_sEventHdl;
62 OUString m_sGroupId;
63 sal_Int32 m_nGroupIndex;
65 OptionsLeaf( OUString aLabel,
66 OUString aPageURL,
67 OUString aEventHdl,
68 OUString aGroupId,
69 sal_Int32 nGroupIndex ) :
70 m_sLabel(std::move( aLabel )),
71 m_sPageURL(std::move( aPageURL )),
72 m_sEventHdl(std::move( aEventHdl )),
73 m_sGroupId(std::move( aGroupId )),
74 m_nGroupIndex( nGroupIndex ) {}
77 // struct OptionsNode ----------------------------------------------------
79 struct OptionsNode
81 OUString m_sId;
82 OUString m_sLabel;
83 bool m_bAllModules;
84 std::vector< std::unique_ptr<OptionsLeaf> > m_aLeaves;
85 std::vector< std::vector< std::unique_ptr<OptionsLeaf> > >
86 m_aGroupedLeaves;
88 OptionsNode( OUString aId,
89 OUString aLabel,
90 bool bAllModules ) :
91 m_sId(std::move( aId )),
92 m_sLabel(std::move( aLabel )),
93 m_bAllModules( bAllModules ) {}
96 typedef std::vector< std::unique_ptr<OptionsNode> > VectorOfNodes;
98 struct LastPageSaver
100 sal_uInt16 m_nLastPageId;
101 OUString m_sLastPageURL_Tools;
102 OUString m_sLastPageURL_ExtMgr;
104 LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
107 // class OfaTreeOptionsDialog --------------------------------------------
109 namespace com::sun::star::frame { class XFrame; }
110 namespace com::sun::star::awt { class XContainerWindowProvider; }
112 struct OptionsPageInfo;
113 struct Module;
114 class ExtensionsTabPage;
115 class SvxColorTabPage;
116 struct OptionsGroupInfo;
118 class OfaTreeOptionsDialog final: public SfxOkDialogController
120 private:
121 std::unique_ptr<weld::Button> xOkPB;
122 std::unique_ptr<weld::Button> xApplyPB;
123 std::unique_ptr<weld::Button> xBackPB;
125 std::unique_ptr<weld::TreeView> xTreeLB;
126 std::unique_ptr<weld::Container> xTabBox;
128 weld::Window* m_pParent;
130 std::unique_ptr<weld::TreeIter> xCurrentPageEntry;
132 OUString sTitle;
134 bool bForgetSelection;
135 bool bIsFromExtensionManager;
137 // check "for the current document only" and set focus to "Western" languages box
138 bool bIsForSetDocumentLanguage;
140 bool bNeedsRestart;
141 svtools::RestartReason eRestartReason;
143 css::uno::Reference < css::awt::XContainerWindowProvider >
144 m_xContainerWinProvider;
145 css::uno::Reference<css::frame::XFrame> m_xFrame;
147 static LastPageSaver* pLastPageSaver;
149 std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId );
150 static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
151 void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame );
153 void LoadExtensionOptions( std::u16string_view rExtensionId );
154 static OUString GetModuleIdentifier( const css::uno::Reference<
155 css::frame::XFrame >& xFrame );
156 static std::unique_ptr<Module> LoadModule( std::u16string_view rModuleIdentifier );
157 static VectorOfNodes LoadNodes( Module* pModule, std::u16string_view rExtensionId );
158 void InsertNodes( const VectorOfNodes& rNodeList );
160 void ApplyOptions();
162 DECL_LINK(ShowPageHdl_Impl, weld::TreeView&, void);
163 DECL_LINK(BackHdl_Impl, weld::Button&, void);
164 DECL_LINK(ApplyHdl_Impl, weld::Button&, void);
165 DECL_LINK(HelpHdl_Impl, weld::Widget&, bool);
166 void ResetCurrentPageFromConfig();
167 void SelectHdl_Impl();
169 void InitItemSets(OptionsGroupInfo& rGroupInfo);
171 virtual short run() override;
173 virtual weld::Button& GetOKButton() const override { return *xOkPB; }
174 virtual const SfxItemSet* GetExampleSet() const override { return nullptr; }
176 // Common initialization
177 OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager);
179 public:
180 OfaTreeOptionsDialog(weld::Window* pParent,
181 const css::uno::Reference< css::frame::XFrame >& _xFrame,
182 bool bActivateLastSelection);
183 OfaTreeOptionsDialog(weld::Window* pParent, std::u16string_view rExtensionId);
184 virtual ~OfaTreeOptionsDialog() override;
186 OptionsPageInfo* AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup );
187 sal_uInt16 AddGroup( const OUString& rGroupName, SfxShell* pCreateShell,
188 SfxModule* pCreateModule, sal_uInt16 nDialogId );
190 void ActivateLastSelection();
191 void ActivatePage( sal_uInt16 nResId );
192 void ActivatePage( const OUString& rPageURL );
193 void ApplyItemSets();
195 // helper functions to call the language settings TabPage from the SpellDialog
196 static void ApplyLanguageOptions(const SfxItemSet& rSet);
197 static OUString getCurrentFactory_Impl( const css::uno::Reference< css::frame::XFrame >& _xFrame );
199 void SetNeedsRestart( svtools::RestartReason eReason );
202 // class ExtensionsTabPage -----------------------------------------------
204 namespace com::sun::star::awt { class XWindow; }
205 namespace com::sun::star::awt { class XContainerWindowEventHandler; }
207 class ExtensionsTabPage
209 private:
210 weld::Container* m_pContainer;
211 OUString m_sPageURL;
212 css::uno::Reference<css::awt::XWindow> m_xPageParent;
213 css::uno::Reference<css::awt::XWindow> m_xPage;
214 OUString m_sEventHdl;
215 css::uno::Reference< css::awt::XContainerWindowEventHandler >
216 m_xEventHdl;
217 css::uno::Reference< css::awt::XContainerWindowProvider >
218 m_xWinProvider;
220 void CreateDialogWithHandler();
221 bool DispatchAction( const OUString& rAction );
223 public:
224 ExtensionsTabPage(
225 weld::Container* pParent,
226 OUString rPageURL, OUString aEvtHdl,
227 const css::uno::Reference<
228 css::awt::XContainerWindowProvider >& rProvider );
230 ~ExtensionsTabPage();
232 void Show();
233 void Hide();
235 void ActivatePage();
236 void DeactivatePage();
238 void ResetPage();
239 void SavePage();
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */