LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/bibliography - toolbar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 341 0.0 %
Date: 2012-12-27 Functions: 0 51 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10