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