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 #ifndef _SVXSELECTOR_HXX 28*cdf0e10cSrcweir #define _SVXSELECTOR_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 31*cdf0e10cSrcweir #include <vcl/fixed.hxx> 32*cdf0e10cSrcweir #include <vcl/group.hxx> 33*cdf0e10cSrcweir #include <vcl/menubtn.hxx> 34*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNode.hpp> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #define _SVSTDARR_USHORTS 42*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 43*cdf0e10cSrcweir #include <svl/svstdarr.hxx> // SvUShorts 44*cdf0e10cSrcweir #include <sfx2/minarray.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #define SVX_CFGGROUP_FUNCTION 1 47*cdf0e10cSrcweir #define SVX_CFGFUNCTION_SLOT 2 48*cdf0e10cSrcweir #define SVX_CFGGROUP_SCRIPTCONTAINER 3 49*cdf0e10cSrcweir #define SVX_CFGFUNCTION_SCRIPT 4 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir struct SvxGroupInfo_Impl 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir sal_uInt16 nKind; 54*cdf0e10cSrcweir sal_uInt16 nOrd; 55*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > 56*cdf0e10cSrcweir xBrowseNode; 57*cdf0e10cSrcweir ::rtl::OUString sURL; 58*cdf0e10cSrcweir ::rtl::OUString sHelpText; 59*cdf0e10cSrcweir sal_Bool bWasOpened; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr ) 62*cdf0e10cSrcweir :nKind( n ) 63*cdf0e10cSrcweir ,nOrd( nr ) 64*cdf0e10cSrcweir ,xBrowseNode() 65*cdf0e10cSrcweir ,sURL() 66*cdf0e10cSrcweir ,sHelpText() 67*cdf0e10cSrcweir ,bWasOpened(sal_False) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxNode ) 72*cdf0e10cSrcweir :nKind( n ) 73*cdf0e10cSrcweir ,nOrd( nr ) 74*cdf0e10cSrcweir ,xBrowseNode( _rxNode ) 75*cdf0e10cSrcweir ,sURL() 76*cdf0e10cSrcweir ,sHelpText() 77*cdf0e10cSrcweir ,bWasOpened(sal_False) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir SvxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, const ::rtl::OUString& _rURL, const ::rtl::OUString& _rHelpText ) 82*cdf0e10cSrcweir :nKind( n ) 83*cdf0e10cSrcweir ,nOrd( nr ) 84*cdf0e10cSrcweir ,xBrowseNode() 85*cdf0e10cSrcweir ,sURL( _rURL ) 86*cdf0e10cSrcweir ,sHelpText( _rHelpText ) 87*cdf0e10cSrcweir ,bWasOpened(sal_False) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir }; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir typedef SvxGroupInfo_Impl* SvxGroupInfoPtr; 93*cdf0e10cSrcweir SV_DECL_PTRARR_DEL(SvxGroupInfoArr_Impl, SvxGroupInfoPtr, 5, 5) 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir class ImageProvider 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir public: 98*cdf0e10cSrcweir virtual ~ImageProvider() {} 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir virtual Image GetImage( const rtl::OUString& rCommandURL ) = 0; 101*cdf0e10cSrcweir }; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir class SvxConfigFunctionListBox_Impl : public SvTreeListBox 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir friend class SvxConfigGroupListBox_Impl; 106*cdf0e10cSrcweir Timer aTimer; 107*cdf0e10cSrcweir SvLBoxEntry* pCurEntry; 108*cdf0e10cSrcweir SvxGroupInfoArr_Impl aArr; 109*cdf0e10cSrcweir SvLBoxEntry* m_pDraggingEntry; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir DECL_LINK( TimerHdl, Timer* ); 112*cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& rMEvt ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir public: 115*cdf0e10cSrcweir SvxConfigFunctionListBox_Impl( Window*, const ResId& ); 116*cdf0e10cSrcweir ~SvxConfigFunctionListBox_Impl(); 117*cdf0e10cSrcweir void ClearAll(); 118*cdf0e10cSrcweir String GetHelpText( SvLBoxEntry *pEntry ); 119*cdf0e10cSrcweir using Window::GetHelpText; 120*cdf0e10cSrcweir SvLBoxEntry* GetLastSelectedEntry(); 121*cdf0e10cSrcweir void FunctionSelected(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // drag n drop methods 124*cdf0e10cSrcweir virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir virtual DragDropMode NotifyStartDrag( 127*cdf0e10cSrcweir TransferDataContainer&, SvLBoxEntry* ); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir virtual void DragFinished( sal_Int8 ); 130*cdf0e10cSrcweir }; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir class SvxConfigGroupListBox_Impl : public SvTreeListBox 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir SvxGroupInfoArr_Impl aArr; 135*cdf0e10cSrcweir bool m_bShowSlots; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir SvxConfigFunctionListBox_Impl* pFunctionListBox; 138*cdf0e10cSrcweir ImageProvider* m_pImageProvider; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir ::com::sun::star::uno::Reference 141*cdf0e10cSrcweir < ::com::sun::star::frame::XFrame > m_xFrame; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir ::com::sun::star::uno::Reference 144*cdf0e10cSrcweir < ::com::sun::star::container::XNameAccess > m_xModuleCommands; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir Image m_hdImage; 147*cdf0e10cSrcweir Image m_hdImage_hc; 148*cdf0e10cSrcweir Image m_libImage; 149*cdf0e10cSrcweir Image m_libImage_hc; 150*cdf0e10cSrcweir Image m_macImage; 151*cdf0e10cSrcweir Image m_macImage_hc; 152*cdf0e10cSrcweir Image m_docImage; 153*cdf0e10cSrcweir Image m_docImage_hc; 154*cdf0e10cSrcweir ::rtl::OUString m_sMyMacros; 155*cdf0e10cSrcweir ::rtl::OUString m_sProdMacros; 156*cdf0e10cSrcweir Image GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast ); 157*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx, ::rtl::OUString& docName ); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir private: 160*cdf0e10cSrcweir void fillScriptList( 161*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& _rxRootNode, 162*cdf0e10cSrcweir SvLBoxEntry* _pParentEntry, 163*cdf0e10cSrcweir bool _bCheapChildsOnDemand 164*cdf0e10cSrcweir ); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir protected: 167*cdf0e10cSrcweir virtual void RequestingChilds( SvLBoxEntry *pEntry); 168*cdf0e10cSrcweir virtual sal_Bool Expand( SvLBoxEntry* pParent ); 169*cdf0e10cSrcweir using SvListView::Expand; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir public: 172*cdf0e10cSrcweir SvxConfigGroupListBox_Impl ( 173*cdf0e10cSrcweir Window* pParent, const ResId&, 174*cdf0e10cSrcweir bool _bShowSlots, 175*cdf0e10cSrcweir const ::com::sun::star::uno::Reference 176*cdf0e10cSrcweir < ::com::sun::star::frame::XFrame >& xFrame 177*cdf0e10cSrcweir ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir ~SvxConfigGroupListBox_Impl(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void Init(); 182*cdf0e10cSrcweir void Open( SvLBoxEntry*, sal_Bool ); 183*cdf0e10cSrcweir void ClearAll(); 184*cdf0e10cSrcweir void GroupSelected(); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir void SetFunctionListBox( SvxConfigFunctionListBox_Impl *pBox ) 187*cdf0e10cSrcweir { pFunctionListBox = pBox; } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir void SetImageProvider( ImageProvider* provider ) 190*cdf0e10cSrcweir { m_pImageProvider = provider; } 191*cdf0e10cSrcweir }; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir class SvxScriptSelectorDialog : public ModelessDialog 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir FixedText aDialogDescription; 196*cdf0e10cSrcweir FixedText aGroupText; 197*cdf0e10cSrcweir SvxConfigGroupListBox_Impl aCategories; 198*cdf0e10cSrcweir FixedText aFunctionText; 199*cdf0e10cSrcweir SvxConfigFunctionListBox_Impl aCommands; 200*cdf0e10cSrcweir OKButton aOKButton; 201*cdf0e10cSrcweir CancelButton aCancelButton; 202*cdf0e10cSrcweir HelpButton aHelpButton; 203*cdf0e10cSrcweir FixedLine aDescription; 204*cdf0e10cSrcweir FixedText aDescriptionText; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir sal_Bool m_bShowSlots; 207*cdf0e10cSrcweir Link m_aAddHdl; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir DECL_LINK( ClickHdl, Button * ); 210*cdf0e10cSrcweir DECL_LINK( SelectHdl, Control* ); 211*cdf0e10cSrcweir DECL_LINK( FunctionDoubleClickHdl, Control* ); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir void UpdateUI(); 214*cdf0e10cSrcweir void ResizeControls(); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir public: 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir SvxScriptSelectorDialog ( 219*cdf0e10cSrcweir Window* pParent = NULL, 220*cdf0e10cSrcweir sal_Bool bShowSlots = sal_False, 221*cdf0e10cSrcweir const ::com::sun::star::uno::Reference 222*cdf0e10cSrcweir < ::com::sun::star::frame::XFrame >& xFrame = 0 223*cdf0e10cSrcweir ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir ~SvxScriptSelectorDialog ( ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir void SetAddHdl( const Link& rLink ) { m_aAddHdl = rLink; } 228*cdf0e10cSrcweir const Link& GetAddHdl() const { return m_aAddHdl; } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void SetImageProvider( ImageProvider* provider ) 231*cdf0e10cSrcweir { aCategories.SetImageProvider( provider ); } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir String GetScriptURL() const; 234*cdf0e10cSrcweir String GetSelectedDisplayName(); 235*cdf0e10cSrcweir String GetSelectedHelpText(); 236*cdf0e10cSrcweir void SetRunLabel(); 237*cdf0e10cSrcweir void SetDialogDescription(const String& rDescription); 238*cdf0e10cSrcweir }; 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir #endif 241