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 #include "precompiled_reportdesign.hxx"
28*cdf0e10cSrcweir #include "toolboxcontroller.hxx"
29*cdf0e10cSrcweir #include <com/sun/star/ui/ImageType.hpp>
30*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
32*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
33*cdf0e10cSrcweir #include <vcl/menu.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManager.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/ui/XImageManager.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/ui/ImageType.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
40*cdf0e10cSrcweir #include <vcl/svapp.hxx>
41*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
42*cdf0e10cSrcweir #include <svtools/miscopt.hxx>
43*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
44*cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
45*cdf0e10cSrcweir #include <vos/mutex.hxx>
46*cdf0e10cSrcweir #include <svx/svxids.hrc>
47*cdf0e10cSrcweir #define ITEMID_COLOR	    1
48*cdf0e10cSrcweir #define ITEMID_BRUSH        2
49*cdf0e10cSrcweir #define ITEMID_FONT         3
50*cdf0e10cSrcweir #define ITEMID_FONTHEIGHT   4
51*cdf0e10cSrcweir #include <editeng/fontitem.hxx>
52*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
53*cdf0e10cSrcweir #include <svx/tbcontrl.hxx>
54*cdf0e10cSrcweir #include <editeng/colritem.hxx>
55*cdf0e10cSrcweir #include <svx/tbxcustomshapes.hxx>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #include <memory>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace rptui
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir 	using namespace svt;
64*cdf0e10cSrcweir 	using namespace com::sun::star;
65*cdf0e10cSrcweir 	using namespace com::sun::star::uno;
66*cdf0e10cSrcweir 	using namespace com::sun::star::beans;
67*cdf0e10cSrcweir 	using namespace com::sun::star::lang;
68*cdf0e10cSrcweir 	using namespace frame;
69*cdf0e10cSrcweir 	using namespace util;
70*cdf0e10cSrcweir 	using namespace ui;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OToolboxController::getImplementationName() throw( RuntimeException )
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir 	return getImplementationName_Static();
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir //------------------------------------------------------------------------------
78*cdf0e10cSrcweir ::rtl::OUString OToolboxController::getImplementationName_Static() throw( RuntimeException )
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.ReportToolboxController"));
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir //------------------------------------------------------------------------------
83*cdf0e10cSrcweir Sequence< ::rtl::OUString> OToolboxController::getSupportedServiceNames_Static(void) throw( RuntimeException )
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir 	Sequence< ::rtl::OUString> aSupported(1);
86*cdf0e10cSrcweir 	aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ReportToolboxController"));
87*cdf0e10cSrcweir 	return aSupported;
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir // -----------------------------------------------------------------------------
90*cdf0e10cSrcweir ::sal_Bool SAL_CALL OToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir     return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir //-------------------------------------------------------------------------
95*cdf0e10cSrcweir Sequence< ::rtl::OUString> SAL_CALL OToolboxController::getSupportedServiceNames() throw(RuntimeException)
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	return getSupportedServiceNames_Static();
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir // -------------------------------------------------------------------------
100*cdf0e10cSrcweir Reference< XInterface > OToolboxController::create(Reference< XComponentContext > const & xContext)
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	return *(new OToolboxController(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY)));
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir // -----------------------------------------------------------------------------
105*cdf0e10cSrcweir DBG_NAME(rpt_OToolboxController)
106*cdf0e10cSrcweir OToolboxController::OToolboxController(const Reference< XMultiServiceFactory >& _rxORB)
107*cdf0e10cSrcweir 	: m_pToolbarController(NULL)
108*cdf0e10cSrcweir 	,m_nToolBoxId(1)
109*cdf0e10cSrcweir 	,m_nSlotId(0)
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir     DBG_CTOR(rpt_OToolboxController,NULL);
112*cdf0e10cSrcweir 	osl_incrementInterlockedCount(&m_refCount);
113*cdf0e10cSrcweir 	m_xServiceManager = _rxORB;
114*cdf0e10cSrcweir 	osl_decrementInterlockedCount(&m_refCount);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir // -----------------------------------------------------------------------------
118*cdf0e10cSrcweir OToolboxController::~OToolboxController()
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir     DBG_DTOR(rpt_OToolboxController,NULL);
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir // -----------------------------------------------------------------------------
123*cdf0e10cSrcweir // XInterface
124*cdf0e10cSrcweir Any SAL_CALL OToolboxController::queryInterface( const Type& _rType ) throw (RuntimeException)
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir 	Any aReturn = ToolboxController::queryInterface(_rType);
127*cdf0e10cSrcweir 	if (!aReturn.hasValue())
128*cdf0e10cSrcweir 		aReturn = TToolboxController_BASE::queryInterface(_rType);
129*cdf0e10cSrcweir 	return aReturn;
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir // -----------------------------------------------------------------------------
132*cdf0e10cSrcweir void SAL_CALL OToolboxController::acquire() throw ()
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	ToolboxController::acquire();
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir // -----------------------------------------------------------------------------
137*cdf0e10cSrcweir void SAL_CALL OToolboxController::release() throw ()
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	ToolboxController::release();
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir // -----------------------------------------------------------------------------
142*cdf0e10cSrcweir void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	ToolboxController::initialize(_rArguments);
145*cdf0e10cSrcweir 	vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
146*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	ToolBox*    pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
149*cdf0e10cSrcweir 	if ( pToolBox )
150*cdf0e10cSrcweir 	{
151*cdf0e10cSrcweir 		const sal_uInt16 nCount = pToolBox->GetItemCount();
152*cdf0e10cSrcweir 		for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
153*cdf0e10cSrcweir 		{
154*cdf0e10cSrcweir 			const sal_uInt16 nItemId = pToolBox->GetItemId(nPos);
155*cdf0e10cSrcweir 			if ( pToolBox->GetItemCommand(nItemId) == String(m_aCommandURL) )
156*cdf0e10cSrcweir 			{
157*cdf0e10cSrcweir 				m_nToolBoxId = nItemId;
158*cdf0e10cSrcweir 				break;
159*cdf0e10cSrcweir 			}
160*cdf0e10cSrcweir 		}
161*cdf0e10cSrcweir         if ( m_aCommandURL.equalsAscii(".uno:BasicShapes") )
162*cdf0e10cSrcweir         {
163*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:BasicShapes")),sal_True));
164*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxTbxCtlCustomShapes(m_nSlotId = SID_DRAWTBX_CS_BASIC,m_nToolBoxId,*pToolBox));
165*cdf0e10cSrcweir         }
166*cdf0e10cSrcweir         else if ( m_aCommandURL.equalsAscii(".uno:SymbolShapes") )
167*cdf0e10cSrcweir         {
168*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:SymbolShapes")),sal_True));
169*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxTbxCtlCustomShapes(m_nSlotId = SID_DRAWTBX_CS_SYMBOL,m_nToolBoxId,*pToolBox));
170*cdf0e10cSrcweir         }
171*cdf0e10cSrcweir         else if ( m_aCommandURL.equalsAscii(".uno:ArrowShapes") )
172*cdf0e10cSrcweir         {
173*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:ArrowShapes")),sal_True));
174*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxTbxCtlCustomShapes(m_nSlotId = SID_DRAWTBX_CS_ARROW,m_nToolBoxId,*pToolBox));
175*cdf0e10cSrcweir         }
176*cdf0e10cSrcweir         else if ( m_aCommandURL.equalsAscii(".uno:FlowChartShapes") )
177*cdf0e10cSrcweir         {
178*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FlowChartShapes")),sal_True));
179*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxTbxCtlCustomShapes(m_nSlotId = SID_DRAWTBX_CS_FLOWCHART,m_nToolBoxId,*pToolBox));
180*cdf0e10cSrcweir         }
181*cdf0e10cSrcweir         else if ( m_aCommandURL.equalsAscii(".uno:CalloutShapes") )
182*cdf0e10cSrcweir         {
183*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:CalloutShapes")),sal_True));
184*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxTbxCtlCustomShapes(m_nSlotId = SID_DRAWTBX_CS_CALLOUT,m_nToolBoxId,*pToolBox));
185*cdf0e10cSrcweir         }
186*cdf0e10cSrcweir         else if ( m_aCommandURL.equalsAscii(".uno:StarShapes") )
187*cdf0e10cSrcweir         {
188*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:StarShapes")),sal_True));
189*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxTbxCtlCustomShapes(m_nSlotId = SID_DRAWTBX_CS_STAR,m_nToolBoxId,*pToolBox));
190*cdf0e10cSrcweir         }
191*cdf0e10cSrcweir         else if ( m_aCommandURL.equalsAscii(".uno:CharFontName") )
192*cdf0e10cSrcweir         {
193*cdf0e10cSrcweir             m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:CharFontName")),sal_True));
194*cdf0e10cSrcweir             m_pToolbarController = TToolbarHelper::createFromQuery(new SvxFontNameToolBoxControl/*SvxStyleToolBoxControl*/(m_nSlotId = SID_ATTR_CHAR_FONT,m_nToolBoxId,*pToolBox));
195*cdf0e10cSrcweir         }
196*cdf0e10cSrcweir 		else if ( m_aCommandURL.equalsAscii(".uno:FontColor") || m_aCommandURL.equalsAscii(".uno:Color") )
197*cdf0e10cSrcweir 		{
198*cdf0e10cSrcweir 			m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FontColor")),sal_True));
199*cdf0e10cSrcweir 			m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Color")),sal_True));
200*cdf0e10cSrcweir 			m_pToolbarController = TToolbarHelper::createFromQuery(new SvxFontColorExtToolBoxControl/*SvxFontColorToolBoxControl*/(m_nSlotId = SID_ATTR_CHAR_COLOR2,m_nToolBoxId,*pToolBox));
201*cdf0e10cSrcweir 		}
202*cdf0e10cSrcweir 		else
203*cdf0e10cSrcweir 		{
204*cdf0e10cSrcweir 			m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:BackgroundColor")),sal_True));
205*cdf0e10cSrcweir 			m_pToolbarController = TToolbarHelper::createFromQuery(new SvxColorToolBoxControl(m_nSlotId = SID_BACKGROUND_COLOR,m_nToolBoxId,*pToolBox));
206*cdf0e10cSrcweir 		}
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 		TCommandState::iterator aIter = m_aStates.begin();
209*cdf0e10cSrcweir 		for (; aIter != m_aStates.end(); ++aIter)
210*cdf0e10cSrcweir 			addStatusListener(aIter->first);
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         if ( m_pToolbarController.is() )
213*cdf0e10cSrcweir 		    m_pToolbarController->initialize(_rArguments);
214*cdf0e10cSrcweir         // check if paste special is allowed, when not don't add DROPDOWN
215*cdf0e10cSrcweir 		pToolBox->SetItemBits(m_nToolBoxId,pToolBox->GetItemBits(m_nToolBoxId) | TIB_DROPDOWN);
216*cdf0e10cSrcweir 	}
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir // -----------------------------------------------------------------------------
219*cdf0e10cSrcweir void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException )
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
222*cdf0e10cSrcweir 	TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete );
223*cdf0e10cSrcweir 	if ( aFind != m_aStates.end() )
224*cdf0e10cSrcweir 	{
225*cdf0e10cSrcweir 		aFind->second = Event.IsEnabled;
226*cdf0e10cSrcweir 		if ( m_pToolbarController.is() )
227*cdf0e10cSrcweir 		{
228*cdf0e10cSrcweir             // All other status events will be processed here
229*cdf0e10cSrcweir             sal_Bool bSetCheckmark      = sal_False;
230*cdf0e10cSrcweir 	        sal_Bool bCheckmark			= sal_False;
231*cdf0e10cSrcweir             //m_pToolbarController->GetToolBox().Enable(Event.IsEnabled);
232*cdf0e10cSrcweir             ToolBox& rTb = m_pToolbarController->GetToolBox();
233*cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < rTb.GetItemCount(); i++ )
234*cdf0e10cSrcweir             {
235*cdf0e10cSrcweir                 sal_uInt16 nId = rTb.GetItemId( i );
236*cdf0e10cSrcweir                 if ( nId == 0 )
237*cdf0e10cSrcweir                     continue;
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir                 rtl::OUString aCmd = rTb.GetItemCommand( nId );
240*cdf0e10cSrcweir                 if ( aCmd == Event.FeatureURL.Complete )
241*cdf0e10cSrcweir                 {
242*cdf0e10cSrcweir                     // Enable/disable item
243*cdf0e10cSrcweir                     rTb.EnableItem( nId, Event.IsEnabled );
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir                     // Checkmark
246*cdf0e10cSrcweir                     if ( Event.State >>= bCheckmark )
247*cdf0e10cSrcweir 				        bSetCheckmark = sal_True;
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir                     if ( bSetCheckmark )
250*cdf0e10cSrcweir                         rTb.CheckItem( nId, bCheckmark );
251*cdf0e10cSrcweir                     else
252*cdf0e10cSrcweir                     {
253*cdf0e10cSrcweir                         rtl::OUString aItemText;
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir                         if ( Event.State >>= aItemText )
256*cdf0e10cSrcweir                             rTb.SetItemText( nId, aItemText );
257*cdf0e10cSrcweir                     }
258*cdf0e10cSrcweir                 }
259*cdf0e10cSrcweir             }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 			switch(m_nSlotId)
262*cdf0e10cSrcweir 			{
263*cdf0e10cSrcweir 				case SID_ATTR_CHAR_COLOR2:
264*cdf0e10cSrcweir 				case SID_BACKGROUND_COLOR:
265*cdf0e10cSrcweir                     {
266*cdf0e10cSrcweir                         util::Color nColor(COL_TRANSPARENT);
267*cdf0e10cSrcweir 			            Event.State >>= nColor;
268*cdf0e10cSrcweir                         ::Color aGcc3WorkaroundTemporary( nColor);
269*cdf0e10cSrcweir 			            SvxColorItem aColorItem(aGcc3WorkaroundTemporary,1);
270*cdf0e10cSrcweir                         if ( SID_ATTR_CHAR_COLOR2 == m_nSlotId )
271*cdf0e10cSrcweir                             static_cast<SvxFontColorExtToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled ? SFX_ITEM_SET : SFX_ITEM_DISABLED,&aColorItem);
272*cdf0e10cSrcweir                         else
273*cdf0e10cSrcweir 					        static_cast<SvxColorToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled ? SFX_ITEM_SET : SFX_ITEM_DISABLED,&aColorItem);
274*cdf0e10cSrcweir                     }
275*cdf0e10cSrcweir 					break;
276*cdf0e10cSrcweir                 case SID_ATTR_CHAR_FONT:
277*cdf0e10cSrcweir                     {
278*cdf0e10cSrcweir                         SvxFontItem aItem(ITEMID_FONT);
279*cdf0e10cSrcweir                         aItem.PutValue(Event.State);
280*cdf0e10cSrcweir                         static_cast<SvxFontNameToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled ? SFX_ITEM_AVAILABLE : SFX_ITEM_DISABLED,&aItem);
281*cdf0e10cSrcweir                     }
282*cdf0e10cSrcweir                     break;
283*cdf0e10cSrcweir 			}
284*cdf0e10cSrcweir 		}
285*cdf0e10cSrcweir 	}
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir // -----------------------------------------------------------------------------
288*cdf0e10cSrcweir Reference< awt::XWindow > SAL_CALL OToolboxController::createPopupWindow() throw (RuntimeException)
289*cdf0e10cSrcweir {
290*cdf0e10cSrcweir 	// execute the menu
291*cdf0e10cSrcweir 	vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
292*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 	Reference< awt::XWindow > xRet;
295*cdf0e10cSrcweir     if ( m_pToolbarController.is() )
296*cdf0e10cSrcweir         xRet = m_pToolbarController.getRef()->createPopupWindow();
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     return xRet;
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir // -----------------------------------------------------------------------------
301*cdf0e10cSrcweir ::sal_Bool SAL_CALL OToolboxController::opensSubToolbar() throw (uno::RuntimeException)
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     return m_nSlotId == SID_DRAWTBX_CS_BASIC;
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir // -----------------------------------------------------------------------------
306*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OToolboxController::getSubToolbarName() throw (uno::RuntimeException)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
309*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
310*cdf0e10cSrcweir     uno::Reference< frame::XSubToolbarController> xSub(m_pToolbarController.getRef(),uno::UNO_QUERY);
311*cdf0e10cSrcweir     if ( xSub.is() )
312*cdf0e10cSrcweir         return xSub->getSubToolbarName();
313*cdf0e10cSrcweir     return ::rtl::OUString();
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir // -----------------------------------------------------------------------------
316*cdf0e10cSrcweir void SAL_CALL OToolboxController::functionSelected( const ::rtl::OUString& rCommand ) throw (uno::RuntimeException)
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
319*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir     uno::Reference< frame::XSubToolbarController> xSub(m_pToolbarController.getRef(),uno::UNO_QUERY);
322*cdf0e10cSrcweir     if ( xSub.is() )
323*cdf0e10cSrcweir     {
324*cdf0e10cSrcweir         xSub->functionSelected(m_aCommandURL = rCommand);
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir // -----------------------------------------------------------------------------
328*cdf0e10cSrcweir void SAL_CALL OToolboxController::updateImage(  ) throw (uno::RuntimeException)
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
331*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     uno::Reference< frame::XSubToolbarController> xSub(m_pToolbarController.getRef(),uno::UNO_QUERY);
334*cdf0e10cSrcweir     if ( xSub.is() )
335*cdf0e10cSrcweir         xSub->updateImage();
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir // -----------------------------------------------------------------------------
338*cdf0e10cSrcweir uno::Reference< awt::XWindow > SAL_CALL OToolboxController::createItemWindow( const uno::Reference< awt::XWindow >& _xParent)
339*cdf0e10cSrcweir throw (uno::RuntimeException)
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir     uno::Reference< awt::XWindow > xWindow;
342*cdf0e10cSrcweir     if ( m_pToolbarController.is() )
343*cdf0e10cSrcweir 	{
344*cdf0e10cSrcweir 		switch(m_nSlotId)
345*cdf0e10cSrcweir 		{
346*cdf0e10cSrcweir             case SID_ATTR_CHAR_FONT:
347*cdf0e10cSrcweir                 xWindow = VCLUnoHelper::GetInterface(static_cast<SvxFontNameToolBoxControl*>(m_pToolbarController.get())->CreateItemWindow(VCLUnoHelper::GetWindow(_xParent)));
348*cdf0e10cSrcweir                 break;
349*cdf0e10cSrcweir             default:
350*cdf0e10cSrcweir                 ;
351*cdf0e10cSrcweir 		}
352*cdf0e10cSrcweir 	}
353*cdf0e10cSrcweir     return xWindow;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir // -----------------------------------------------------------------------------
356*cdf0e10cSrcweir //..........................................................................
357*cdf0e10cSrcweir } // rptui
358*cdf0e10cSrcweir //..........................................................................
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 
361