LibreOffice Module cui (master)  1
acccfg.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/container/XNameAccess.hpp>
25 #include <com/sun/star/frame/XFrame.hpp>
26 
27 #include <sfx2/tabdlg.hxx>
28 #include <vcl/idle.hxx>
29 #include <vcl/keycod.hxx>
30 #include <i18nutil/searchopt.hxx>
31 #include <config_features.h>
32 #include "cfgutil.hxx"
33 
34 #if HAVE_FEATURE_SCRIPTING
35 class SfxMacroInfoItem;
36 #endif
39 class SfxStringItem;
40 
41 // class SfxAcceleratorConfigPage ----------------------------------------
42 
43 struct TAccInfo
44 {
45 public:
46  TAccInfo(sal_Int32 nKeyPos, sal_Int32 nListPos, const vcl::KeyCode& aKey)
47  : m_nKeyPos(nKeyPos)
48  , m_nListPos(nListPos)
49  , m_bIsConfigurable(true)
51  , m_sCommand()
52  , m_aKey(aKey)
53  {
54  }
55 
56  bool isConfigured() const
57  {
58  return (m_nKeyPos > -1 && m_nListPos > -1 && !m_sCommand.isEmpty());
59  }
60 
61  sal_Int32 m_nKeyPos;
62  sal_Int32 m_nListPos;
64  OUString m_sCommand;
66 };
67 
68 namespace sfx2
69 {
70 class FileDialogHelper;
71 }
72 
74 {
75  Open,
76  SaveAs
77 };
78 
80 {
81 private:
82 #if HAVE_FEATURE_SCRIPTING
83  const SfxMacroInfoItem* m_pMacroInfoItem;
84 #endif
85  std::unique_ptr<sfx2::FileDialogHelper> m_pFileDlg;
86 
89  OUString aFilterAllStr;
90  OUString aFilterCfgStr;
93 
94  css::uno::Reference<css::uno::XComponentContext> m_xContext;
95  css::uno::Reference<css::ui::XAcceleratorConfiguration> m_xGlobal;
96  css::uno::Reference<css::ui::XAcceleratorConfiguration> m_xModule;
97  css::uno::Reference<css::ui::XAcceleratorConfiguration> m_xAct;
98  css::uno::Reference<css::container::XNameAccess> m_xUICmdDescription;
99  css::uno::Reference<css::frame::XFrame> m_xFrame;
100 
102  OUString m_sModuleUIName;
103 
104  // For search
107 
109 
110  std::unique_ptr<weld::TreeView> m_xEntriesBox;
111  std::unique_ptr<weld::RadioButton> m_xOfficeButton;
112  std::unique_ptr<weld::RadioButton> m_xModuleButton;
113  std::unique_ptr<weld::Button> m_xChangeButton;
114  std::unique_ptr<weld::Button> m_xRemoveButton;
115  std::unique_ptr<CuiConfigGroupListBox> m_xGroupLBox;
116  std::unique_ptr<CuiConfigFunctionListBox> m_xFunctionBox;
117  std::unique_ptr<weld::TreeView> m_xKeyBox;
118  std::unique_ptr<weld::Entry> m_xSearchEdit;
119  std::unique_ptr<weld::Button> m_xLoadButton;
120  std::unique_ptr<weld::Button> m_xSaveButton;
121  std::unique_ptr<weld::Button> m_xResetButton;
122 
123  DECL_LINK(ChangeHdl, weld::Button&, void);
124  DECL_LINK(RemoveHdl, weld::Button&, void);
125  DECL_LINK(SelectHdl, weld::TreeView&, void);
126  DECL_LINK(SearchUpdateHdl, weld::Entry&, void);
127  DECL_LINK(Save, weld::Button&, void);
128  DECL_LINK(Load, weld::Button&, void);
129  DECL_LINK(Default, weld::Button&, void);
130  DECL_LINK(RadioHdl, weld::Toggleable&, void);
131  DECL_LINK(ImplUpdateDataHdl, Timer*, void);
132  DECL_LINK(FocusOut_Impl, weld::Widget&, void);
133  DECL_LINK(TimeOut_Impl, Timer*, void);
134 
135  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
136 
137  DECL_LINK(LoadHdl, sfx2::FileDialogHelper*, void);
138  DECL_LINK(SaveHdl, sfx2::FileDialogHelper*, void);
139 
140  OUString GetLabel4Command(const OUString& rCommand);
141  int applySearchFilter(OUString const& rSearchTerm);
142  void InitAccCfg();
143  sal_Int32 MapKeyCodeToPos(const vcl::KeyCode& rCode) const;
144  void StartFileDialog(StartFileDialogType nType, const OUString& rTitle);
145 
146  void Init(const css::uno::Reference<css::ui::XAcceleratorConfiguration>& pAccMgr);
147  void ResetConfig();
148 
149 public:
151  const SfxItemSet& rItemSet);
152  virtual ~SfxAcceleratorConfigPage() override;
153 
154  virtual bool FillItemSet(SfxItemSet*) override;
155  virtual void Reset(const SfxItemSet*) override;
156 
157  void Apply(const css::uno::Reference<css::ui::XAcceleratorConfiguration>& pAccMgr);
158 };
159 
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration > &pAccMgr)
Definition: acccfg.cxx:1054
OUString GetLabel4Command(const OUString &rCommand)
Definition: acccfg.cxx:1545
void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration > &pAccMgr)
Definition: acccfg.cxx:976
bool isConfigured() const
Definition: acccfg.hxx:56
DECL_LINK(ChangeHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xLoadButton
Definition: acccfg.hxx:119
sal_Int32 m_nListPos
Definition: acccfg.hxx:62
OUString m_sModuleLongName
Definition: acccfg.hxx:101
std::unique_ptr< weld::RadioButton > m_xModuleButton
Definition: acccfg.hxx:112
std::unique_ptr< CuiConfigGroupListBox > m_xGroupLBox
Definition: acccfg.hxx:115
SfxStylesInfo_Impl m_aStylesInfo
Definition: acccfg.hxx:91
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctionBox
Definition: acccfg.hxx:116
std::unique_ptr< weld::Entry > m_xSearchEdit
Definition: acccfg.hxx:118
sal_Int32 m_nKeyPos
Definition: acccfg.hxx:61
OUString aLoadAccelConfigStr
Definition: acccfg.hxx:87
std::unique_ptr< weld::Button > m_xSaveButton
Definition: acccfg.hxx:120
OUString m_sCommand
Definition: acccfg.hxx:64
std::unique_ptr< weld::TreeView > m_xKeyBox
Definition: acccfg.hxx:117
std::unique_ptr< weld::Button > m_xResetButton
Definition: acccfg.hxx:121
OUString aSaveAccelConfigStr
Definition: acccfg.hxx:88
sal_Int32 MapKeyCodeToPos(const vcl::KeyCode &rCode) const
Definition: acccfg.cxx:1528
vcl::KeyCode m_aKey
Definition: acccfg.hxx:65
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal
Definition: acccfg.hxx:95
virtual ~SfxAcceleratorConfigPage() override
Definition: acccfg.cxx:913
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule
Definition: acccfg.hxx:96
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: acccfg.hxx:94
StartFileDialogType
css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription
Definition: acccfg.hxx:98
std::unique_ptr< weld::Button > m_xRemoveButton
Definition: acccfg.hxx:114
i18nutil::SearchOptions2 m_options
Definition: acccfg.hxx:106
std::unique_ptr< weld::Button > m_xChangeButton
Definition: acccfg.hxx:113
std::unique_ptr< sfx2::FileDialogHelper > m_pFileDlg
Definition: acccfg.hxx:85
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: acccfg.hxx:99
virtual void Reset(const SfxItemSet *) override
Definition: acccfg.cxx:1492
int applySearchFilter(OUString const &rSearchTerm)
Definition: acccfg.cxx:1583
TAccInfo(sal_Int32 nKeyPos, sal_Int32 nListPos, const vcl::KeyCode &aKey)
< it's important to set true as default - because only fix entries will be disabled later...
Definition: acccfg.hxx:46
std::unique_ptr< weld::TreeView > m_xEntriesBox
Definition: acccfg.hxx:110
virtual bool FillItemSet(SfxItemSet *) override
Definition: acccfg.cxx:1473
void StartFileDialog(StartFileDialogType nType, const OUString &rTitle)
Definition: acccfg.cxx:1453
SfxAcceleratorConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rItemSet)
Definition: acccfg.cxx:825
bool m_bIsConfigurable
Definition: acccfg.hxx:63
std::unique_ptr< weld::RadioButton > m_xOfficeButton
Definition: acccfg.hxx:111
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct
Definition: acccfg.hxx:97