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