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 _ACCCFG_HXX
21 : #define _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_Impl;
50 : class SfxConfigFunctionListBox_Impl;
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 );
59 :
60 : protected:
61 : virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&,
62 : const Image&, SvLBoxButtonKind eButtonKind);
63 :
64 : public:
65 0 : SfxAccCfgTabListBox_Impl(
66 : SfxAcceleratorConfigPage* pAccelConfigPage,
67 : Window *pParent,
68 : const ResId &rResId ) :
69 : SvTabListBox( pParent, rResId ),
70 0 : m_pAccelConfigPage( pAccelConfigPage )
71 0 : {}
72 :
73 : void ReplaceEntry( sal_uInt16 nPos, const String &rStr );
74 : };
75 :
76 : // class SfxAcceleratorConfigPage ----------------------------------------
77 :
78 0 : struct TAccInfo
79 : {
80 : public:
81 0 : TAccInfo( sal_Int32 nKeyPos ,
82 : sal_Int32 nListPos,
83 : const KeyCode& aKey )
84 : : m_nKeyPos (nKeyPos )
85 : , m_nListPos (nListPos )
86 : , m_bIsConfigurable(sal_True ) /**< its important to set sal_True as default -
87 : because only fix entries will be disabled later ... */
88 : , m_sCommand ( )
89 0 : , m_aKey (aKey )
90 0 : {}
91 :
92 0 : sal_Bool isConfigured() const
93 : {
94 0 : return (m_nKeyPos>-1 && m_nListPos>-1 && !m_sCommand.isEmpty());
95 : }
96 :
97 : sal_Int32 m_nKeyPos;
98 : sal_Int32 m_nListPos;
99 : sal_Bool m_bIsConfigurable;
100 : OUString m_sCommand;
101 : KeyCode m_aKey;
102 : };
103 :
104 : namespace sfx2
105 : {
106 : class FileDialogHelper;
107 : }
108 :
109 : class SfxAcceleratorConfigPage : public SfxTabPage
110 : {
111 : friend class SfxAccCfgTabListBox_Impl;
112 : private:
113 : const SfxMacroInfoItem* m_pMacroInfoItem;
114 : const SfxStringItem* m_pStringItem;
115 : const SfxStringItem* m_pFontItem;
116 : sfx2::FileDialogHelper* m_pFileDlg;
117 :
118 : SfxAccCfgTabListBox_Impl aEntriesBox;
119 : FixedLine aKeyboardGroup;
120 : RadioButton aOfficeButton;
121 : RadioButton aModuleButton;
122 : PushButton aChangeButton;
123 : PushButton aRemoveButton;
124 : FixedText aGroupText;
125 : SfxConfigGroupListBox_Impl* pGroupLBox;
126 : FixedText aFunctionText;
127 : SfxConfigFunctionListBox_Impl* pFunctionBox;
128 : FixedText aKeyText;
129 : SvTreeListBox aKeyBox;
130 : FixedLine aFunctionsGroup;
131 : PushButton aLoadButton;
132 : PushButton aSaveButton;
133 : PushButton aResetButton;
134 : String aLoadAccelConfigStr;
135 : String aSaveAccelConfigStr;
136 : String aFilterAllStr;
137 : String aFilterCfgStr;
138 : SfxStylesInfo_Impl m_aStylesInfo;
139 : sal_Bool m_bStylesInfoInitialized;
140 :
141 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
142 : css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal;
143 : css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule;
144 : css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct;
145 : css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
146 : css::uno::Reference< css::frame::XFrame > m_xFrame;
147 :
148 : OUString m_sModuleLongName;
149 : OUString m_sModuleShortName;
150 : OUString m_sModuleUIName;
151 :
152 : DECL_LINK(ChangeHdl, void *);
153 : DECL_LINK(RemoveHdl, void *);
154 : DECL_LINK( SelectHdl, Control * );
155 : DECL_LINK(Save, void *);
156 : DECL_LINK(Load, void *);
157 : DECL_LINK(Default, void *);
158 : DECL_LINK(RadioHdl, void *);
159 :
160 : DECL_LINK(LoadHdl, void *);
161 : DECL_LINK(SaveHdl, void *);
162 :
163 : String GetLabel4Command(const String& sCommand);
164 : void InitAccCfg();
165 : sal_uInt16 MapKeyCodeToPos( const KeyCode &rCode ) const;
166 : css::uno::Reference< css::frame::XModel > SearchForAlreadyLoadedDoc(const String& sName);
167 : void StartFileDialog( WinBits nBits, const String& rTitle );
168 :
169 : void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
170 : void ResetConfig();
171 :
172 : void CreateCustomItems( SvTreeListEntry* pEntry, const String& aCol1, const String& aCol2 );
173 :
174 : public:
175 : SfxAcceleratorConfigPage( Window *pParent, const SfxItemSet& rItemSet );
176 : virtual ~SfxAcceleratorConfigPage();
177 :
178 : virtual sal_Bool FillItemSet( SfxItemSet& );
179 : virtual void Reset( const SfxItemSet& );
180 :
181 : void Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
182 : static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
183 : };
184 :
185 :
186 : class SfxAcceleratorConfigListBox : public ListBox
187 : {
188 : void KeyInput( const KeyEvent &rKEvt );
189 :
190 : public:
191 :
192 : SfxAcceleratorConfigListBox( Window *pParent, ResId &rResId ) :
193 : ListBox( pParent, rResId ) {}
194 :
195 : void ReplaceEntry( sal_uInt16 nPos, const String &rStr );
196 : void ExpandEntry ( sal_uInt16 nPos, const String &rStr );
197 : };
198 :
199 : class SvxShortcutAssignDlg : public SfxNoLayoutSingleTabDialog
200 : {
201 : public:
202 : SvxShortcutAssignDlg(
203 : Window* pParent,
204 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame,
205 : const SfxItemSet& rSet );
206 : virtual ~SvxShortcutAssignDlg();
207 : };
208 :
209 : #endif
210 :
211 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|