xref: /aoo42x/main/cui/source/inc/acccfg.hxx (revision c4eee24d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _ACCCFG_HXX
25 #define _ACCCFG_HXX
26 
27 // #include *****************************************************************
28 
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/container/XIndexContainer.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/frame/XModuleManager.hpp>
33 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
34 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
35 #include <com/sun/star/frame/XFrame.hpp>
36 #include <com/sun/star/frame/XStorable.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
39 #include <com/sun/star/script/browse/XBrowseNode.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <com/sun/star/frame/XFrame.hpp>
42 
43 #include <algorithm>
44 
45 #include <vcl/fixed.hxx>
46 #include <vcl/button.hxx>
47 #include <vcl/dialog.hxx>
48 #include <vcl/lstbox.hxx>
49 #include <vcl/group.hxx>
50 #include <svtools/svtabbx.hxx>
51 #include <svtools/svtreebx.hxx>
52 #include <sfx2/tabdlg.hxx>
53 #include <sfx2/basedlgs.hxx>
54 
55 #define _SVSTDARR_STRINGSDTOR
56 #include <svl/svstdarr.hxx>
57 
58 #include <sfx2/minarray.hxx>
59 
60 #include "cfgutil.hxx"
61 
62 // class SfxAcceleratorConfigListBox *************************************************
63 
64 #define css ::com::sun::star
65 
66 class SfxMacroInfoItem;
67 class SfxConfigGroupListBox_Impl;
68 class SfxConfigFunctionListBox_Impl;
69 class SfxAcceleratorConfigPage;
70 
71 class SfxAccCfgTabListBox_Impl : public SvTabListBox
72 {
73 	SfxAcceleratorConfigPage*	m_pAccelConfigPage;
74 
75 	void 						KeyInput( const KeyEvent &rKEvt );
76 
77 protected:
78 	virtual void				InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image&, SvLBoxButtonKind eButtonKind );
79 
80 public:
SfxAccCfgTabListBox_Impl(SfxAcceleratorConfigPage * pAccelConfigPage,Window * pParent,const ResId & rResId)81 								SfxAccCfgTabListBox_Impl(
82 										SfxAcceleratorConfigPage* pAccelConfigPage,
83 										Window *pParent,
84 										const ResId &rResId ) :
85 									 SvTabListBox( pParent, rResId ),
86 									m_pAccelConfigPage( pAccelConfigPage )
87 								{}
88 
89 	void 						ReplaceEntry( sal_uInt16 nPos, const String &rStr );
90 };
91 
92 // class SfxAcceleratorConfigPage ----------------------------------------
93 
94 struct TAccInfo
95 {
96     public:
97 
TAccInfoTAccInfo98         TAccInfo(      sal_Int32 nKeyPos ,
99                        sal_Int32 nListPos,
100                  const KeyCode&  aKey    )
101             : m_nKeyPos        (nKeyPos  )
102             , m_nListPos       (nListPos )
103             , m_bIsConfigurable(sal_True )
104             , m_sCommand       (         )
105             , m_aKey           (aKey     )
106             // its important to set sal_True as default -
107             // because only fix entries will be disabled later ...
108         {}
109 
isConfiguredTAccInfo110         sal_Bool isConfigured() const
111         {
112             return (m_nKeyPos>-1 && m_nListPos>-1 && m_sCommand.getLength());
113         }
114 
115         sal_Int32 m_nKeyPos;
116         sal_Int32 m_nListPos;
117         sal_Bool m_bIsConfigurable;
118         ::rtl::OUString m_sCommand;
119         KeyCode m_aKey;
120 };
121 
122 namespace sfx2
123 {
124     class FileDialogHelper;
125 }
126 
127 class SfxAcceleratorConfigPage : public SfxTabPage
128 {
129 	friend class SfxAccCfgTabListBox_Impl;
130 private:
131 	const SfxMacroInfoItem*			m_pMacroInfoItem;
132 	const SfxStringItem*			m_pStringItem;
133 	const SfxStringItem*			m_pFontItem;
134     sfx2::FileDialogHelper*         m_pFileDlg;
135 
136 	SfxAccCfgTabListBox_Impl		aEntriesBox;
137     FixedLine                       aKeyboardGroup;
138  	RadioButton						aOfficeButton;
139 	RadioButton						aModuleButton;
140 	PushButton         				aChangeButton;
141 	PushButton         				aRemoveButton;
142 	FixedText          				aGroupText;
143     SfxConfigGroupListBox_Impl*     pGroupLBox;
144 	FixedText          				aFunctionText;
145 	SfxConfigFunctionListBox_Impl*	pFunctionBox;
146 	FixedText          				aKeyText;
147 	SvTreeListBox     				aKeyBox;
148     FixedLine                       aFunctionsGroup;
149 	PushButton						aLoadButton;
150 	PushButton						aSaveButton;
151 	PushButton		   				aResetButton;
152 	String				aLoadAccelConfigStr;
153 	String				aSaveAccelConfigStr;
154 	String				aFilterAllStr;
155 	String				aFilterCfgStr;
156     SfxStylesInfo_Impl              m_aStylesInfo;
157     sal_Bool                        m_bStylesInfoInitialized;
158 
159     css::uno::Reference< css::lang::XMultiServiceFactory >     m_xSMGR;
160     css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal;
161     css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule;
162     css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct;
163     css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
164     css::uno::Reference< css::frame::XFrame > m_xFrame;
165 
166     ::rtl::OUString m_sModuleLongName;
167     ::rtl::OUString m_sModuleShortName;
168     ::rtl::OUString m_sModuleUIName;
169 
170 	DECL_LINK( 					ChangeHdl, Button * );
171 	DECL_LINK( 					RemoveHdl, Button * );
172 	DECL_LINK( 					SelectHdl, Control * );
173 	DECL_LINK( 					Save, Button * );
174 	DECL_LINK( 					Load, Button * );
175 	DECL_LINK( 					Default, PushButton * );
176 	DECL_LINK(					RadioHdl, RadioButton* );
177 
178     DECL_LINK(                  LoadHdl, sfx2::FileDialogHelper* );
179     DECL_LINK(                  SaveHdl, sfx2::FileDialogHelper* );
180 
181     String                      GetLabel4Command(const String& sCommand);
182     void                        InitAccCfg();
183 	sal_uInt16  					MapKeyCodeToPos( const KeyCode &rCode ) const;
184     css::uno::Reference< css::frame::XModel > SearchForAlreadyLoadedDoc(const String& sName);
185     void                        StartFileDialog( WinBits nBits, const String& rTitle );
186 
187 	void 						Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
188 	void 						ResetConfig();
189 
190 	void						CreateCustomItems( SvLBoxEntry* pEntry, const String& aCol1, const String& aCol2 );
191 
192 public:
193 								SfxAcceleratorConfigPage( Window *pParent, const SfxItemSet& rItemSet );
194 	virtual 					~SfxAcceleratorConfigPage();
195 
196 	virtual sal_Bool				FillItemSet( SfxItemSet& );
197 	virtual void				Reset( const SfxItemSet& );
198 
199     void                        Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
200 	static SfxTabPage*			Create( Window* pParent, const SfxItemSet& rAttrSet );
201 };
202 
203 
204 class SfxAcceleratorConfigListBox : public ListBox
205 {
206 	void KeyInput( const KeyEvent &rKEvt );
207 
208 public:
209 
SfxAcceleratorConfigListBox(Window * pParent,ResId & rResId)210 	SfxAcceleratorConfigListBox( Window *pParent, ResId &rResId ) :
211 		ListBox( pParent, rResId ) {}
212 
213 	void ReplaceEntry( sal_uInt16 nPos, const String &rStr );
214 	void ExpandEntry ( sal_uInt16 nPos, const String &rStr );
215 };
216 
217 class SvxShortcutAssignDlg : public SfxSingleTabDialog
218 {
219 public:
220     SvxShortcutAssignDlg(
221         Window* pParent,
222         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame,
223         const SfxItemSet& rSet );
224 	virtual	~SvxShortcutAssignDlg();
225 };
226 
227 
228 
229 #undef css
230 
231 #endif
232 
233