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 .
20 #ifndef INCLUDED_CUI_SOURCE_INC_TREEOPT_HXX
21 #define INCLUDED_CUI_SOURCE_INC_TREEOPT_HXX
23 #include <sal/config.h>
27 #include <sfx2/basedlgs.hxx>
28 #include <svtools/restartdialog.hxx>
33 // struct OrderedEntry ---------------------------------------------------
40 OrderedEntry( sal_Int32 nIndex
, const OUString
& rId
) :
41 m_nIndex( nIndex
), m_sId( rId
) {}
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( const OUString
& rLabel
,
66 const OUString
& rPageURL
,
67 const OUString
& rEventHdl
,
68 const OUString
& rGroupId
,
69 sal_Int32 nGroupIndex
) :
71 m_sPageURL( rPageURL
),
72 m_sEventHdl( rEventHdl
),
73 m_sGroupId( rGroupId
),
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( const OUString
& rId
,
89 const OUString
& rLabel
,
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
{ namespace sun
{ namespace star
{ namespace frame
{ class XFrame
; } } } }
110 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XContainerWindowProvider
; } } } }
112 struct OptionsPageInfo
;
114 class ExtensionsTabPage
;
115 class SvxColorTabPage
;
117 class OfaTreeOptionsDialog final
: public SfxOkDialogController
120 std::unique_ptr
<weld::Button
> xOkPB
;
121 std::unique_ptr
<weld::Button
> xApplyPB
;
122 std::unique_ptr
<weld::Button
> xBackPB
;
124 std::unique_ptr
<weld::TreeView
> xTreeLB
;
125 std::unique_ptr
<weld::Container
> xTabBox
;
127 weld::Window
* m_pParent
;
129 std::unique_ptr
<weld::TreeIter
> xCurrentPageEntry
;
133 bool bForgetSelection
;
134 bool bIsFromExtensionManager
;
136 // check "for the current document only" and set focus to "Western" languages box
137 bool bIsForSetDocumentLanguage
;
140 svtools::RestartReason eRestartReason
;
142 css::uno::Reference
< css::awt::XContainerWindowProvider
>
143 m_xContainerWinProvider
;
145 static LastPageSaver
* pLastPageSaver
;
147 std::unique_ptr
<SfxItemSet
> CreateItemSet( sal_uInt16 nId
);
148 static void ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
);
149 void InitTreeAndHandler();
150 void Initialize( const css::uno::Reference
< css::frame::XFrame
>& _xFrame
);
153 void LoadExtensionOptions( const OUString
& rExtensionId
);
154 static OUString
GetModuleIdentifier( const css::uno::Reference
<
155 css::frame::XFrame
>& xFrame
);
156 static std::unique_ptr
<Module
> LoadModule( const OUString
& rModuleIdentifier
);
157 static VectorOfNodes
LoadNodes( Module
* pModule
, const OUString
& rExtensionId
);
158 void InsertNodes( const VectorOfNodes
& rNodeList
);
160 void ApplyOptions( bool deactivate
);
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(OKHdl_Impl
, weld::Button
&, void);
166 void SelectHdl_Impl();
168 virtual short run() override
;
170 virtual weld::Button
& GetOKButton() const override
{ return *xOkPB
; }
171 virtual const SfxItemSet
* GetExampleSet() const override
{ return nullptr; }
174 OfaTreeOptionsDialog(weld::Window
* pParent
,
175 const css::uno::Reference
< css::frame::XFrame
>& _xFrame
,
176 bool bActivateLastSelection
);
177 OfaTreeOptionsDialog(weld::Window
* pParent
, const OUString
& rExtensionId
);
178 virtual ~OfaTreeOptionsDialog() override
;
180 OptionsPageInfo
* AddTabPage( sal_uInt16 nId
, const OUString
& rPageName
, sal_uInt16 nGroup
);
181 sal_uInt16
AddGroup( const OUString
& rGroupName
, SfxShell
* pCreateShell
,
182 SfxModule
* pCreateModule
, sal_uInt16 nDialogId
);
184 void ActivateLastSelection();
185 void ActivatePage( sal_uInt16 nResId
);
186 void ActivatePage( const OUString
& rPageURL
);
187 void ApplyItemSets();
189 // helper functions to call the language settings TabPage from the SpellDialog
190 static void ApplyLanguageOptions(const SfxItemSet
& rSet
);
192 void SetNeedsRestart( svtools::RestartReason eReason
);
195 // class ExtensionsTabPage -----------------------------------------------
197 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XWindow
; } } } }
198 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XContainerWindowEventHandler
; } } } }
200 class ExtensionsTabPage
203 weld::Container
* m_pContainer
;
205 css::uno::Reference
<css::awt::XWindow
> m_xPageParent
;
206 css::uno::Reference
<css::awt::XWindow
> m_xPage
;
207 OUString m_sEventHdl
;
208 css::uno::Reference
< css::awt::XContainerWindowEventHandler
>
210 css::uno::Reference
< css::awt::XContainerWindowProvider
>
213 void CreateDialogWithHandler();
214 bool DispatchAction( const OUString
& rAction
);
218 weld::Container
* pParent
,
219 const OUString
& rPageURL
, const OUString
& rEvtHdl
,
220 const css::uno::Reference
<
221 css::awt::XContainerWindowProvider
>& rProvider
);
223 ~ExtensionsTabPage();
229 void DeactivatePage();
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */