update dev300-m58
[ooovba.git] / svx / source / cui / acccfg.hxx
blobd115544cfb8e0ffe7d8612a6092f1da1b68ceb55
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: acccfg.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _ACCCFG_HXX
32 #define _ACCCFG_HXX
34 // #include *****************************************************************
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/container/XIndexContainer.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <com/sun/star/frame/XModuleManager.hpp>
40 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
41 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/frame/XStorable.hpp>
44 #include <com/sun/star/uno/XComponentContext.hpp>
45 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
46 #include <com/sun/star/script/browse/XBrowseNode.hpp>
47 #include <com/sun/star/container/XNameAccess.hpp>
48 #include <com/sun/star/frame/XFrame.hpp>
50 #include <algorithm>
52 #include <vcl/fixed.hxx>
53 #include <vcl/button.hxx>
54 #include <vcl/dialog.hxx>
55 #include <vcl/lstbox.hxx>
56 #include <vcl/group.hxx>
57 #include <svtools/svtabbx.hxx>
58 #include <svtools/svtreebx.hxx>
59 #include <sfx2/tabdlg.hxx>
60 #include <sfx2/basedlgs.hxx>
62 #define _SVSTDARR_STRINGSDTOR
63 #include <svtools/svstdarr.hxx>
65 #include <sfx2/minarray.hxx>
67 #include "cfgutil.hxx"
69 // class SfxAcceleratorConfigListBox *************************************************
71 #define css ::com::sun::star
73 class SfxMacroInfoItem;
74 class SfxConfigGroupListBox_Impl;
75 class SfxConfigFunctionListBox_Impl;
76 class SfxAcceleratorConfigPage;
78 class SfxAccCfgTabListBox_Impl : public SvTabListBox
80 SfxAcceleratorConfigPage* m_pAccelConfigPage;
82 void KeyInput( const KeyEvent &rKEvt );
84 protected:
85 virtual void InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image&, SvLBoxButtonKind eButtonKind );
87 public:
88 SfxAccCfgTabListBox_Impl(
89 SfxAcceleratorConfigPage* pAccelConfigPage,
90 Window *pParent,
91 const ResId &rResId ) :
92 SvTabListBox( pParent, rResId ),
93 m_pAccelConfigPage( pAccelConfigPage )
96 void ReplaceEntry( USHORT nPos, const String &rStr );
99 // class SfxAcceleratorConfigPage ----------------------------------------
101 struct TAccInfo
103 public:
105 TAccInfo( sal_Int32 nKeyPos ,
106 sal_Int32 nListPos,
107 const KeyCode& aKey )
108 : m_nKeyPos (nKeyPos )
109 , m_nListPos (nListPos )
110 , m_bIsConfigurable(sal_True )
111 , m_sCommand ( )
112 , m_aKey (aKey )
113 // its important to set TRUE as default -
114 // because only fix entries will be disabled later ...
117 sal_Bool isConfigured() const
119 return (m_nKeyPos>-1 && m_nListPos>-1 && m_sCommand.getLength());
122 sal_Int32 m_nKeyPos;
123 sal_Int32 m_nListPos;
124 sal_Bool m_bIsConfigurable;
125 ::rtl::OUString m_sCommand;
126 KeyCode m_aKey;
129 namespace sfx2
131 class FileDialogHelper;
134 class SfxAcceleratorConfigPage : public SfxTabPage
136 friend class SfxAccCfgTabListBox_Impl;
137 private:
138 const SfxMacroInfoItem* m_pMacroInfoItem;
139 const SfxStringItem* m_pStringItem;
140 const SfxStringItem* m_pFontItem;
141 sfx2::FileDialogHelper* m_pFileDlg;
143 SfxAccCfgTabListBox_Impl aEntriesBox;
144 FixedLine aKeyboardGroup;
145 RadioButton aOfficeButton;
146 RadioButton aModuleButton;
147 PushButton aChangeButton;
148 PushButton aRemoveButton;
149 FixedText aGroupText;
150 SfxConfigGroupListBox_Impl* pGroupLBox;
151 FixedText aFunctionText;
152 SfxConfigFunctionListBox_Impl* pFunctionBox;
153 FixedText aKeyText;
154 SvTreeListBox aKeyBox;
155 FixedLine aFunctionsGroup;
156 PushButton aLoadButton;
157 PushButton aSaveButton;
158 PushButton aResetButton;
159 String aLoadAccelConfigStr;
160 String aSaveAccelConfigStr;
161 String aFilterAllStr;
162 String aFilterCfgStr;
163 SfxStylesInfo_Impl m_aStylesInfo;
164 sal_Bool m_bStylesInfoInitialized;
166 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
167 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal;
168 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule;
169 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct;
170 css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
171 css::uno::Reference< css::frame::XFrame > m_xFrame;
173 ::rtl::OUString m_sModuleLongName;
174 ::rtl::OUString m_sModuleShortName;
175 ::rtl::OUString m_sModuleUIName;
177 DECL_LINK( ChangeHdl, Button * );
178 DECL_LINK( RemoveHdl, Button * );
179 DECL_LINK( SelectHdl, Control * );
180 DECL_LINK( Save, Button * );
181 DECL_LINK( Load, Button * );
182 DECL_LINK( Default, PushButton * );
183 DECL_LINK( RadioHdl, RadioButton* );
185 DECL_LINK( LoadHdl, sfx2::FileDialogHelper* );
186 DECL_LINK( SaveHdl, sfx2::FileDialogHelper* );
188 String GetLabel4Command(const String& sCommand);
189 void InitAccCfg();
190 KeyCode MapPosToKeyCode( USHORT nPos ) const;
191 USHORT MapKeyCodeToPos( const KeyCode &rCode ) const;
192 String GetFunctionName( KeyFuncType eType ) const;
193 css::uno::Reference< css::frame::XModel > SearchForAlreadyLoadedDoc(const String& sName);
194 void StartFileDialog( WinBits nBits, const String& rTitle );
196 void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
197 void ResetConfig();
199 void CreateCustomItems( SvLBoxEntry* pEntry, const String& aCol1, const String& aCol2 );
201 public:
202 SfxAcceleratorConfigPage( Window *pParent, const SfxItemSet& rItemSet );
203 virtual ~SfxAcceleratorConfigPage();
205 virtual BOOL FillItemSet( SfxItemSet& );
206 virtual void Reset( const SfxItemSet& );
208 void SelectMacro(const SfxMacroInfoItem*);
209 void Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);
210 void CopySource2Target(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xSourceAccMgr,
211 const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xTargetAccMgr);
212 static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
216 class SfxAcceleratorConfigListBox : public ListBox
218 void KeyInput( const KeyEvent &rKEvt );
220 public:
222 SfxAcceleratorConfigListBox( Window *pParent, ResId &rResId ) :
223 ListBox( pParent, rResId ) {}
225 void ReplaceEntry( USHORT nPos, const String &rStr );
226 void ExpandEntry ( USHORT nPos, const String &rStr );
230 // class USHORTArr **********************************************************
232 DECL_2BYTEARRAY(USHORTArr, USHORT, 10, 10)
234 // class SfxAcceleratorConfigDialog **************************************************
236 class SfxAcceleratorConfigDialog : public ModalDialog
238 OKButton aOKButton;
239 CancelButton aCancelButton;
240 PushButton aChangeButton;
241 PushButton aRemoveButton;
242 SfxAcceleratorConfigListBox aEntriesBox;
243 FixedText aDescriptionTextText;
244 FixedText aDescriptionInfoText;
245 FixedLine aKeyboardGroup;
246 FixedText aGroupText;
247 ListBox aGroupLBox;
248 FixedText aFunctionText;
249 ListBox aFunctionBox;
250 FixedText aKeyText;
251 ListBox aKeyBox;
252 FixedLine aFunctionsGroup;
254 USHORTArr aAccelArr;
255 USHORTArr aFunctionArr;
256 USHORTArr aKeyArr;
258 void OKHdl ( Button * );
259 void ChangeHdl( Button * );
260 void RemoveHdl( Button * );
261 void SelectHdl( ListBox *pListBox );
263 KeyCode PosToKeyCode ( USHORT nPos ) const;
264 USHORT KeyCodeToPos ( const KeyCode &rCode ) const;
265 String GetFunctionName( KeyFuncType eType ) const;
267 public:
269 SfxAcceleratorConfigDialog( Window *pParent );
273 class SvxShortcutAssignDlg : public SfxSingleTabDialog
275 public:
276 SvxShortcutAssignDlg(
277 Window* pParent,
278 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame,
279 const SfxItemSet& rSet );
280 virtual ~SvxShortcutAssignDlg();
285 #undef css
287 #endif