1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
26 #include <sfx2/basedlgs.hxx>
27 #include <svtools/restartdialog.hxx>
33 // struct OrderedEntry ---------------------------------------------------
40 OrderedEntry( sal_Int32 nIndex
, OUString aId
) :
41 m_nIndex( nIndex
), m_sId(std::move( aId
)) {}
45 // struct Module ---------------------------------------------------------
50 std::vector
< std::unique_ptr
<OrderedEntry
> > m_aNodeList
;
52 Module() : m_bActive( false ) {}
55 // struct OptionsLeaf ----------------------------------------------------
63 sal_Int32 m_nGroupIndex
;
65 OptionsLeaf( OUString aLabel
,
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 ----------------------------------------------------
84 std::vector
< std::unique_ptr
<OptionsLeaf
> > m_aLeaves
;
85 std::vector
< std::vector
< std::unique_ptr
<OptionsLeaf
> > >
88 OptionsNode( OUString aId
,
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
;
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
;
114 class ExtensionsTabPage
;
115 class SvxColorTabPage
;
116 struct OptionsGroupInfo
;
118 class OfaTreeOptionsDialog final
: public SfxOkDialogController
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
;
134 bool bForgetSelection
;
135 bool bIsFromExtensionManager
;
137 // check "for the current document only" and set focus to "Western" languages box
138 bool bIsForSetDocumentLanguage
;
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
);
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
);
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
210 weld::Container
* m_pContainer
;
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
>
217 css::uno::Reference
< css::awt::XContainerWindowProvider
>
220 void CreateDialogWithHandler();
221 bool DispatchAction( const OUString
& rAction
);
225 weld::Container
* pParent
,
226 OUString rPageURL
, OUString aEvtHdl
,
227 const css::uno::Reference
<
228 css::awt::XContainerWindowProvider
>& rProvider
);
230 ~ExtensionsTabPage();
236 void DeactivatePage();
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */