1*2a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2a97ec55SAndrew Rist * distributed with this work for additional information 6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an 15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 17*2a97ec55SAndrew Rist * specific language governing permissions and limitations 18*2a97ec55SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2a97ec55SAndrew Rist *************************************************************/ 21*2a97ec55SAndrew Rist 22*2a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 27cdf0e10cSrcweir #include <osl/mutex.hxx> 28cdf0e10cSrcweir #include <tools/urlobj.hxx> 29cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 30cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 31cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 32cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp> 33cdf0e10cSrcweir #include <datman.hxx> 34cdf0e10cSrcweir #include <tools/debug.hxx> 35cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 36cdf0e10cSrcweir #include <svx/svxids.hrc> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #include <svtools/miscopt.hxx> 39cdf0e10cSrcweir #include <svtools/imgdef.hxx> 40cdf0e10cSrcweir #include <vcl/svapp.hxx> 41cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 42cdf0e10cSrcweir #include "bibbeam.hxx" 43cdf0e10cSrcweir #include "toolbar.hrc" 44cdf0e10cSrcweir #include "bibresid.hxx" 45cdf0e10cSrcweir 46cdf0e10cSrcweir #ifndef BIBTOOLS_HXX 47cdf0e10cSrcweir #include "bibtools.hxx" 48cdf0e10cSrcweir #endif 49cdf0e10cSrcweir #include <vos/mutex.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir using namespace ::rtl; 52cdf0e10cSrcweir using namespace ::com::sun::star; 53cdf0e10cSrcweir using namespace ::com::sun::star::uno; 54cdf0e10cSrcweir using namespace ::com::sun::star::beans; 55cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar) 56cdf0e10cSrcweir 57cdf0e10cSrcweir 58cdf0e10cSrcweir // Konstanten ------------------------------------------------------------- 59cdf0e10cSrcweir 60cdf0e10cSrcweir 61cdf0e10cSrcweir BibToolBarListener::BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 62cdf0e10cSrcweir nIndex(nId), 63cdf0e10cSrcweir aCommand(aStr), 64cdf0e10cSrcweir pToolBar(pTB) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir BibToolBarListener::~BibToolBarListener() 69cdf0e10cSrcweir { 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir void BibToolBarListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir if(rEvt.FeatureURL.Complete == aCommand) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex()); 77cdf0e10cSrcweir pToolBar->EnableItem(nIndex,rEvt.IsEnabled); 78cdf0e10cSrcweir 79cdf0e10cSrcweir ::com::sun::star::uno::Any aState=rEvt.State; 80cdf0e10cSrcweir if(aState.getValueType()==::getBooleanCppuType()) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir sal_Bool bChecked= *(sal_Bool*)aState.getValue(); 83cdf0e10cSrcweir pToolBar->CheckItem(nIndex, bChecked); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir /* 87cdf0e10cSrcweir rtl::OUString FeatureDescriptor; 88cdf0e10cSrcweir sal_Bool Requery; 89cdf0e10cSrcweir ::com::sun::star::uno::Any State;*/ 90cdf0e10cSrcweir } 91cdf0e10cSrcweir }; 92cdf0e10cSrcweir 93cdf0e10cSrcweir rtl::OUString BibToolBarListener::GetCommand() 94cdf0e10cSrcweir { 95cdf0e10cSrcweir return aCommand; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir BibTBListBoxListener::BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 99cdf0e10cSrcweir BibToolBarListener(pTB,aStr,nId) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir BibTBListBoxListener::~BibTBListBoxListener() 104cdf0e10cSrcweir { 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir void BibTBListBoxListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir if(rEvt.FeatureURL.Complete == GetCommand()) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex()); 112cdf0e10cSrcweir pToolBar->EnableSourceList(rEvt.IsEnabled); 113cdf0e10cSrcweir 114cdf0e10cSrcweir Any aState = rEvt.State; 115cdf0e10cSrcweir if(aState.getValueType() == ::getCppuType((Sequence<rtl::OUString>*)0)) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir pToolBar->UpdateSourceList(sal_False); 118cdf0e10cSrcweir pToolBar->ClearSourceList(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*)aState.getValue(); 121cdf0e10cSrcweir const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray(); 122cdf0e10cSrcweir 123cdf0e10cSrcweir sal_uInt32 nCount = pStringSeq->getLength(); 124cdf0e10cSrcweir XubString aEntry; 125cdf0e10cSrcweir for( sal_uInt32 i=0; i<nCount; i++ ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir aEntry = String(pStringArray[i]); 128cdf0e10cSrcweir pToolBar->InsertSourceEntry(aEntry); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir pToolBar->UpdateSourceList(sal_True); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir XubString aStr = String(rEvt.FeatureDescriptor); 134cdf0e10cSrcweir pToolBar->SelectSourceEntry(aStr); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir }; 137cdf0e10cSrcweir 138cdf0e10cSrcweir BibTBQueryMenuListener::BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 139cdf0e10cSrcweir BibToolBarListener(pTB,aStr,nId) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir BibTBQueryMenuListener::~BibTBQueryMenuListener() 144cdf0e10cSrcweir { 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir void BibTBQueryMenuListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir if(rEvt.FeatureURL.Complete == GetCommand()) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex()); 152cdf0e10cSrcweir pToolBar->EnableSourceList(rEvt.IsEnabled); 153cdf0e10cSrcweir 154cdf0e10cSrcweir uno::Any aState=rEvt.State; 155cdf0e10cSrcweir if(aState.getValueType()==::getCppuType((Sequence<rtl::OUString>*)0)) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir pToolBar->ClearFilterMenu(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*) aState.getValue(); 160cdf0e10cSrcweir const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray(); 161cdf0e10cSrcweir 162cdf0e10cSrcweir sal_uInt32 nCount = pStringSeq->getLength(); 163cdf0e10cSrcweir for( sal_uInt32 i=0; i<nCount; i++ ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir sal_uInt16 nID=pToolBar->InsertFilterItem(String(pStringArray[i])); 166cdf0e10cSrcweir if(pStringArray[i]==rEvt.FeatureDescriptor) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir // XubString aStr = rEvt.FeatureDescriptor; 169cdf0e10cSrcweir pToolBar->SelectFilterItem(nID); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir } 173cdf0e10cSrcweir } 174cdf0e10cSrcweir }; 175cdf0e10cSrcweir 176cdf0e10cSrcweir BibTBEditListener::BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 177cdf0e10cSrcweir BibToolBarListener(pTB,aStr,nId) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir BibTBEditListener::~BibTBEditListener() 182cdf0e10cSrcweir { 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir if(rEvt.FeatureURL.Complete == GetCommand()) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex()); 190cdf0e10cSrcweir pToolBar->EnableQuery(rEvt.IsEnabled); 191cdf0e10cSrcweir 192cdf0e10cSrcweir uno::Any aState=rEvt.State; 193cdf0e10cSrcweir if(aState.getValueType()==::getCppuType((const OUString*)0)) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir String aStr = String(*(OUString*) aState.getValue()); 196cdf0e10cSrcweir pToolBar->SetQueryString(aStr); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir } 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir SV_IMPL_PTRARR( BibToolBarListenerArr, BibToolBarListenerPtr); 202cdf0e10cSrcweir 203cdf0e10cSrcweir BibToolBar::BibToolBar(Window* pParent, Link aLink, WinBits nStyle): 204cdf0e10cSrcweir ToolBox(pParent,BibResId(RID_BIB_TOOLBAR)), 205cdf0e10cSrcweir aImgLst(BibResId( RID_TOOLBAR_IMGLIST )), 206cdf0e10cSrcweir aImgLstHC(BibResId(RID_TOOLBAR_IMGLIST_HC )), 207cdf0e10cSrcweir aBigImgLst(BibResId( RID_TOOLBAR_BIGIMGLIST )), 208cdf0e10cSrcweir aBigImgLstHC(BibResId( RID_TOOLBAR_BIGIMGLIST_HC )), 209cdf0e10cSrcweir aFtSource(this,WB_VCENTER), 210cdf0e10cSrcweir aLBSource(this,WB_DROPDOWN), 211cdf0e10cSrcweir aFtQuery(this,WB_VCENTER), 212cdf0e10cSrcweir aEdQuery(this), 213cdf0e10cSrcweir nMenuId(0), 214cdf0e10cSrcweir nSelMenuItem(0), 215cdf0e10cSrcweir aLayoutManager( aLink ), 216cdf0e10cSrcweir nSymbolsSize( SFX_SYMBOLS_SIZE_SMALL ), 217cdf0e10cSrcweir nOutStyle( 0 ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir SvtMiscOptions aSvtMiscOptions; 220cdf0e10cSrcweir nSymbolsSize = aSvtMiscOptions.GetCurrentSymbolsSize(); 221cdf0e10cSrcweir nOutStyle = aSvtMiscOptions.GetToolboxStyle(); 222cdf0e10cSrcweir 223cdf0e10cSrcweir ApplyImageList(); 224cdf0e10cSrcweir SetStyle(GetStyle()|nStyle); 225cdf0e10cSrcweir SetOutStyle(TOOLBOX_STYLE_FLAT); 226cdf0e10cSrcweir Size aSize=GetSizePixel(); 227cdf0e10cSrcweir Size a2Size(GetOutputSizePixel()); 228cdf0e10cSrcweir a2Size.Width()=100; 229cdf0e10cSrcweir aLBSource.SetSizePixel(a2Size); 230cdf0e10cSrcweir aLBSource.SetDropDownLineCount(9); 231cdf0e10cSrcweir aLBSource.Show(); 232cdf0e10cSrcweir aLBSource.SetSelectHdl(LINK( this, BibToolBar, SelHdl)); 233cdf0e10cSrcweir 234cdf0e10cSrcweir SvtMiscOptions().AddListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); 235cdf0e10cSrcweir Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK( this, BibToolBar, SendSelHdl)); 238cdf0e10cSrcweir aTimer.SetTimeout(400); 239cdf0e10cSrcweir 240cdf0e10cSrcweir SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl)); 241cdf0e10cSrcweir 242cdf0e10cSrcweir aEdQuery.SetSizePixel(aLBSource.GetSizePixel()); 243cdf0e10cSrcweir aEdQuery.Show(); 244cdf0e10cSrcweir 245cdf0e10cSrcweir XubString aStr=GetItemText(TBC_FT_SOURCE); 246cdf0e10cSrcweir Rectangle aRect=GetItemRect(TBC_FT_SOURCE); 247cdf0e10cSrcweir aFtSource.SetText(aStr); 248cdf0e10cSrcweir aFtSource.SetSizePixel(aRect.GetSize()); 249cdf0e10cSrcweir aFtSource.SetBackground(Wallpaper( COL_TRANSPARENT )); 250cdf0e10cSrcweir 251cdf0e10cSrcweir aStr=GetItemText(TBC_FT_QUERY); 252cdf0e10cSrcweir aRect=GetItemRect(TBC_FT_QUERY); 253cdf0e10cSrcweir aFtQuery.SetText(aStr); 254cdf0e10cSrcweir aFtQuery.SetSizePixel(aRect.GetSize()); 255cdf0e10cSrcweir aFtQuery.SetBackground(Wallpaper( COL_TRANSPARENT )); 256cdf0e10cSrcweir 257cdf0e10cSrcweir SetItemWindow(TBC_FT_SOURCE,&aFtSource); 258cdf0e10cSrcweir SetItemWindow(TBC_LB_SOURCE,&aLBSource); 259cdf0e10cSrcweir SetItemWindow(TBC_FT_QUERY ,&aFtQuery); 260cdf0e10cSrcweir SetItemWindow(TBC_ED_QUERY ,&aEdQuery); 261cdf0e10cSrcweir 262cdf0e10cSrcweir ::bib::AddToTaskPaneList( this ); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir BibToolBar::~BibToolBar() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); 268cdf0e10cSrcweir Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); 269cdf0e10cSrcweir ::bib::RemoveFromTaskPaneList( this ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir void BibToolBar::InitListener() 273cdf0e10cSrcweir { 274cdf0e10cSrcweir sal_uInt16 nCount=GetItemCount(); 275cdf0e10cSrcweir 276cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 277cdf0e10cSrcweir uno::Reference< frame::XDispatch > xDisp(xController,UNO_QUERY); 278cdf0e10cSrcweir 279cdf0e10cSrcweir uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); 280cdf0e10cSrcweir if( xTrans.is() ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir util::URL aQueryURL; 283cdf0e10cSrcweir aQueryURL.Complete = C2U(".uno:Bib/MenuFilter"); 284cdf0e10cSrcweir xTrans->parseStrict( aQueryURL); 285cdf0e10cSrcweir BibToolBarListener* pQuery=new BibTBQueryMenuListener(this,aQueryURL.Complete,TBC_BT_AUTOFILTER); 286cdf0e10cSrcweir xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pQuery),aQueryURL); 287cdf0e10cSrcweir 288cdf0e10cSrcweir for(sal_uInt16 nPos=0;nPos<nCount;nPos++) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir sal_uInt16 nId=GetItemId(nPos); 291cdf0e10cSrcweir if(!nId || nId==TBC_FT_SOURCE || nId==TBC_FT_QUERY) 292cdf0e10cSrcweir continue; 293cdf0e10cSrcweir 294cdf0e10cSrcweir util::URL aURL; 295cdf0e10cSrcweir aURL.Complete = GetItemCommand(nId); 296cdf0e10cSrcweir if(!aURL.Complete.getLength()) 297cdf0e10cSrcweir continue; 298cdf0e10cSrcweir 299cdf0e10cSrcweir xTrans->parseStrict( aURL ); 300cdf0e10cSrcweir 301cdf0e10cSrcweir BibToolBarListener* pListener=NULL; 302cdf0e10cSrcweir if(nId==TBC_LB_SOURCE) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir pListener=new BibTBListBoxListener(this,aURL.Complete,nId); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir else if(nId==TBC_ED_QUERY) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir pListener=new BibTBEditListener(this,aURL.Complete,nId); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir else 311cdf0e10cSrcweir { 312cdf0e10cSrcweir pListener=new BibToolBarListener(this,aURL.Complete,nId); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir BibToolBarListenerPtr pxInsert = new Reference<frame::XStatusListener>; 316cdf0e10cSrcweir (*pxInsert) = pListener; 317cdf0e10cSrcweir aListenerArr.Insert( pxInsert, aListenerArr.Count() ); 318cdf0e10cSrcweir xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pListener),aURL); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir } 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir void BibToolBar::SetXController(const uno::Reference< frame::XController > & xCtr) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir xController=xCtr; 326cdf0e10cSrcweir InitListener(); 327cdf0e10cSrcweir 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir void BibToolBar::Select() 331cdf0e10cSrcweir { 332cdf0e10cSrcweir sal_uInt16 nId=GetCurItemId(); 333cdf0e10cSrcweir 334cdf0e10cSrcweir if(nId!=TBC_BT_AUTOFILTER) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir SendDispatch(nId,Sequence<PropertyValue>() ); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir else 339cdf0e10cSrcweir { 340cdf0e10cSrcweir Sequence<PropertyValue> aPropVal(2); 341cdf0e10cSrcweir PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 342cdf0e10cSrcweir pPropertyVal[0].Name=C2U("QueryText"); 343cdf0e10cSrcweir rtl::OUString aSelection = aEdQuery.GetText(); 344cdf0e10cSrcweir pPropertyVal[0].Value <<= aSelection; 345cdf0e10cSrcweir 346cdf0e10cSrcweir pPropertyVal[1].Name=C2U("QueryField"); 347cdf0e10cSrcweir pPropertyVal[1].Value <<= aQueryField; 348cdf0e10cSrcweir SendDispatch(nId,aPropVal); 349cdf0e10cSrcweir } 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir void BibToolBar::SendDispatch(sal_uInt16 nId, const Sequence< PropertyValue >& rArgs) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir rtl::OUString aCommand = GetItemCommand(nId); 355cdf0e10cSrcweir 356cdf0e10cSrcweir uno::Reference< frame::XDispatchProvider > xDSP( xController, UNO_QUERY ); 357cdf0e10cSrcweir 358cdf0e10cSrcweir if( xDSP.is() && aCommand.getLength()) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 361cdf0e10cSrcweir 362cdf0e10cSrcweir uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); 363cdf0e10cSrcweir if( xTrans.is() ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir // Datei laden 366cdf0e10cSrcweir util::URL aURL; 367cdf0e10cSrcweir aURL.Complete = aCommand; 368cdf0e10cSrcweir 369cdf0e10cSrcweir xTrans->parseStrict( aURL ); 370cdf0e10cSrcweir 371cdf0e10cSrcweir uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, rtl::OUString(), frame::FrameSearchFlag::SELF ); 372cdf0e10cSrcweir 373cdf0e10cSrcweir if ( xDisp.is() ) 374cdf0e10cSrcweir xDisp->dispatch( aURL, rArgs); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir void BibToolBar::Click() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir sal_uInt16 nId=GetCurItemId(); 383cdf0e10cSrcweir 384cdf0e10cSrcweir if(nId == TBC_BT_COL_ASSIGN ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir if(pDatMan) 387cdf0e10cSrcweir pDatMan->CreateMappingDialog(GetParent()); 388cdf0e10cSrcweir CheckItem( nId, sal_False ); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir else if(nId == TBC_BT_CHANGESOURCE) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir if(pDatMan) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir OUString sNew = pDatMan->CreateDBChangeDialog(GetParent()); 395cdf0e10cSrcweir if(sNew.getLength()) 396cdf0e10cSrcweir pDatMan->setActiveDataSource(sNew); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir CheckItem( nId, sal_False ); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir void BibToolBar::ClearFilterMenu() 403cdf0e10cSrcweir { 404cdf0e10cSrcweir aPopupMenu.Clear(); 405cdf0e10cSrcweir nMenuId=0; 406cdf0e10cSrcweir } 407cdf0e10cSrcweir sal_uInt16 BibToolBar::InsertFilterItem(const XubString& aMenuEntry) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir nMenuId++; 410cdf0e10cSrcweir aPopupMenu.InsertItem(nMenuId,aMenuEntry); 411cdf0e10cSrcweir 412cdf0e10cSrcweir return nMenuId; 413cdf0e10cSrcweir } 414cdf0e10cSrcweir void BibToolBar::SelectFilterItem(sal_uInt16 nId) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir aPopupMenu.CheckItem(nId); 417cdf0e10cSrcweir nSelMenuItem=nId; 418cdf0e10cSrcweir aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) ); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir void BibToolBar::EnableSourceList(sal_Bool bFlag) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir aFtSource.Enable(bFlag); 424cdf0e10cSrcweir aLBSource.Enable(bFlag); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir 427cdf0e10cSrcweir void BibToolBar::ClearSourceList() 428cdf0e10cSrcweir { 429cdf0e10cSrcweir aLBSource.Clear(); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir void BibToolBar::UpdateSourceList(sal_Bool bFlag) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir aLBSource.SetUpdateMode(bFlag); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir void BibToolBar::InsertSourceEntry(const XubString& aEntry, sal_uInt16 nPos) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir aLBSource.InsertEntry(aEntry, nPos); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir void BibToolBar::SelectSourceEntry(const XubString& aStr) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir aLBSource.SelectEntry(aStr); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir void BibToolBar::EnableQuery(sal_Bool bFlag) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir aFtQuery.Enable(bFlag); 450cdf0e10cSrcweir aEdQuery.Enable(bFlag); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir 453cdf0e10cSrcweir void BibToolBar::SetQueryString(const XubString& aStr) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir aEdQuery.SetText(aStr); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir 459cdf0e10cSrcweir long BibToolBar::PreNotify( NotifyEvent& rNEvt ) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir long nResult=sal_True; 462cdf0e10cSrcweir 463cdf0e10cSrcweir sal_uInt16 nSwitch=rNEvt.GetType(); 464cdf0e10cSrcweir if(aEdQuery.HasFocus() && nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); 467cdf0e10cSrcweir sal_uInt16 nKey = aKeyCode.GetCode(); 468cdf0e10cSrcweir if(nKey == KEY_RETURN) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir Sequence<PropertyValue> aPropVal(2); 471cdf0e10cSrcweir PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 472cdf0e10cSrcweir pPropertyVal[0].Name = C2U("QueryText"); 473cdf0e10cSrcweir rtl::OUString aSelection = aEdQuery.GetText(); 474cdf0e10cSrcweir pPropertyVal[0].Value <<= aSelection; 475cdf0e10cSrcweir pPropertyVal[1].Name=C2U("QueryField"); 476cdf0e10cSrcweir pPropertyVal[1].Value <<= aQueryField; 477cdf0e10cSrcweir SendDispatch(TBC_BT_AUTOFILTER,aPropVal); 478cdf0e10cSrcweir return nResult; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir } 482cdf0e10cSrcweir 483cdf0e10cSrcweir nResult=ToolBox::PreNotify(rNEvt); 484cdf0e10cSrcweir 485cdf0e10cSrcweir return nResult; 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir IMPL_LINK( BibToolBar, SelHdl, ListBox*, /*pLb*/ ) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir aTimer.Start(); 491cdf0e10cSrcweir return 0; 492cdf0e10cSrcweir } 493cdf0e10cSrcweir 494cdf0e10cSrcweir IMPL_LINK( BibToolBar, SendSelHdl, Timer*,/*pT*/) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir Sequence<PropertyValue> aPropVal(1); 497cdf0e10cSrcweir PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 498cdf0e10cSrcweir pPropertyVal[0].Name = C2U("DataSourceName"); 499cdf0e10cSrcweir String aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource.GetSelectEntry() ) ); 500cdf0e10cSrcweir rtl::OUString aSelection = aEntry; 501cdf0e10cSrcweir pPropertyVal[0].Value <<= aSelection; 502cdf0e10cSrcweir SendDispatch(TBC_LB_SOURCE,aPropVal); 503cdf0e10cSrcweir 504cdf0e10cSrcweir return 0; 505cdf0e10cSrcweir } 506cdf0e10cSrcweir //----------------------------------------------------------------------------- 507cdf0e10cSrcweir IMPL_LINK( BibToolBar, MenuHdl, ToolBox*, /*pToolbox*/) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir sal_uInt16 nId=GetCurItemId(); 510cdf0e10cSrcweir if(nId==TBC_BT_AUTOFILTER) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage) 513cdf0e10cSrcweir 514cdf0e10cSrcweir SetItemDown(TBC_BT_AUTOFILTER,sal_True); 515cdf0e10cSrcweir nId = aPopupMenu.Execute(this, GetItemRect(TBC_BT_AUTOFILTER)); 516cdf0e10cSrcweir 517cdf0e10cSrcweir 518cdf0e10cSrcweir if(nId>0) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir aPopupMenu.CheckItem(nSelMenuItem,sal_False); 521cdf0e10cSrcweir aPopupMenu.CheckItem(nId); 522cdf0e10cSrcweir nSelMenuItem=nId; 523cdf0e10cSrcweir aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) ); 524cdf0e10cSrcweir Sequence<PropertyValue> aPropVal(2); 525cdf0e10cSrcweir PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 526cdf0e10cSrcweir pPropertyVal[0].Name = C2U("QueryText"); 527cdf0e10cSrcweir rtl::OUString aSelection = aEdQuery.GetText(); 528cdf0e10cSrcweir pPropertyVal[0].Value <<= aSelection; 529cdf0e10cSrcweir pPropertyVal[1].Name=C2U("QueryField"); 530cdf0e10cSrcweir pPropertyVal[1].Value <<= aQueryField; 531cdf0e10cSrcweir SendDispatch(TBC_BT_AUTOFILTER,aPropVal); 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir Point aPoint; 535cdf0e10cSrcweir MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC ); 536cdf0e10cSrcweir MouseMove( aLeave ); 537cdf0e10cSrcweir SetItemDown(TBC_BT_AUTOFILTER,sal_False); 538cdf0e10cSrcweir 539cdf0e10cSrcweir 540cdf0e10cSrcweir } 541cdf0e10cSrcweir return 0; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir //----------------------------------------------------------------------------- 544cdf0e10cSrcweir void BibToolBar::statusChanged(const frame::FeatureStateEvent& rEvent) 545cdf0e10cSrcweir throw( uno::RuntimeException ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir for(sal_uInt16 i = 0; i < aListenerArr.Count(); i++) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir BibToolBarListenerPtr pListener = aListenerArr.GetObject(i); 550cdf0e10cSrcweir (*pListener)->statusChanged(rEvent); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir } 553cdf0e10cSrcweir /* -----------------------------07.05.2002 15:08------------------------------ 554cdf0e10cSrcweir 555cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 556cdf0e10cSrcweir void BibToolBar::DataChanged( const DataChangedEvent& rDCEvt ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 559cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 560cdf0e10cSrcweir ApplyImageList(); 561cdf0e10cSrcweir ToolBox::DataChanged( rDCEvt ); 562cdf0e10cSrcweir } 563cdf0e10cSrcweir /* -----------------------------07.05.2002 15:09------------------------------ 564cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 565cdf0e10cSrcweir 566cdf0e10cSrcweir IMPL_LINK( BibToolBar, OptionsChanged_Impl, void*, /*pVoid*/ ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir sal_Bool bRebuildToolBar = sal_False; 569cdf0e10cSrcweir sal_Int16 eSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 570cdf0e10cSrcweir if ( nSymbolsSize != eSymbolsSize ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir nSymbolsSize = eSymbolsSize; 573cdf0e10cSrcweir bRebuildToolBar = sal_True; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir else if ( nOutStyle != SvtMiscOptions().GetToolboxStyle() ) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir nOutStyle = SvtMiscOptions().GetToolboxStyle(); 578cdf0e10cSrcweir SetOutStyle( nOutStyle ); 579cdf0e10cSrcweir bRebuildToolBar = sal_True; 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir if ( bRebuildToolBar ) 583cdf0e10cSrcweir RebuildToolbar(); 584cdf0e10cSrcweir 585cdf0e10cSrcweir return 0L; 586cdf0e10cSrcweir } 587cdf0e10cSrcweir 588cdf0e10cSrcweir //----------------------------------------------------------------------------- 589cdf0e10cSrcweir 590cdf0e10cSrcweir IMPL_LINK( BibToolBar, SettingsChanged_Impl, void*, /*pVoid*/ ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir // Check if toolbar button size have changed and we have to use system settings 593cdf0e10cSrcweir sal_Int16 eSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 594cdf0e10cSrcweir if ( eSymbolsSize != nSymbolsSize ) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir nSymbolsSize = eSymbolsSize; 597cdf0e10cSrcweir RebuildToolbar(); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir return 0L; 601cdf0e10cSrcweir } 602cdf0e10cSrcweir 603cdf0e10cSrcweir //----------------------------------------------------------------------------- 604cdf0e10cSrcweir void BibToolBar::RebuildToolbar() 605cdf0e10cSrcweir { 606cdf0e10cSrcweir ApplyImageList(); 607cdf0e10cSrcweir // We have to call parent asynchronously as SetSize works also asynchronously! 608cdf0e10cSrcweir Application::PostUserEvent( aLayoutManager, 0 ); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir //----------------------------------------------------------------------------- 612cdf0e10cSrcweir 613cdf0e10cSrcweir void BibToolBar::ApplyImageList() 614cdf0e10cSrcweir { 615cdf0e10cSrcweir ImageList& rList = ( nSymbolsSize == SFX_SYMBOLS_SIZE_SMALL ) ? 616cdf0e10cSrcweir ( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImgLstHC : aImgLst ) : 617cdf0e10cSrcweir ( GetSettings().GetStyleSettings().GetHighContrastMode() ? aBigImgLstHC : aBigImgLst ); 618cdf0e10cSrcweir 619cdf0e10cSrcweir SetItemImage(TBC_BT_AUTOFILTER , rList.GetImage(SID_FM_AUTOFILTER)); 620cdf0e10cSrcweir SetItemImage(TBC_BT_FILTERCRIT , rList.GetImage(SID_FM_FILTERCRIT)); 621cdf0e10cSrcweir SetItemImage(TBC_BT_REMOVEFILTER, rList.GetImage(SID_FM_REMOVE_FILTER_SORT )); 622cdf0e10cSrcweir AdjustToolBox(); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir void BibToolBar::AdjustToolBox() 626cdf0e10cSrcweir { 627cdf0e10cSrcweir Size aOldSize = GetSizePixel(); 628cdf0e10cSrcweir Size aSize = CalcWindowSizePixel(); 629cdf0e10cSrcweir if ( !aSize.Width() ) 630cdf0e10cSrcweir aSize.Width() = aOldSize.Width(); 631cdf0e10cSrcweir else if ( !aSize.Height() ) 632cdf0e10cSrcweir aSize.Height() = aOldSize.Height(); 633cdf0e10cSrcweir 634cdf0e10cSrcweir Size aTbSize = GetSizePixel(); 635cdf0e10cSrcweir if ( 636cdf0e10cSrcweir (aSize.Width() && aSize.Width() != aTbSize.Width()) || 637cdf0e10cSrcweir (aSize.Height() && aSize.Height() != aTbSize.Height()) 638cdf0e10cSrcweir ) 639cdf0e10cSrcweir { 640cdf0e10cSrcweir SetPosSizePixel( GetPosPixel(), aSize ); 641cdf0e10cSrcweir Invalidate(); 642cdf0e10cSrcweir } 643cdf0e10cSrcweir } 644