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