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