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