1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _ACCCFG_HXX 29 #define _ACCCFG_HXX 30 31 // #include ***************************************************************** 32 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #include <com/sun/star/container/XIndexContainer.hpp> 35 #include <com/sun/star/container/XNameAccess.hpp> 36 #include <com/sun/star/frame/XModuleManager.hpp> 37 #include <com/sun/star/ui/XUIConfigurationManager.hpp> 38 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp> 39 #include <com/sun/star/frame/XFrame.hpp> 40 #include <com/sun/star/frame/XStorable.hpp> 41 #include <com/sun/star/uno/XComponentContext.hpp> 42 #include <com/sun/star/lang/XSingleComponentFactory.hpp> 43 #include <com/sun/star/script/browse/XBrowseNode.hpp> 44 #include <com/sun/star/container/XNameAccess.hpp> 45 #include <com/sun/star/frame/XFrame.hpp> 46 47 #include <algorithm> 48 49 #include <vcl/fixed.hxx> 50 #include <vcl/button.hxx> 51 #include <vcl/dialog.hxx> 52 #include <vcl/lstbox.hxx> 53 #include <vcl/group.hxx> 54 #include <svtools/svtabbx.hxx> 55 #include <svtools/svtreebx.hxx> 56 #include <sfx2/tabdlg.hxx> 57 #include <sfx2/basedlgs.hxx> 58 59 #define _SVSTDARR_STRINGSDTOR 60 #include <svl/svstdarr.hxx> 61 62 #include <sfx2/minarray.hxx> 63 64 #include "cfgutil.hxx" 65 66 // class SfxAcceleratorConfigListBox ************************************************* 67 68 #define css ::com::sun::star 69 70 class SfxMacroInfoItem; 71 class SfxConfigGroupListBox_Impl; 72 class SfxConfigFunctionListBox_Impl; 73 class SfxAcceleratorConfigPage; 74 75 class SfxAccCfgTabListBox_Impl : public SvTabListBox 76 { 77 SfxAcceleratorConfigPage* m_pAccelConfigPage; 78 79 void KeyInput( const KeyEvent &rKEvt ); 80 81 protected: 82 virtual void InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image&, SvLBoxButtonKind eButtonKind ); 83 84 public: 85 SfxAccCfgTabListBox_Impl( 86 SfxAcceleratorConfigPage* pAccelConfigPage, 87 Window *pParent, 88 const ResId &rResId ) : 89 SvTabListBox( pParent, rResId ), 90 m_pAccelConfigPage( pAccelConfigPage ) 91 {} 92 93 void ReplaceEntry( sal_uInt16 nPos, const String &rStr ); 94 }; 95 96 // class SfxAcceleratorConfigPage ---------------------------------------- 97 98 struct TAccInfo 99 { 100 public: 101 102 TAccInfo( sal_Int32 nKeyPos , 103 sal_Int32 nListPos, 104 const KeyCode& aKey ) 105 : m_nKeyPos (nKeyPos ) 106 , m_nListPos (nListPos ) 107 , m_bIsConfigurable(sal_True ) 108 , m_sCommand ( ) 109 , m_aKey (aKey ) 110 // its important to set sal_True as default - 111 // because only fix entries will be disabled later ... 112 {} 113 114 sal_Bool isConfigured() const 115 { 116 return (m_nKeyPos>-1 && m_nListPos>-1 && m_sCommand.getLength()); 117 } 118 119 sal_Int32 m_nKeyPos; 120 sal_Int32 m_nListPos; 121 sal_Bool m_bIsConfigurable; 122 ::rtl::OUString m_sCommand; 123 KeyCode m_aKey; 124 }; 125 126 namespace sfx2 127 { 128 class FileDialogHelper; 129 } 130 131 class SfxAcceleratorConfigPage : public SfxTabPage 132 { 133 friend class SfxAccCfgTabListBox_Impl; 134 private: 135 const SfxMacroInfoItem* m_pMacroInfoItem; 136 const SfxStringItem* m_pStringItem; 137 const SfxStringItem* m_pFontItem; 138 sfx2::FileDialogHelper* m_pFileDlg; 139 140 SfxAccCfgTabListBox_Impl aEntriesBox; 141 FixedLine aKeyboardGroup; 142 RadioButton aOfficeButton; 143 RadioButton aModuleButton; 144 PushButton aChangeButton; 145 PushButton aRemoveButton; 146 FixedText aGroupText; 147 SfxConfigGroupListBox_Impl* pGroupLBox; 148 FixedText aFunctionText; 149 SfxConfigFunctionListBox_Impl* pFunctionBox; 150 FixedText aKeyText; 151 SvTreeListBox aKeyBox; 152 FixedLine aFunctionsGroup; 153 PushButton aLoadButton; 154 PushButton aSaveButton; 155 PushButton aResetButton; 156 String aLoadAccelConfigStr; 157 String aSaveAccelConfigStr; 158 String aFilterAllStr; 159 String aFilterCfgStr; 160 SfxStylesInfo_Impl m_aStylesInfo; 161 sal_Bool m_bStylesInfoInitialized; 162 163 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 164 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal; 165 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule; 166 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct; 167 css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription; 168 css::uno::Reference< css::frame::XFrame > m_xFrame; 169 170 ::rtl::OUString m_sModuleLongName; 171 ::rtl::OUString m_sModuleShortName; 172 ::rtl::OUString m_sModuleUIName; 173 174 DECL_LINK( ChangeHdl, Button * ); 175 DECL_LINK( RemoveHdl, Button * ); 176 DECL_LINK( SelectHdl, Control * ); 177 DECL_LINK( Save, Button * ); 178 DECL_LINK( Load, Button * ); 179 DECL_LINK( Default, PushButton * ); 180 DECL_LINK( RadioHdl, RadioButton* ); 181 182 DECL_LINK( LoadHdl, sfx2::FileDialogHelper* ); 183 DECL_LINK( SaveHdl, sfx2::FileDialogHelper* ); 184 185 String GetLabel4Command(const String& sCommand); 186 void InitAccCfg(); 187 sal_uInt16 MapKeyCodeToPos( const KeyCode &rCode ) const; 188 css::uno::Reference< css::frame::XModel > SearchForAlreadyLoadedDoc(const String& sName); 189 void StartFileDialog( WinBits nBits, const String& rTitle ); 190 191 void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr); 192 void ResetConfig(); 193 194 void CreateCustomItems( SvLBoxEntry* pEntry, const String& aCol1, const String& aCol2 ); 195 196 public: 197 SfxAcceleratorConfigPage( Window *pParent, const SfxItemSet& rItemSet ); 198 virtual ~SfxAcceleratorConfigPage(); 199 200 virtual sal_Bool FillItemSet( SfxItemSet& ); 201 virtual void Reset( const SfxItemSet& ); 202 203 void Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr); 204 static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet ); 205 }; 206 207 208 class SfxAcceleratorConfigListBox : public ListBox 209 { 210 void KeyInput( const KeyEvent &rKEvt ); 211 212 public: 213 214 SfxAcceleratorConfigListBox( Window *pParent, ResId &rResId ) : 215 ListBox( pParent, rResId ) {} 216 217 void ReplaceEntry( sal_uInt16 nPos, const String &rStr ); 218 void ExpandEntry ( sal_uInt16 nPos, const String &rStr ); 219 }; 220 221 class SvxShortcutAssignDlg : public SfxSingleTabDialog 222 { 223 public: 224 SvxShortcutAssignDlg( 225 Window* pParent, 226 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame, 227 const SfxItemSet& rSet ); 228 virtual ~SvxShortcutAssignDlg(); 229 }; 230 231 232 233 #undef css 234 235 #endif 236 237