office-gobmx/extensions/source/bibliography/toolbar.cxx

727 lines
22 KiB
C++
Raw Normal View History

2000-09-18 10:18:56 -05:00
/*************************************************************************
*
* $RCSfile: toolbar.cxx,v $
*
* $Revision: 1.14 $
2000-09-18 10:18:56 -05:00
*
* last change: $Author: hr $ $Date: 2004-11-09 16:45:49 $
2000-09-18 10:18:56 -05:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
2000-11-14 04:06:35 -06:00
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
2000-09-18 10:18:56 -05:00
#include <osl/mutex.hxx>
#include <tools/urlobj.hxx>
#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
#include <com/sun/star/frame/XDispatch.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
#include <com/sun/star/frame/XDispatchProvider.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
#include <com/sun/star/util/XURLTransformer.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#endif
#ifndef _BIB_DATMAN_HXX
#include <datman.hxx>
#endif
2000-09-18 10:18:56 -05:00
#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT
#include <tools/debug.hxx>
#endif
#ifndef _SVX_SVXIDS_HRC
#include <svx/svxids.hrc>
#endif
#ifndef INCLUDED_SVTOOLS_MISCOPT_HXX
#include <svtools/miscopt.hxx>
#endif
#ifndef _SVTOOLS_IMGDEF_HXX
#include <svtools/imgdef.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#include <vcl/mnemonic.hxx>
2000-09-18 10:18:56 -05:00
#include "bibbeam.hxx"
#include "toolbar.hrc"
#include "bibresid.hxx"
2002-04-25 03:27:20 -05:00
#ifndef BIBTOOLS_HXX
#include "bibtools.hxx"
#endif
2000-09-18 10:18:56 -05:00
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
#define C2U(cChar) OUString::createFromAscii(cChar)
// Konstanten -------------------------------------------------------------
BibToolBarListener::BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
pToolBar(pTB),
nIndex(nId),
aCommand(aStr)
{
}
BibToolBarListener::~BibToolBarListener()
{
}
void BibToolBarListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException )
{
if(rEvt.FeatureURL.Complete == aCommand)
{
pToolBar->EnableItem(nIndex,rEvt.IsEnabled);
::com::sun::star::uno::Any aState=rEvt.State;
if(aState.getValueType()==::getBooleanCppuType())
{
sal_Bool bChecked= *(sal_Bool*)aState.getValue();
pToolBar->CheckItem(nIndex, bChecked);
}
/*
rtl::OUString FeatureDescriptor;
sal_Bool Requery;
::com::sun::star::uno::Any State;*/
}
};
sal_uInt16 BibToolBarListener::GetIndex()
{
return nIndex;
}
void BibToolBarListener::SetIndex(sal_uInt16 nId)
{
nIndex=nId;
}
rtl::OUString BibToolBarListener::GetCommand()
{
return aCommand;
}
void BibToolBarListener::SetCommand(const rtl::OUString& aStr)
{
aCommand=aStr;
}
BibTBListBoxListener::BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
BibToolBarListener(pTB,aStr,nId)
{
}
BibTBListBoxListener::~BibTBListBoxListener()
{
}
void BibTBListBoxListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException )
{
if(rEvt.FeatureURL.Complete == GetCommand())
{
pToolBar->EnableSourceList(rEvt.IsEnabled);
Any aState = rEvt.State;
if(aState.getValueType() == ::getCppuType((Sequence<rtl::OUString>*)0))
{
pToolBar->UpdateSourceList(sal_False);
pToolBar->ClearSourceList();
Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*)aState.getValue();
const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray();
sal_uInt32 nCount = pStringSeq->getLength();
XubString aEntry;
for( sal_uInt32 i=0; i<nCount; i++ )
{
aEntry = String(pStringArray[i]);
pToolBar->InsertSourceEntry(aEntry);
}
pToolBar->UpdateSourceList(sal_True);
}
XubString aStr = String(rEvt.FeatureDescriptor);
pToolBar->SelectSourceEntry(aStr);
}
};
BibTBQueryMenuListener::BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
BibToolBarListener(pTB,aStr,nId)
{
}
BibTBQueryMenuListener::~BibTBQueryMenuListener()
{
}
void BibTBQueryMenuListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException )
{
if(rEvt.FeatureURL.Complete == GetCommand())
{
pToolBar->EnableSourceList(rEvt.IsEnabled);
uno::Any aState=rEvt.State;
if(aState.getValueType()==::getCppuType((Sequence<rtl::OUString>*)0))
{
pToolBar->ClearFilterMenu();
Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*) aState.getValue();
const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray();
sal_uInt32 nCount = pStringSeq->getLength();
for( sal_uInt32 i=0; i<nCount; i++ )
{
sal_uInt16 nID=pToolBar->InsertFilterItem(String(pStringArray[i]));
if(pStringArray[i]==rEvt.FeatureDescriptor)
{
// XubString aStr = rEvt.FeatureDescriptor;
pToolBar->SelectFilterItem(nID);
}
}
}
}
};
BibTBEditListener::BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
BibToolBarListener(pTB,aStr,nId)
{
}
BibTBEditListener::~BibTBEditListener()
{
}
void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException )
{
if(rEvt.FeatureURL.Complete == GetCommand())
{
pToolBar->EnableQuery(rEvt.IsEnabled);
uno::Any aState=rEvt.State;
if(aState.getValueType()==::getCppuType((const OUString*)0))
{
String aStr = String(*(OUString*) aState.getValue());
pToolBar->SetQueryString(aStr);
}
}
}
SV_IMPL_PTRARR( BibToolBarListenerArr, BibToolBarListenerPtr);
BibToolBar::BibToolBar(Window* pParent, Link aLink, WinBits nStyle):
2000-09-18 10:18:56 -05:00
ToolBox(pParent,BibResId(RID_BIB_TOOLBAR)),
aFtSource(this,WB_VCENTER),
aLBSource(this,WB_DROPDOWN),
aFtQuery(this,WB_VCENTER),
aEdQuery(this),
aImgLst(BibResId( RID_TOOLBAR_IMGLIST )),
aImgLstHC(BibResId(RID_TOOLBAR_IMGLIST_HC )),
aBigImgLst(BibResId( RID_TOOLBAR_BIGIMGLIST )),
aBigImgLstHC(BibResId( RID_TOOLBAR_BIGIMGLIST_HC )),
2000-09-18 10:18:56 -05:00
nSelMenuItem(0),
nMenuId(0),
aLayoutManager( aLink ),
nSymbolSet( SFX_SYMBOLS_SMALL ),
nOutStyle( 0 )
2000-09-18 10:18:56 -05:00
{
nSymbolSet = GetCurrentSymbolSet();
nOutStyle = SvtMiscOptions().GetToolboxStyle();
ApplyImageList();
2000-09-18 10:18:56 -05:00
SetStyle(GetStyle()|nStyle);
SetOutStyle(TOOLBOX_STYLE_FLAT);
Size aSize=GetSizePixel();
Size a2Size(GetOutputSizePixel());
a2Size.Width()=100;
aLBSource.SetSizePixel(a2Size);
aLBSource.SetDropDownLineCount(9);
aLBSource.Show();
aLBSource.SetSelectHdl(LINK( this, BibToolBar, SelHdl));
SvtMiscOptions().AddListener( LINK( this, BibToolBar, OptionsChanged_Impl ) );
Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) );
2000-09-18 10:18:56 -05:00
aTimer.SetTimeoutHdl(LINK( this, BibToolBar, SendSelHdl));
aTimer.SetTimeout(400);
aMenuTimer.SetTimeoutHdl(LINK( this, BibToolBar, MenuHdl));
aMenuTimer.SetTimeout(300);
aEdQuery.SetSizePixel(aLBSource.GetSizePixel());
aEdQuery.Show();
XubString aStr=GetItemText(TBC_FT_SOURCE);
Rectangle aRect=GetItemRect(TBC_FT_SOURCE);
aFtSource.SetText(aStr);
aFtSource.SetSizePixel(aRect.GetSize());
aFtSource.SetBackground(Wallpaper( COL_TRANSPARENT ));
2000-09-18 10:18:56 -05:00
aStr=GetItemText(TBC_FT_QUERY);
aRect=GetItemRect(TBC_FT_QUERY);
aFtQuery.SetText(aStr);
aFtQuery.SetSizePixel(aRect.GetSize());
aFtQuery.SetBackground(Wallpaper( COL_TRANSPARENT ));
2000-09-18 10:18:56 -05:00
SetItemWindow(TBC_FT_SOURCE,&aFtSource);
SetItemWindow(TBC_LB_SOURCE,&aLBSource);
SetItemWindow(TBC_FT_QUERY ,&aFtQuery);
SetItemWindow(TBC_ED_QUERY ,&aEdQuery);
2002-04-25 03:27:20 -05:00
::bib::AddToTaskPaneList( this );
2000-09-18 10:18:56 -05:00
}
BibToolBar::~BibToolBar()
{
SvtMiscOptions().RemoveListener( LINK( this, BibToolBar, OptionsChanged_Impl ) );
Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) );
2002-04-25 03:27:20 -05:00
::bib::RemoveFromTaskPaneList( this );
2000-09-18 10:18:56 -05:00
}
2002-04-25 03:27:20 -05:00
2000-09-18 10:18:56 -05:00
void BibToolBar::InitListener()
{
sal_uInt16 nCount=GetItemCount();
2000-11-14 04:06:35 -06:00
uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
2000-09-18 10:18:56 -05:00
uno::Reference< frame::XDispatch > xDisp(xController,UNO_QUERY);
uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
if( xTrans.is() )
{
util::URL aQueryURL;
aQueryURL.Complete = C2U(".uno:Bib/MenuFilter");
xTrans->parseStrict( aQueryURL);
BibToolBarListener* pQuery=new BibTBQueryMenuListener(this,aQueryURL.Complete,TBC_BT_AUTOFILTER);
xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pQuery),aQueryURL);
for(sal_uInt16 nPos=0;nPos<nCount;nPos++)
{
sal_uInt16 nId=GetItemId(nPos);
2001-05-31 05:18:40 -05:00
if(!nId || nId==TBC_FT_SOURCE || nId==TBC_FT_QUERY)
continue;
2000-09-18 10:18:56 -05:00
util::URL aURL;
aURL.Complete = GetItemCommand(nId);
2001-05-31 05:18:40 -05:00
if(!aURL.Complete.getLength())
continue;
2000-09-18 10:18:56 -05:00
xTrans->parseStrict( aURL );
BibToolBarListener* pListener=NULL;
if(nId==TBC_LB_SOURCE)
{
pListener=new BibTBListBoxListener(this,aURL.Complete,nId);
}
else if(nId==TBC_ED_QUERY)
{
pListener=new BibTBEditListener(this,aURL.Complete,nId);
}
else
{
pListener=new BibToolBarListener(this,aURL.Complete,nId);
}
BibToolBarListenerPtr pxInsert = new Reference<frame::XStatusListener>;
(*pxInsert) = pListener;
aListenerArr.Insert( pxInsert, aListenerArr.Count() );
xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pListener),aURL);
}
}
}
void BibToolBar::SetXController(const uno::Reference< frame::XController > & xCtr)
{
xController=xCtr;
InitListener();
}
void BibToolBar::Select()
{
sal_uInt16 nId=GetCurItemId();
if(nId!=TBC_BT_AUTOFILTER)
{
SendDispatch(nId,Sequence<PropertyValue>() );
}
else
{
Sequence<PropertyValue> aPropVal(2);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
pPropertyVal[0].Name=C2U("QueryText");
rtl::OUString aSelection = aEdQuery.GetText();
pPropertyVal[0].Value <<= aSelection;
pPropertyVal[1].Name=C2U("QueryField");
pPropertyVal[1].Value <<= aQueryField;
SendDispatch(nId,aPropVal);
}
}
void BibToolBar::SendDispatch(sal_uInt16 nId, const Sequence< PropertyValue >& rArgs)
{
rtl::OUString aCommand = GetItemCommand(nId);
uno::Reference< frame::XDispatchProvider > xDSP( xController, UNO_QUERY );
2001-05-11 04:26:36 -05:00
if( xDSP.is() && aCommand.getLength())
2000-09-18 10:18:56 -05:00
{
2000-11-14 04:06:35 -06:00
uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
2000-09-18 10:18:56 -05:00
uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
if( xTrans.is() )
{
// Datei laden
util::URL aURL;
aURL.Complete = aCommand;
xTrans->parseStrict( aURL );
uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, rtl::OUString(), frame::FrameSearchFlag::SELF );
if ( xDisp.is() )
xDisp->dispatch( aURL, rArgs);
}
}
}
void BibToolBar::Click()
{
sal_uInt16 nId=GetCurItemId();
if(nId==TBC_BT_AUTOFILTER)
{
aMenuTimer.Start();
}
else if(nId == TBC_BT_COL_ASSIGN )
{
if(pDatMan)
pDatMan->CreateMappingDialog(GetParent());
}
else if(nId == TBC_BT_CHANGESOURCE)
{
if(pDatMan)
{
OUString sNew = pDatMan->CreateDBChangeDialog(GetParent());
if(sNew.getLength())
pDatMan->setActiveDataSource(sNew);
}
}
2000-09-18 10:18:56 -05:00
}
void BibToolBar::ClearFilterMenu()
{
aPopupMenu.Clear();
nMenuId=0;
}
sal_uInt16 BibToolBar::InsertFilterItem(const XubString& aMenuEntry)
{
nMenuId++;
aPopupMenu.InsertItem(nMenuId,aMenuEntry);
return nMenuId;
}
void BibToolBar::SelectFilterItem(sal_uInt16 nId)
{
aPopupMenu.CheckItem(nId);
nSelMenuItem=nId;
aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) );
2000-09-18 10:18:56 -05:00
}
void BibToolBar::EnableSourceList(sal_Bool bFlag)
{
aFtSource.Enable(bFlag);
aLBSource.Enable(bFlag);
}
void BibToolBar::ClearSourceList()
{
aLBSource.Clear();
}
void BibToolBar::UpdateSourceList(sal_Bool bFlag)
{
aLBSource.SetUpdateMode(bFlag);
}
void BibToolBar::InsertSourceEntry(const XubString& aEntry, sal_uInt16 nPos)
{
aLBSource.InsertEntry(aEntry, nPos);
}
void BibToolBar::SelectSourceEntry(const XubString& aStr)
{
aLBSource.SelectEntry(aStr);
}
void BibToolBar::EnableQuery(sal_Bool bFlag)
{
aFtQuery.Enable(bFlag);
aEdQuery.Enable(bFlag);
}
void BibToolBar::SetQueryString(const XubString& aStr)
{
aEdQuery.SetText(aStr);
}
long BibToolBar::PreNotify( NotifyEvent& rNEvt )
{
long nResult=sal_True;
sal_uInt16 nSwitch=rNEvt.GetType();
if(aEdQuery.HasFocus() && nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP)
{
const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
sal_uInt16 nKey = aKeyCode.GetCode();
if(nKey == KEY_RETURN)
{
Sequence<PropertyValue> aPropVal(2);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
pPropertyVal[0].Name = C2U("QueryText");
rtl::OUString aSelection = aEdQuery.GetText();
pPropertyVal[0].Value <<= aSelection;
pPropertyVal[1].Name=C2U("QueryField");
pPropertyVal[1].Value <<= aQueryField;
SendDispatch(TBC_BT_AUTOFILTER,aPropVal);
return nResult;
}
}
nResult=ToolBox::PreNotify(rNEvt);
return nResult;
}
IMPL_LINK( BibToolBar, SelHdl, ListBox*, pLb )
{
aTimer.Start();
return 0;
}
IMPL_LINK( BibToolBar, SendSelHdl, Timer*,pT)
{
Sequence<PropertyValue> aPropVal(1);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
pPropertyVal[0].Name = C2U("DataSourceName");
String aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource.GetSelectEntry() ) );
2000-09-18 10:18:56 -05:00
rtl::OUString aSelection = aEntry;
pPropertyVal[0].Value <<= aSelection;
SendDispatch(TBC_LB_SOURCE,aPropVal);
return 0;
}
//-----------------------------------------------------------------------------
IMPL_LINK( BibToolBar, MenuHdl, Timer*,pT)
{
if(IsItemDown(TBC_BT_AUTOFILTER))
{
EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage)
SetItemDown(TBC_BT_AUTOFILTER,sal_True);
sal_uInt16 nId = aPopupMenu.Execute(this, GetItemRect(TBC_BT_AUTOFILTER));
if(nId>0)
{
aPopupMenu.CheckItem(nSelMenuItem,sal_False);
aPopupMenu.CheckItem(nId);
nSelMenuItem=nId;
aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) );
2000-09-18 10:18:56 -05:00
Sequence<PropertyValue> aPropVal(2);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
pPropertyVal[0].Name = C2U("QueryText");
rtl::OUString aSelection = aEdQuery.GetText();
pPropertyVal[0].Value <<= aSelection;
pPropertyVal[1].Name=C2U("QueryField");
pPropertyVal[1].Value <<= aQueryField;
SendDispatch(TBC_BT_AUTOFILTER,aPropVal);
}
Point aPoint;
MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
MouseMove( aLeave );
SetItemDown(TBC_BT_AUTOFILTER,sal_False);
}
return 0;
}
//-----------------------------------------------------------------------------
void BibToolBar::statusChanged(const frame::FeatureStateEvent& rEvent)
throw( uno::RuntimeException )
{
for(sal_uInt16 i = 0; i < aListenerArr.Count(); i++)
{
BibToolBarListenerPtr pListener = aListenerArr.GetObject(i);
(*pListener)->statusChanged(rEvent);
}
}
/* -----------------------------07.05.2002 15:08------------------------------
---------------------------------------------------------------------------*/
void BibToolBar::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
ApplyImageList();
ToolBox::DataChanged( rDCEvt );
}
/* -----------------------------07.05.2002 15:09------------------------------
---------------------------------------------------------------------------*/
IMPL_LINK( BibToolBar, OptionsChanged_Impl, void*, pVoid )
{
sal_Bool bRebuildToolBar = sal_False;
if ( nSymbolSet != GetCurrentSymbolSet() )
{
nSymbolSet = GetCurrentSymbolSet();
bRebuildToolBar = sal_True;
}
else if ( nOutStyle != SvtMiscOptions().GetToolboxStyle() )
{
nOutStyle = SvtMiscOptions().GetToolboxStyle();
SetOutStyle( nOutStyle );
bRebuildToolBar = sal_True;
}
if ( bRebuildToolBar )
RebuildToolbar();
return 0L;
}
//-----------------------------------------------------------------------------
IMPL_LINK( BibToolBar, SettingsChanged_Impl, void*, pVoid )
{
// Check if toolbar button size have changed and we have to use system settings
sal_Int16 eSymbolSet = GetCurrentSymbolSet();
if ( eSymbolSet != nSymbolSet )
{
nSymbolSet = eSymbolSet;
RebuildToolbar();
}
return 0L;
}
//-----------------------------------------------------------------------------
sal_Int16 BibToolBar::GetCurrentSymbolSet()
{
sal_Int16 eOptSymbolSet = SvtMiscOptions().GetSymbolSet();
if ( eOptSymbolSet == SFX_SYMBOLS_AUTO )
{
// Use system settings, we have to retrieve the toolbar icon size from the
// Application class
ULONG nStyleIconSize = Application::GetSettings().GetStyleSettings().GetToolbarIconSize();
if ( nStyleIconSize == STYLE_TOOLBAR_ICONSIZE_LARGE )
eOptSymbolSet = SFX_SYMBOLS_LARGE;
else
eOptSymbolSet = SFX_SYMBOLS_SMALL;
}
return eOptSymbolSet;
}
//-----------------------------------------------------------------------------
void BibToolBar::RebuildToolbar()
{
ApplyImageList();
// We have to call parent asynchronously as SetSize works also asynchronously!
Application::PostUserEvent( aLayoutManager, 0 );
}
//-----------------------------------------------------------------------------
void BibToolBar::ApplyImageList()
{
ImageList& rList = ( nSymbolSet == SFX_SYMBOLS_SMALL ) ?
( GetDisplayBackground().GetColor().IsDark() ? aImgLstHC : aImgLst ) :
( GetDisplayBackground().GetColor().IsDark() ? aBigImgLstHC : aBigImgLst );
SetItemImage(TBC_BT_AUTOFILTER , rList.GetImage(SID_FM_AUTOFILTER));
SetItemImage(TBC_BT_FILTERCRIT , rList.GetImage(SID_FM_FILTERCRIT));
SetItemImage(TBC_BT_REMOVEFILTER, rList.GetImage(SID_FM_REMOVE_FILTER_SORT ));
AdjustToolBox();
}
void BibToolBar::AdjustToolBox()
{
Size aOldSize = GetSizePixel();
Size aSize = CalcWindowSizePixel();
if ( !aSize.Width() )
aSize.Width() = aOldSize.Width();
else if ( !aSize.Height() )
aSize.Height() = aOldSize.Height();
Size aTbSize = GetSizePixel();
if ( aSize.Width() && aSize.Width() != aTbSize.Width() ||
aSize.Height() && aSize.Height() != aTbSize.Height() )
{
SetPosSizePixel( GetPosPixel(), aSize );
Invalidate();
}
}