Line data Source code
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 : #ifndef INCLUDED_CUI_SOURCE_INC_ACCCFG_HXX
21 : #define INCLUDED_CUI_SOURCE_INC_ACCCFG_HXX
22 :
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <com/sun/star/container/XIndexContainer.hpp>
25 : #include <com/sun/star/frame/XModuleManager.hpp>
26 : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
27 : #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
28 : #include <com/sun/star/frame/XStorable.hpp>
29 : #include <com/sun/star/uno/XComponentContext.hpp>
30 : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
31 : #include <com/sun/star/script/browse/XBrowseNode.hpp>
32 : #include <com/sun/star/container/XNameAccess.hpp>
33 : #include <com/sun/star/frame/XFrame.hpp>
34 :
35 : #include <algorithm>
36 :
37 : #include <vcl/fixed.hxx>
38 : #include <vcl/button.hxx>
39 : #include <vcl/dialog.hxx>
40 : #include <vcl/lstbox.hxx>
41 : #include <vcl/group.hxx>
42 : #include <svtools/svtabbx.hxx>
43 : #include <svtools/treelistbox.hxx>
44 : #include <sfx2/tabdlg.hxx>
45 : #include <sfx2/basedlgs.hxx>
46 : #include "cfgutil.hxx"
47 :
48 : class SfxMacroInfoItem;
49 : class SfxConfigGroupListBox;
50 : class SfxConfigFunctionListBox;
51 : class SfxAcceleratorConfigPage;
52 : class SfxStringItem;
53 :
54 0 : class SfxAccCfgTabListBox_Impl : public SvTabListBox
55 : {
56 : SfxAcceleratorConfigPage* m_pAccelConfigPage;
57 :
58 : void KeyInput( const KeyEvent &rKEvt ) SAL_OVERRIDE;
59 :
60 : protected:
61 : virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&,
62 : const Image&, SvLBoxButtonKind eButtonKind) SAL_OVERRIDE;
63 :
64 : public:
65 0 : SfxAccCfgTabListBox_Impl(vcl::Window *pParent, WinBits nStyle)
66 : : SvTabListBox(pParent, nStyle)
67 0 : , m_pAccelConfigPage(NULL)
68 : {
69 0 : }
70 :
71 0 : void SetAccelConfigPage(SfxAcceleratorConfigPage* pAccelConfigPage)
72 : {
73 0 : m_pAccelConfigPage = pAccelConfigPage;
74 0 : }
75 :
76 : void ReplaceEntry( sal_uInt16 nPos, const OUString &rStr );
77 : };
78 :
79 : // class SfxAcceleratorConfigPage ----------------------------------------
80 :
81 0 : struct TAccInfo
82 : {
83 : public:
84 0 : TAccInfo( sal_Int32 nKeyPos ,
85 : sal_Int32 nListPos,
86 : const vcl::KeyCode& aKey )
87 : : m_nKeyPos (nKeyPos )
88 : , m_nListPos (nListPos )
89 : , m_bIsConfigurable(true ) /**< its important to set sal_True as default -
90 : because only fix entries will be disabled later ... */
91 : , m_sCommand ( )
92 0 : , m_aKey (aKey )
93 0 : {}
94 :
95 0 : bool isConfigured() const
96 : {
97 0 : return (m_nKeyPos>-1 && m_nListPos>-1 && !m_sCommand.isEmpty());
98 : }
99 :
100 : sal_Int32 m_nKeyPos;
101 : sal_Int32 m_nListPos;
102 : bool m_bIsConfigurable;
103 : OUString m_sCommand;
104 : vcl::KeyCode m_aKey;
105 : };
106 :
107 : namespace sfx2
108 : {
109 : class FileDialogHelper;
110 : }
111 :
112 : class SfxAcceleratorConfigPage : public SfxTabPage
113 : {
114 : friend class SfxAccCfgTabListBox_Impl;
115 : private:
116 : const SfxMacroInfoItem* m_pMacroInfoItem;
117 : const SfxStringItem* m_pStringItem;
118 : const SfxStringItem* m_pFontItem;
119 : sfx2::FileDialogHelper* m_pFileDlg;
120 :
121 : SfxAccCfgTabListBox_Impl* m_pEntriesBox;
122 : RadioButton* m_pOfficeButton;
123 : RadioButton* m_pModuleButton;
124 : PushButton* m_pChangeButton;
125 : PushButton* m_pRemoveButton;
126 : SfxConfigGroupListBox* m_pGroupLBox;
127 : SfxConfigFunctionListBox* m_pFunctionBox;
128 : SvTreeListBox* m_pKeyBox;
129 : PushButton* m_pLoadButton;
130 : PushButton* m_pSaveButton;
131 : PushButton* m_pResetButton;
132 : OUString aLoadAccelConfigStr;
133 : OUString aSaveAccelConfigStr;
134 : OUString aFilterAllStr;
135 : OUString aFilterCfgStr;
136 : SfxStylesInfo_Impl m_aStylesInfo;
137 : bool m_bStylesInfoInitialized;
138 :
139 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
140 : css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal;
141 : css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule;
142 : css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct;
143 : css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
144 : css::uno::Reference< css::frame::XFrame > m_xFrame;
145 :
146 : OUString m_sModuleLongName;
147 : OUString m_sModuleShortName;
148 : OUString m_sModuleUIName;
149 :
150 : DECL_LINK(ChangeHdl, void *);
151 : DECL_LINK(RemoveHdl, void *);
152 : DECL_LINK( SelectHdl, Control * );
153 : DECL_LINK(Save, void *);
154 : DECL_LINK(Load, void *);
155 : DECL_LINK(Default, void *);
156 : DECL_LINK(RadioHdl, void *);
157 :
158 : DECL_LINK(LoadHdl, void *);
159 : DECL_LINK(SaveHdl, void *);
160 :
161 : OUString GetLabel4Command(const OUString& rCommand);
162 : void InitAccCfg();
163 : sal_uLong MapKeyCodeToPos( const vcl::KeyCode &rCode ) const;
164 : css::uno::Reference< css::frame::XModel > SearchForAlreadyLoadedDoc(const OUString& sName);
165 : void StartFileDialog( WinBits nBits, const OUString& rTitle );
166 :
167 : void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
168 : void ResetConfig();
169 :
170 : void CreateCustomItems( SvTreeListEntry* pEntry, const OUString& aCol1, const OUString& aCol2 );
171 :
172 : public:
173 : SfxAcceleratorConfigPage( vcl::Window *pParent, const SfxItemSet& rItemSet );
174 : virtual ~SfxAcceleratorConfigPage();
175 :
176 : virtual bool FillItemSet( SfxItemSet* ) SAL_OVERRIDE;
177 : virtual void Reset( const SfxItemSet* ) SAL_OVERRIDE;
178 :
179 : void Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
180 : };
181 :
182 : #endif
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|