1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _BIB_TOOLBAR_HXX 25 #define _BIB_TOOLBAR_HXX 26 27 #include <com/sun/star/frame/XController.hpp> 28 #include <com/sun/star/frame/XStatusListener.hpp> 29 30 31 #include <vcl/toolbox.hxx> 32 #include <vcl/lstbox.hxx> 33 #include <vcl/edit.hxx> 34 #include <vcl/fixed.hxx> 35 #include <svl/svarray.hxx> 36 #include <vcl/timer.hxx> 37 #include <cppuhelper/implbase1.hxx> // helper for implementations 38 39 class BibDataManager; 40 class BibToolBar; 41 42 class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener> 43 { 44 private: 45 46 sal_uInt16 nIndex; 47 rtl::OUString aCommand; 48 49 protected: 50 51 BibToolBar *pToolBar; 52 53 public: 54 55 BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); 56 ~BibToolBarListener(); 57 58 rtl::OUString GetCommand(); 59 60 // ::com::sun::star::lang::XEventListener 61 // we do not hold References to dispatches, so there is nothing to do on disposal disposing(const::com::sun::star::lang::EventObject &)62 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& /*Source*/) 63 throw( ::com::sun::star::uno::RuntimeException ){}; 64 65 // ::com::sun::star::frame::XStatusListener 66 virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) 67 throw( ::com::sun::star::uno::RuntimeException ); 68 69 }; 70 71 class BibTBListBoxListener: public BibToolBarListener 72 { 73 public: 74 75 BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); 76 ~BibTBListBoxListener(); 77 78 virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) 79 throw( ::com::sun::star::uno::RuntimeException ); 80 81 }; 82 83 class BibTBEditListener: public BibToolBarListener 84 { 85 public: 86 87 BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); 88 ~BibTBEditListener(); 89 90 virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) 91 throw( ::com::sun::star::uno::RuntimeException ); 92 93 }; 94 95 class BibTBQueryMenuListener: public BibToolBarListener 96 { 97 public: 98 99 BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); 100 ~BibTBQueryMenuListener(); 101 102 virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) 103 throw( ::com::sun::star::uno::RuntimeException ); 104 105 }; 106 107 108 typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener>* BibToolBarListenerPtr; 109 SV_DECL_PTRARR_DEL( BibToolBarListenerArr, BibToolBarListenerPtr, 4, 4 ) 110 111 class BibToolBar: public ToolBox 112 { 113 private: 114 115 BibToolBarListenerArr aListenerArr; 116 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController; 117 Timer aTimer; 118 // Timer aMenuTimer; 119 ImageList aImgLst; 120 ImageList aImgLstHC; 121 ImageList aBigImgLst; 122 ImageList aBigImgLstHC; 123 FixedText aFtSource; 124 ListBox aLBSource; 125 FixedText aFtQuery; 126 Edit aEdQuery; 127 PopupMenu aPopupMenu; 128 sal_uInt16 nMenuId; 129 sal_uInt16 nSelMenuItem; 130 rtl::OUString aQueryField; 131 Link aLayoutManager; 132 sal_Int16 nSymbolsSize; 133 sal_Int16 nOutStyle; 134 135 BibDataManager* pDatMan; 136 DECL_LINK( SelHdl, ListBox* ); 137 DECL_LINK( SendSelHdl, Timer* ); 138 DECL_LINK( MenuHdl, ToolBox* ); 139 DECL_LINK( OptionsChanged_Impl, void* ); 140 DECL_LINK( SettingsChanged_Impl, void* ); 141 142 void ApplyImageList(); 143 void RebuildToolbar(); 144 145 protected: 146 147 void DataChanged( const DataChangedEvent& rDCEvt ); 148 void InitListener(); 149 virtual void Select(); 150 virtual void Click(); 151 long PreNotify( NotifyEvent& rNEvt ); 152 153 154 public: 155 156 BibToolBar(Window* pParent, Link aLink, WinBits nStyle = WB_3DLOOK ); 157 ~BibToolBar(); 158 159 void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &); 160 161 void ClearSourceList(); 162 void UpdateSourceList(sal_Bool bFlag=sal_True); 163 void EnableSourceList(sal_Bool bFlag=sal_True); 164 void InsertSourceEntry(const XubString&,sal_uInt16 nPos=LISTBOX_APPEND ); 165 void SelectSourceEntry(const XubString& ); 166 167 void EnableQuery(sal_Bool bFlag=sal_True); 168 void SetQueryString(const XubString& ); 169 void AdjustToolBox(); 170 171 void ClearFilterMenu(); 172 sal_uInt16 InsertFilterItem(const XubString& ); 173 void SelectFilterItem(sal_uInt16 nId); 174 175 void statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) 176 throw( ::com::sun::star::uno::RuntimeException ); 177 SetDatMan(BibDataManager & rDatMan)178 void SetDatMan(BibDataManager& rDatMan) {pDatMan = &rDatMan;} 179 void SendDispatch(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs); 180 }; 181 182 183 184 185 #endif 186