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_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/awt/MenuItemStyle.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/awt/XPopupMenuExtended.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <vos/mutex.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <svtools/toolbarmenu.hxx>
43*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
44*cdf0e10cSrcweir #include <sfx2/app.hxx>
45*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
47*cdf0e10cSrcweir #include <svl/eitem.hxx>
48*cdf0e10cSrcweir #include <vcl/settings.hxx>
49*cdf0e10cSrcweir #include <svl/intitem.hxx>
50*cdf0e10cSrcweir #include <editeng/colritem.hxx>
51*cdf0e10cSrcweir #include <tools/urlobj.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include <svx/dialogs.hrc>
54*cdf0e10cSrcweir #include <svx/svdtrans.hxx>
55*cdf0e10cSrcweir #include <svx/sdasitm.hxx>
56*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
57*cdf0e10cSrcweir #include "svx/extrusioncolorcontrol.hxx"
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir //#include "chrtitem.hxx"
60*cdf0e10cSrcweir #include "helpid.hrc"
61*cdf0e10cSrcweir #include "extrusioncontrols.hxx"
62*cdf0e10cSrcweir #include "extrusioncontrols.hrc"
63*cdf0e10cSrcweir #include "colorwindow.hxx"
64*cdf0e10cSrcweir #include "extrusiondepthdialog.hxx"
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir ////////////
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir using ::rtl::OUString;
69*cdf0e10cSrcweir //using ::svtools::ToolbarMenu;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir using namespace ::com::sun::star;
72*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
73*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
74*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
75*cdf0e10cSrcweir using namespace ::com::sun::star::util;
76*cdf0e10cSrcweir using namespace ::com::sun::star::graphic;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir namespace svx
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir /*************************************************************************
82*cdf0e10cSrcweir |*
83*cdf0e10cSrcweir |* ExtrusionDirectionWindow
84*cdf0e10cSrcweir |*
85*cdf0e10cSrcweir \************************************************************************/
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir static sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir ExtrusionDirectionWindow::ExtrusionDirectionWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
90*cdf0e10cSrcweir : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION ))
91*cdf0e10cSrcweir , mrController( rController )
92*cdf0e10cSrcweir , maImgPerspective( SVX_RES( IMG_PERSPECTIVE ) )
93*cdf0e10cSrcweir , maImgPerspectiveH( SVX_RES( IMG_PERSPECTIVE_H ) )
94*cdf0e10cSrcweir , maImgParallel( SVX_RES( IMG_PARALLEL ) )
95*cdf0e10cSrcweir , maImgParallelH( SVX_RES( IMG_PARALLEL_H ) )
96*cdf0e10cSrcweir , msExtrusionDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" ) )
97*cdf0e10cSrcweir , msExtrusionProjection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" ) )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir 	SetHelpId( HID_MENU_EXTRUSION_DIRECTION );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	sal_uInt16 i;
102*cdf0e10cSrcweir 	for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
103*cdf0e10cSrcweir 	{
104*cdf0e10cSrcweir 		maImgDirection[i] = Image( SVX_RES( IMG_DIRECTION + i ) );
105*cdf0e10cSrcweir 		maImgDirectionH[i] = Image( SVX_RES( IMG_DIRECTION_H + i ) );
106*cdf0e10cSrcweir 	}
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
109*cdf0e10cSrcweir 	mpDirectionSet = createEmptyValueSetControl();
110*cdf0e10cSrcweir 	mpDirectionSet->SetHelpId( HID_VALUESET_EXTRUSION_DIRECTION );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	mpDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
113*cdf0e10cSrcweir 	mpDirectionSet->SetColCount( 3 );
114*cdf0e10cSrcweir 	mpDirectionSet->EnableFullItemMode( sal_False );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
119*cdf0e10cSrcweir 	{
120*cdf0e10cSrcweir 		String aText( SVX_RES( STR_DIRECTION + i ) );
121*cdf0e10cSrcweir 		mpDirectionSet->InsertItem( i+1, bHighContrast ? maImgDirectionH[ i ] : maImgDirection[ i ], aText );
122*cdf0e10cSrcweir 	}
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	mpDirectionSet->SetOutputSizePixel( Size( 72, 72 ) );
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	appendEntry( 2, mpDirectionSet );
127*cdf0e10cSrcweir 	appendSeparator();
128*cdf0e10cSrcweir 	appendEntry( 0, String( SVX_RES( STR_PERSPECTIVE ) ), bHighContrast ? maImgPerspectiveH : maImgPerspective );
129*cdf0e10cSrcweir 	appendEntry( 1, String( SVX_RES( STR_PARALLEL ) ), bHighContrast ? maImgParallelH : maImgParallel );
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	SetOutputSizePixel( getMenuSize() );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	FreeResource();
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     AddStatusListener( msExtrusionDirection );
136*cdf0e10cSrcweir     AddStatusListener( msExtrusionProjection );
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt )
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	ToolbarMenu::DataChanged( rDCEvt );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
144*cdf0e10cSrcweir 	{
145*cdf0e10cSrcweir 		bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		for( sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
148*cdf0e10cSrcweir 		{
149*cdf0e10cSrcweir 			mpDirectionSet->SetItemImage( i+1, bHighContrast ? maImgDirectionH[ i ] : maImgDirection[ i ] );
150*cdf0e10cSrcweir 		}
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 		setEntryImage( 0, bHighContrast ? maImgPerspectiveH : maImgPerspective );
153*cdf0e10cSrcweir 		setEntryImage( 1, bHighContrast ? maImgParallelH : maImgParallel );
154*cdf0e10cSrcweir 	}
155*cdf0e10cSrcweir }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir // -----------------------------------------------------------------------
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	if( mpDirectionSet )
162*cdf0e10cSrcweir 	{
163*cdf0e10cSrcweir 		sal_uInt16 nItemId;
164*cdf0e10cSrcweir 		for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
165*cdf0e10cSrcweir 		{
166*cdf0e10cSrcweir 			if( gSkewList[nItemId] == nSkew )
167*cdf0e10cSrcweir 				break;
168*cdf0e10cSrcweir 		}
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		if( nItemId <= DIRECTION_SE )
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			mpDirectionSet->SelectItem( nItemId+1 );
173*cdf0e10cSrcweir 		}
174*cdf0e10cSrcweir 		else
175*cdf0e10cSrcweir 		{
176*cdf0e10cSrcweir 			mpDirectionSet->SetNoSelection();
177*cdf0e10cSrcweir 		}
178*cdf0e10cSrcweir 	}
179*cdf0e10cSrcweir 	enableEntry( 2, bEnabled );
180*cdf0e10cSrcweir }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir // -----------------------------------------------------------------------
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir 	checkEntry( 0, (nProjection == 0) && bEnabled );
187*cdf0e10cSrcweir 	checkEntry( 1, (nProjection == 1 ) && bEnabled );
188*cdf0e10cSrcweir 	enableEntry( 0, bEnabled );
189*cdf0e10cSrcweir 	enableEntry( 1, bEnabled );
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir // -----------------------------------------------------------------------
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir void SAL_CALL ExtrusionDirectionWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
195*cdf0e10cSrcweir {
196*cdf0e10cSrcweir 	if( Event.FeatureURL.Main.equals( msExtrusionDirection ) )
197*cdf0e10cSrcweir 	{
198*cdf0e10cSrcweir 		if( !Event.IsEnabled )
199*cdf0e10cSrcweir 		{
200*cdf0e10cSrcweir 			implSetDirection( -1, false );
201*cdf0e10cSrcweir 		}
202*cdf0e10cSrcweir 		else
203*cdf0e10cSrcweir 		{
204*cdf0e10cSrcweir 			sal_Int32 nValue = 0;
205*cdf0e10cSrcweir 			if( Event.State >>= nValue )
206*cdf0e10cSrcweir 				implSetDirection( nValue, true );
207*cdf0e10cSrcweir 		}
208*cdf0e10cSrcweir 	}
209*cdf0e10cSrcweir 	else if( Event.FeatureURL.Main.equals( msExtrusionProjection ) )
210*cdf0e10cSrcweir 	{
211*cdf0e10cSrcweir 		if( !Event.IsEnabled )
212*cdf0e10cSrcweir 		{
213*cdf0e10cSrcweir 			implSetProjection( -1, false );
214*cdf0e10cSrcweir 		}
215*cdf0e10cSrcweir 		else
216*cdf0e10cSrcweir 		{
217*cdf0e10cSrcweir 			sal_Int32 nValue = 0;
218*cdf0e10cSrcweir 			if( Event.State >>= nValue )
219*cdf0e10cSrcweir 				implSetProjection( nValue, true );
220*cdf0e10cSrcweir 		}
221*cdf0e10cSrcweir 	}
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir // -----------------------------------------------------------------------
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl )
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir 	if ( IsInPopupMode() )
229*cdf0e10cSrcweir 		EndPopupMode();
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	if( pControl == mpDirectionSet )
232*cdf0e10cSrcweir 	{
233*cdf0e10cSrcweir         Sequence< PropertyValue > aArgs( 1 );
234*cdf0e10cSrcweir         aArgs[0].Name = msExtrusionDirection.copy(5);
235*cdf0e10cSrcweir         aArgs[0].Value <<= (sal_Int32)gSkewList[mpDirectionSet->GetSelectItemId()-1];
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 		mrController.dispatchCommand( msExtrusionDirection, aArgs );
238*cdf0e10cSrcweir 	}
239*cdf0e10cSrcweir 	else
240*cdf0e10cSrcweir 	{
241*cdf0e10cSrcweir 		int nProjection = getSelectedEntryId();
242*cdf0e10cSrcweir 		if( (nProjection >= 0) && (nProjection < 2 ) )
243*cdf0e10cSrcweir 		{
244*cdf0e10cSrcweir             Sequence< PropertyValue > aArgs( 1 );
245*cdf0e10cSrcweir             aArgs[0].Name = msExtrusionProjection.copy(5);
246*cdf0e10cSrcweir             aArgs[0].Value <<= (sal_Int32)nProjection;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 			mrController.dispatchCommand( msExtrusionProjection, aArgs );
249*cdf0e10cSrcweir             implSetProjection( nProjection, true );
250*cdf0e10cSrcweir 		}
251*cdf0e10cSrcweir 	}
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 	return 0;
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir // =======================================================================
257*cdf0e10cSrcweir // ExtrusionDirectionControl
258*cdf0e10cSrcweir // =======================================================================
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir ExtrusionDirectionControl::ExtrusionDirectionControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
261*cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) ) )
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir // -----------------------------------------------------------------------
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir ::Window* ExtrusionDirectionControl::createPopupWindow( ::Window* pParent )
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir     return new ExtrusionDirectionWindow( *this, m_xFrame, pParent );
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir // -----------------------------------------------------------------------
273*cdf0e10cSrcweir // XServiceInfo
274*cdf0e10cSrcweir // -----------------------------------------------------------------------
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir OUString SAL_CALL ExtrusionDirectionControl_getImplementationName()
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDirectionController" ));
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir // --------------------------------------------------------------------
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException )
284*cdf0e10cSrcweir {
285*cdf0e10cSrcweir     Sequence< OUString > aSNS( 1 );
286*cdf0e10cSrcweir     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
287*cdf0e10cSrcweir     return aSNS;
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir // --------------------------------------------------------------------
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDirectionControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir 	return *new ExtrusionDirectionControl( rSMgr );
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir // --------------------------------------------------------------------
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir OUString SAL_CALL ExtrusionDirectionControl::getImplementationName(  ) throw (RuntimeException)
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	return ExtrusionDirectionControl_getImplementationName();
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir // --------------------------------------------------------------------
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionDirectionControl::getSupportedServiceNames(  ) throw (RuntimeException)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	return ExtrusionDirectionControl_getSupportedServiceNames();
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir // ####################################################################
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir ExtrusionDepthDialog::ExtrusionDepthDialog( Window* pParent, double fDepth, FieldUnit eDefaultUnit )
314*cdf0e10cSrcweir :	ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_EXTRUSION_DEPTH ) ),
315*cdf0e10cSrcweir 	maFLDepth( this, SVX_RES( FL_DEPTH ) ),
316*cdf0e10cSrcweir 	maMtrDepth( this, SVX_RES( MTR_DEPTH ) ),
317*cdf0e10cSrcweir 	maOKButton( this, SVX_RES( BTN_OK ) ),
318*cdf0e10cSrcweir 	maCancelButton( this, SVX_RES( BTN_CANCEL ) ),
319*cdf0e10cSrcweir 	maHelpButton( this, SVX_RES( BTN_HELP ) )
320*cdf0e10cSrcweir {
321*cdf0e10cSrcweir 	bool bMetric = IsMetric( eDefaultUnit );
322*cdf0e10cSrcweir 	maMtrDepth.SetUnit( bMetric ? FUNIT_CM : FUNIT_INCH );
323*cdf0e10cSrcweir 	maMtrDepth.SetValue( (int) fDepth * 100, FUNIT_100TH_MM );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	FreeResource();
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir ExtrusionDepthDialog::~ExtrusionDepthDialog()
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir double ExtrusionDepthDialog::getDepth() const
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir //	bool bMetric = IsMetric( meDefaultUnit );
335*cdf0e10cSrcweir 	return (double)( maMtrDepth.GetValue( FUNIT_100TH_MM ) ) / 100.0;
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir // ####################################################################
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir double aDepthListInch[] = { 0, 1270,2540,5080,10160 };
341*cdf0e10cSrcweir double aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir ExtrusionDepthWindow::ExtrusionDepthWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
344*cdf0e10cSrcweir : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH ))
345*cdf0e10cSrcweir , mrController( rController )
346*cdf0e10cSrcweir , maImgDepth0( SVX_RES( IMG_DEPTH_0 ) )
347*cdf0e10cSrcweir , maImgDepth1( SVX_RES( IMG_DEPTH_1 ) )
348*cdf0e10cSrcweir , maImgDepth2( SVX_RES( IMG_DEPTH_2 ) )
349*cdf0e10cSrcweir , maImgDepth3( SVX_RES( IMG_DEPTH_3 ) )
350*cdf0e10cSrcweir , maImgDepth4( SVX_RES( IMG_DEPTH_4 ) )
351*cdf0e10cSrcweir , maImgDepthInfinity( SVX_RES( IMG_DEPTH_INFINITY ) )
352*cdf0e10cSrcweir , maImgDepth0h( SVX_RES( IMG_DEPTH_0_H ) )
353*cdf0e10cSrcweir , maImgDepth1h( SVX_RES( IMG_DEPTH_1_H ) )
354*cdf0e10cSrcweir , maImgDepth2h( SVX_RES( IMG_DEPTH_2_H ) )
355*cdf0e10cSrcweir , maImgDepth3h( SVX_RES( IMG_DEPTH_3_H ) )
356*cdf0e10cSrcweir , maImgDepth4h( SVX_RES( IMG_DEPTH_4_H ) )
357*cdf0e10cSrcweir , maImgDepthInfinityh( SVX_RES( IMG_DEPTH_INFINITY_H ) )
358*cdf0e10cSrcweir , mfDepth( -1.0 )
359*cdf0e10cSrcweir , msExtrusionDepth( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" ) )
360*cdf0e10cSrcweir , msMetricUnit( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ) )
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir 	SetHelpId( HID_MENU_EXTRUSION_DEPTH );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	SetSelectHdl( LINK( this, ExtrusionDepthWindow, SelectHdl ) );
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir 	String aEmpty;
369*cdf0e10cSrcweir 	appendEntry( 0, aEmpty, bHighContrast ? maImgDepth0h : maImgDepth0 );
370*cdf0e10cSrcweir 	appendEntry( 1, aEmpty, bHighContrast ? maImgDepth1h : maImgDepth1 );
371*cdf0e10cSrcweir 	appendEntry( 2, aEmpty, bHighContrast ? maImgDepth2h : maImgDepth2 );
372*cdf0e10cSrcweir 	appendEntry( 3, aEmpty, bHighContrast ? maImgDepth3h : maImgDepth3 );
373*cdf0e10cSrcweir 	appendEntry( 4, aEmpty, bHighContrast ? maImgDepth4h : maImgDepth4 );
374*cdf0e10cSrcweir 	appendEntry( 5, String( SVX_RES( STR_INFINITY ) ), bHighContrast ? maImgDepthInfinityh : maImgDepthInfinity );
375*cdf0e10cSrcweir 	appendEntry( 6, String( SVX_RES( STR_CUSTOM ) ) );
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	SetOutputSizePixel( getMenuSize() );
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 	FreeResource();
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir     AddStatusListener( msExtrusionDepth );
382*cdf0e10cSrcweir     AddStatusListener( msMetricUnit );
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir // -----------------------------------------------------------------------
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir void ExtrusionDepthWindow::implSetDepth( double fDepth )
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 	mfDepth = fDepth;
390*cdf0e10cSrcweir 	int i;
391*cdf0e10cSrcweir 	for( i = 0; i < 7; i++ )
392*cdf0e10cSrcweir 	{
393*cdf0e10cSrcweir 		if( i == 5 )
394*cdf0e10cSrcweir 		{
395*cdf0e10cSrcweir 			checkEntry( i, fDepth >= 338666 );
396*cdf0e10cSrcweir 		}
397*cdf0e10cSrcweir 		else if( i != 6 )
398*cdf0e10cSrcweir 		{
399*cdf0e10cSrcweir 			checkEntry( i, (fDepth == (IsMetric( meUnit ) ? aDepthListMM[i] : aDepthListInch[i]) ) );
400*cdf0e10cSrcweir 		}
401*cdf0e10cSrcweir 	}
402*cdf0e10cSrcweir }
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir // -----------------------------------------------------------------------
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit )
407*cdf0e10cSrcweir {
408*cdf0e10cSrcweir 	meUnit = eUnit;
409*cdf0e10cSrcweir 	sal_uInt16 nResource = IsMetric( eUnit ) ? RID_SVXSTR_DEPTH_0 : RID_SVXSTR_DEPTH_0_INCH;
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 	for( int i = 0; i < 5; i++ )
412*cdf0e10cSrcweir 	{
413*cdf0e10cSrcweir 		String aStr( SVX_RES( nResource + i ) );
414*cdf0e10cSrcweir 		setEntryText( i, aStr );
415*cdf0e10cSrcweir 	};
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir // -----------------------------------------------------------------------
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir void SAL_CALL ExtrusionDepthWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
421*cdf0e10cSrcweir {
422*cdf0e10cSrcweir 	if( Event.FeatureURL.Main.equals( msExtrusionDepth ) )
423*cdf0e10cSrcweir 	{
424*cdf0e10cSrcweir 		if( !Event.IsEnabled )
425*cdf0e10cSrcweir 		{
426*cdf0e10cSrcweir 			implSetDepth( 0 );
427*cdf0e10cSrcweir 		}
428*cdf0e10cSrcweir 		else
429*cdf0e10cSrcweir 		{
430*cdf0e10cSrcweir 			double fValue = 0.0;
431*cdf0e10cSrcweir 			if( Event.State >>= fValue )
432*cdf0e10cSrcweir 				implSetDepth( fValue );
433*cdf0e10cSrcweir 		}
434*cdf0e10cSrcweir 	}
435*cdf0e10cSrcweir 	else if( Event.FeatureURL.Main.equals( msMetricUnit ) )
436*cdf0e10cSrcweir 	{
437*cdf0e10cSrcweir 		if( Event.IsEnabled )
438*cdf0e10cSrcweir 		{
439*cdf0e10cSrcweir 			sal_Int32 nValue = 0;
440*cdf0e10cSrcweir 			if( Event.State >>= nValue )
441*cdf0e10cSrcweir 			{
442*cdf0e10cSrcweir 				implFillStrings( static_cast<FieldUnit>(nValue) );
443*cdf0e10cSrcweir 				if( mfDepth >= 0.0 )
444*cdf0e10cSrcweir 					implSetDepth( mfDepth );
445*cdf0e10cSrcweir 			}
446*cdf0e10cSrcweir 		}
447*cdf0e10cSrcweir 	}
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir // -----------------------------------------------------------------------
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir void ExtrusionDepthWindow::DataChanged( const DataChangedEvent& rDCEvt )
453*cdf0e10cSrcweir {
454*cdf0e10cSrcweir 	ToolbarMenu::DataChanged( rDCEvt );
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 	if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
457*cdf0e10cSrcweir 	{
458*cdf0e10cSrcweir 		bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 		setEntryImage( 0, bHighContrast ? maImgDepth0h : maImgDepth0 );
461*cdf0e10cSrcweir 		setEntryImage( 1, bHighContrast ? maImgDepth1h : maImgDepth1 );
462*cdf0e10cSrcweir 		setEntryImage( 2, bHighContrast ? maImgDepth2h : maImgDepth2 );
463*cdf0e10cSrcweir 		setEntryImage( 3, bHighContrast ? maImgDepth3h : maImgDepth3 );
464*cdf0e10cSrcweir 		setEntryImage( 4, bHighContrast ? maImgDepth4h : maImgDepth4 );
465*cdf0e10cSrcweir 		setEntryImage( 5, bHighContrast ? maImgDepthInfinityh : maImgDepthInfinity );
466*cdf0e10cSrcweir 	}
467*cdf0e10cSrcweir }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir // -----------------------------------------------------------------------
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir IMPL_LINK( ExtrusionDepthWindow, SelectHdl, void *, EMPTYARG )
473*cdf0e10cSrcweir {
474*cdf0e10cSrcweir 	int nSelected = getSelectedEntryId();
475*cdf0e10cSrcweir 	if( nSelected != -1 )
476*cdf0e10cSrcweir 	{
477*cdf0e10cSrcweir 		if( nSelected == 6 )
478*cdf0e10cSrcweir 		{
479*cdf0e10cSrcweir 			if ( IsInPopupMode() )
480*cdf0e10cSrcweir 				EndPopupMode();
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir             const rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthDialog" ));
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir             Any a;
485*cdf0e10cSrcweir             Sequence< PropertyValue > aArgs( 2 );
486*cdf0e10cSrcweir             aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Depth" ));
487*cdf0e10cSrcweir             aArgs[0].Value <<= mfDepth;
488*cdf0e10cSrcweir             aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ));
489*cdf0e10cSrcweir             aArgs[1].Value <<= static_cast<sal_Int32>( meUnit );
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir             mrController.dispatchCommand( aCommand, aArgs );
492*cdf0e10cSrcweir 		}
493*cdf0e10cSrcweir 		else
494*cdf0e10cSrcweir 		{
495*cdf0e10cSrcweir 			double fDepth;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir 			if( nSelected == 5 )
498*cdf0e10cSrcweir 			{
499*cdf0e10cSrcweir 				fDepth = 338666.6;
500*cdf0e10cSrcweir 			}
501*cdf0e10cSrcweir 			else
502*cdf0e10cSrcweir 			{
503*cdf0e10cSrcweir 				fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
504*cdf0e10cSrcweir 			}
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir             Sequence< PropertyValue > aArgs( 1 );
507*cdf0e10cSrcweir             aArgs[0].Name = msExtrusionDepth.copy(5);
508*cdf0e10cSrcweir             aArgs[0].Value <<= fDepth;
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir             mrController.dispatchCommand( msExtrusionDepth,  aArgs );
511*cdf0e10cSrcweir 			implSetDepth( fDepth );
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 			if ( IsInPopupMode() )
514*cdf0e10cSrcweir 				EndPopupMode();
515*cdf0e10cSrcweir 		}
516*cdf0e10cSrcweir 	}
517*cdf0e10cSrcweir 	return 0;
518*cdf0e10cSrcweir }
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir // =======================================================================
521*cdf0e10cSrcweir // ExtrusionDirectionControl
522*cdf0e10cSrcweir // =======================================================================
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir ExtrusionDepthController::ExtrusionDepthController( const Reference< lang::XMultiServiceFactory >& rServiceManager )
525*cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthFloater" ) ) )
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir }
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir // -----------------------------------------------------------------------
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir ::Window* ExtrusionDepthController::createPopupWindow( ::Window* pParent )
532*cdf0e10cSrcweir {
533*cdf0e10cSrcweir     return new ExtrusionDepthWindow( *this, m_xFrame, pParent );
534*cdf0e10cSrcweir }
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir // -----------------------------------------------------------------------
538*cdf0e10cSrcweir // XServiceInfo
539*cdf0e10cSrcweir // -----------------------------------------------------------------------
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir OUString SAL_CALL ExtrusionDepthController_getImplementationName()
542*cdf0e10cSrcweir {
543*cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDepthController" ));
544*cdf0e10cSrcweir }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir // --------------------------------------------------------------------
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException )
549*cdf0e10cSrcweir {
550*cdf0e10cSrcweir     Sequence< OUString > aSNS( 1 );
551*cdf0e10cSrcweir     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuController" ));
552*cdf0e10cSrcweir     return aSNS;
553*cdf0e10cSrcweir }
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir // --------------------------------------------------------------------
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDepthController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
558*cdf0e10cSrcweir {
559*cdf0e10cSrcweir 	return *new ExtrusionDepthController( rSMgr );
560*cdf0e10cSrcweir }
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir // --------------------------------------------------------------------
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir OUString SAL_CALL ExtrusionDepthController::getImplementationName(  ) throw (RuntimeException)
565*cdf0e10cSrcweir {
566*cdf0e10cSrcweir 	return ExtrusionDepthController_getImplementationName();
567*cdf0e10cSrcweir }
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir // --------------------------------------------------------------------
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionDepthController::getSupportedServiceNames(  ) throw (RuntimeException)
572*cdf0e10cSrcweir {
573*cdf0e10cSrcweir 	return ExtrusionDepthController_getSupportedServiceNames();
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir // ####################################################################
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir // -------------------------------------------------------------------------
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir ExtrusionLightingWindow::ExtrusionLightingWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
582*cdf0e10cSrcweir : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING ))
583*cdf0e10cSrcweir , mrController( rController )
584*cdf0e10cSrcweir , maImgBright( SVX_RES( IMG_LIGHTING_BRIGHT ) )
585*cdf0e10cSrcweir , maImgNormal( SVX_RES( IMG_LIGHTING_NORMAL ) )
586*cdf0e10cSrcweir , maImgDim( SVX_RES( IMG_LIGHTING_DIM ) )
587*cdf0e10cSrcweir , maImgBrighth( SVX_RES( IMG_LIGHTING_BRIGHT_H ) )
588*cdf0e10cSrcweir , maImgNormalh( SVX_RES( IMG_LIGHTING_NORMAL_H ) )
589*cdf0e10cSrcweir , maImgDimh( SVX_RES( IMG_LIGHTING_DIM_H ) )
590*cdf0e10cSrcweir , mnLevel( 0 )
591*cdf0e10cSrcweir , mbLevelEnabled( false )
592*cdf0e10cSrcweir , mnDirection( FROM_FRONT )
593*cdf0e10cSrcweir , mbDirectionEnabled( false )
594*cdf0e10cSrcweir , msExtrusionLightingDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" ))
595*cdf0e10cSrcweir , msExtrusionLightingIntensity( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" ))
596*cdf0e10cSrcweir {
597*cdf0e10cSrcweir 	sal_uInt16 i;
598*cdf0e10cSrcweir 	for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ )
599*cdf0e10cSrcweir 	{
600*cdf0e10cSrcweir 		if( i != FROM_FRONT )
601*cdf0e10cSrcweir 		{
602*cdf0e10cSrcweir 			maImgLightingOff[i] = Image( SVX_RES( IMG_LIGHT_OFF + i ) );
603*cdf0e10cSrcweir 			maImgLightingOn[i] = Image( SVX_RES( IMG_LIGHT_ON + i ) );
604*cdf0e10cSrcweir 			maImgLightingOffh[i] = Image( SVX_RES( IMG_LIGHT_OFF_H + i ) );
605*cdf0e10cSrcweir 			maImgLightingOnh[i] = Image( SVX_RES( IMG_LIGHT_ON_H + i ) );
606*cdf0e10cSrcweir 		}
607*cdf0e10cSrcweir 		maImgLightingPreview[i] = Image( SVX_RES( IMG_LIGHT_PREVIEW + i ) );
608*cdf0e10cSrcweir 		maImgLightingPreviewh[i] = Image( SVX_RES( IMG_LIGHT_PREVIEW_H + i ) );
609*cdf0e10cSrcweir 	}
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 	SetHelpId( HID_MENU_EXTRUSION_LIGHTING );
612*cdf0e10cSrcweir 	SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	mpLightingSet = createEmptyValueSetControl();
615*cdf0e10cSrcweir 	mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir 	mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
618*cdf0e10cSrcweir 	mpLightingSet->SetColCount( 3 );
619*cdf0e10cSrcweir 	mpLightingSet->EnableFullItemMode( sal_False );
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir 	for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ )
624*cdf0e10cSrcweir 	{
625*cdf0e10cSrcweir 		if( i != FROM_FRONT )
626*cdf0e10cSrcweir 		{
627*cdf0e10cSrcweir 			mpLightingSet->InsertItem( i+1, bHighContrast ? maImgLightingOffh[i] : maImgLightingOff[i] );
628*cdf0e10cSrcweir 		}
629*cdf0e10cSrcweir 		else
630*cdf0e10cSrcweir 		{
631*cdf0e10cSrcweir 			mpLightingSet->InsertItem( 5, bHighContrast ? maImgLightingPreviewh[FROM_FRONT] : maImgLightingPreview[FROM_FRONT] );
632*cdf0e10cSrcweir 		}
633*cdf0e10cSrcweir 	}
634*cdf0e10cSrcweir 	mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) );
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir 	appendEntry( 3, mpLightingSet );
637*cdf0e10cSrcweir 	appendSeparator();
638*cdf0e10cSrcweir 	appendEntry( 0, String( SVX_RES( STR_BRIGHT ) ), bHighContrast ? maImgBrighth : maImgBright );
639*cdf0e10cSrcweir 	appendEntry( 1, String( SVX_RES( STR_NORMAL ) ), bHighContrast ? maImgNormalh : maImgNormal );
640*cdf0e10cSrcweir 	appendEntry( 2, String( SVX_RES( STR_DIM ) ), bHighContrast ? maImgDimh : maImgDim );
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	SetOutputSizePixel( getMenuSize() );
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 	FreeResource();
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir     AddStatusListener( msExtrusionLightingDirection );
647*cdf0e10cSrcweir     AddStatusListener( msExtrusionLightingIntensity );
648*cdf0e10cSrcweir }
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir // -----------------------------------------------------------------------
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
653*cdf0e10cSrcweir {
654*cdf0e10cSrcweir 	mnLevel = nLevel;
655*cdf0e10cSrcweir 	mbLevelEnabled = bEnabled;
656*cdf0e10cSrcweir 	int i = 0;
657*cdf0e10cSrcweir 	for( i = 0; i < 3; i++ )
658*cdf0e10cSrcweir 	{
659*cdf0e10cSrcweir 		checkEntry( i, (i == nLevel) && bEnabled );
660*cdf0e10cSrcweir 		enableEntry( i, bEnabled );
661*cdf0e10cSrcweir 	}
662*cdf0e10cSrcweir }
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir // -----------------------------------------------------------------------
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
667*cdf0e10cSrcweir {
668*cdf0e10cSrcweir 	mnDirection = nDirection;
669*cdf0e10cSrcweir 	mbDirectionEnabled = bEnabled;
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 	if( !bEnabled )
674*cdf0e10cSrcweir 		nDirection = FROM_FRONT;
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir 	sal_uInt16 nItemId;
677*cdf0e10cSrcweir 	for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
678*cdf0e10cSrcweir 	{
679*cdf0e10cSrcweir 		if( nItemId == FROM_FRONT )
680*cdf0e10cSrcweir 		{
681*cdf0e10cSrcweir 			mpLightingSet->SetItemImage( nItemId + 1, bHighContrast ? maImgLightingPreviewh[ nDirection ] : maImgLightingPreview[ nDirection ] );
682*cdf0e10cSrcweir 		}
683*cdf0e10cSrcweir 		else
684*cdf0e10cSrcweir 		{
685*cdf0e10cSrcweir 			if( bHighContrast )
686*cdf0e10cSrcweir 			{
687*cdf0e10cSrcweir 				mpLightingSet->SetItemImage( nItemId + 1, (sal_uInt16)nDirection == nItemId ? maImgLightingOnh[nItemId] : maImgLightingOffh[nItemId] );
688*cdf0e10cSrcweir 			}
689*cdf0e10cSrcweir 			else
690*cdf0e10cSrcweir 			{
691*cdf0e10cSrcweir 				mpLightingSet->SetItemImage( nItemId + 1, (sal_uInt16)nDirection == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId] );
692*cdf0e10cSrcweir 			}
693*cdf0e10cSrcweir 		}
694*cdf0e10cSrcweir 	}
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir 	enableEntry( 3, bEnabled );
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir // -----------------------------------------------------------------------
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir void SAL_CALL ExtrusionLightingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
702*cdf0e10cSrcweir {
703*cdf0e10cSrcweir 	if( Event.FeatureURL.Main.equals( msExtrusionLightingIntensity ) )
704*cdf0e10cSrcweir 	{
705*cdf0e10cSrcweir 		if( !Event.IsEnabled )
706*cdf0e10cSrcweir 		{
707*cdf0e10cSrcweir 			implSetIntensity( 0, false );
708*cdf0e10cSrcweir 		}
709*cdf0e10cSrcweir 		else
710*cdf0e10cSrcweir 		{
711*cdf0e10cSrcweir 			sal_Int32 nValue = 0;
712*cdf0e10cSrcweir 			if( Event.State >>= nValue )
713*cdf0e10cSrcweir 				implSetIntensity( nValue, true );
714*cdf0e10cSrcweir 		}
715*cdf0e10cSrcweir 	}
716*cdf0e10cSrcweir 	else if( Event.FeatureURL.Main.equals( msExtrusionLightingDirection ) )
717*cdf0e10cSrcweir 	{
718*cdf0e10cSrcweir 		if( !Event.IsEnabled )
719*cdf0e10cSrcweir 		{
720*cdf0e10cSrcweir 			implSetDirection( 0, false );
721*cdf0e10cSrcweir 		}
722*cdf0e10cSrcweir 		else
723*cdf0e10cSrcweir 		{
724*cdf0e10cSrcweir 			sal_Int32 nValue = 0;
725*cdf0e10cSrcweir 			if( Event.State >>= nValue )
726*cdf0e10cSrcweir 				implSetDirection( nValue, true );
727*cdf0e10cSrcweir 		}
728*cdf0e10cSrcweir 	}
729*cdf0e10cSrcweir }
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir // -----------------------------------------------------------------------
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt )
734*cdf0e10cSrcweir {
735*cdf0e10cSrcweir 	ToolbarMenu::DataChanged( rDCEvt );
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir 	if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
738*cdf0e10cSrcweir 	{
739*cdf0e10cSrcweir 		bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir 		implSetDirection( mnDirection, mbDirectionEnabled );
742*cdf0e10cSrcweir 		setEntryImage( 0, bHighContrast ? maImgBrighth : maImgBright );
743*cdf0e10cSrcweir 		setEntryImage( 1, bHighContrast ? maImgNormalh : maImgNormal );
744*cdf0e10cSrcweir 		setEntryImage( 2, bHighContrast ? maImgDimh : maImgDim );
745*cdf0e10cSrcweir 	}
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir // -----------------------------------------------------------------------
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl )
751*cdf0e10cSrcweir {
752*cdf0e10cSrcweir 	if ( IsInPopupMode() )
753*cdf0e10cSrcweir 		EndPopupMode();
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 	if( pControl == this )
756*cdf0e10cSrcweir 	{
757*cdf0e10cSrcweir 		int nLevel = getSelectedEntryId();
758*cdf0e10cSrcweir 		if( nLevel >= 0 )
759*cdf0e10cSrcweir 		{
760*cdf0e10cSrcweir 			if( nLevel != 3 )
761*cdf0e10cSrcweir 			{
762*cdf0e10cSrcweir                 Sequence< PropertyValue > aArgs( 1 );
763*cdf0e10cSrcweir                 aArgs[0].Name = msExtrusionLightingIntensity.copy(5);
764*cdf0e10cSrcweir                 aArgs[0].Value <<= (sal_Int32)nLevel;
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 				mrController.dispatchCommand( msExtrusionLightingIntensity, aArgs );
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 				implSetIntensity( nLevel, true );
769*cdf0e10cSrcweir 			}
770*cdf0e10cSrcweir 		}
771*cdf0e10cSrcweir 	}
772*cdf0e10cSrcweir 	else
773*cdf0e10cSrcweir 	{
774*cdf0e10cSrcweir 		sal_Int32 nDirection = mpLightingSet->GetSelectItemId();
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 		if( (nDirection > 0) && (nDirection < 10) )
777*cdf0e10cSrcweir 		{
778*cdf0e10cSrcweir 			nDirection--;
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir             Sequence< PropertyValue > aArgs( 1 );
781*cdf0e10cSrcweir             aArgs[0].Name = msExtrusionLightingDirection.copy(5);
782*cdf0e10cSrcweir             aArgs[0].Value <<= (sal_Int32)nDirection;
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 			mrController.dispatchCommand( msExtrusionLightingDirection, aArgs );
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 			implSetDirection( nDirection, true );
787*cdf0e10cSrcweir 		}
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir 	}
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir 	return 0;
792*cdf0e10cSrcweir }
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir // ========================================================================
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir ExtrusionLightingControl::ExtrusionLightingControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
797*cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) ) )
798*cdf0e10cSrcweir {
799*cdf0e10cSrcweir }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir // -----------------------------------------------------------------------
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir ::Window* ExtrusionLightingControl::createPopupWindow( ::Window* pParent )
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir     return new ExtrusionLightingWindow( *this, m_xFrame, pParent );
806*cdf0e10cSrcweir }
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir // -----------------------------------------------------------------------
809*cdf0e10cSrcweir // XServiceInfo
810*cdf0e10cSrcweir // -----------------------------------------------------------------------
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir OUString SAL_CALL ExtrusionLightingControl_getImplementationName()
813*cdf0e10cSrcweir {
814*cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionLightingController" ));
815*cdf0e10cSrcweir }
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir // --------------------------------------------------------------------
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException )
820*cdf0e10cSrcweir {
821*cdf0e10cSrcweir     Sequence< OUString > aSNS( 1 );
822*cdf0e10cSrcweir     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
823*cdf0e10cSrcweir     return aSNS;
824*cdf0e10cSrcweir }
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir // --------------------------------------------------------------------
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir Reference< XInterface > SAL_CALL SAL_CALL ExtrusionLightingControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
829*cdf0e10cSrcweir {
830*cdf0e10cSrcweir 	return *new ExtrusionLightingControl( rSMgr );
831*cdf0e10cSrcweir }
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir // --------------------------------------------------------------------
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir OUString SAL_CALL ExtrusionLightingControl::getImplementationName(  ) throw (RuntimeException)
836*cdf0e10cSrcweir {
837*cdf0e10cSrcweir 	return ExtrusionLightingControl_getImplementationName();
838*cdf0e10cSrcweir }
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir // --------------------------------------------------------------------
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionLightingControl::getSupportedServiceNames(  ) throw (RuntimeException)
843*cdf0e10cSrcweir {
844*cdf0e10cSrcweir 	return ExtrusionLightingControl_getSupportedServiceNames();
845*cdf0e10cSrcweir }
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir // ####################################################################
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir ExtrusionSurfaceWindow::ExtrusionSurfaceWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
850*cdf0e10cSrcweir : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE ))
851*cdf0e10cSrcweir , mrController( rController )
852*cdf0e10cSrcweir , maImgSurface1( SVX_RES( IMG_WIRE_FRAME ) )
853*cdf0e10cSrcweir , maImgSurface2( SVX_RES( IMG_MATTE ) )
854*cdf0e10cSrcweir , maImgSurface3( SVX_RES( IMG_PLASTIC ) )
855*cdf0e10cSrcweir , maImgSurface4( SVX_RES( IMG_METAL ) )
856*cdf0e10cSrcweir , maImgSurface1h( SVX_RES( IMG_WIRE_FRAME_H ) )
857*cdf0e10cSrcweir , maImgSurface2h( SVX_RES( IMG_MATTE_H ) )
858*cdf0e10cSrcweir , maImgSurface3h( SVX_RES( IMG_PLASTIC_H ) )
859*cdf0e10cSrcweir , maImgSurface4h( SVX_RES( IMG_METAL_H ) )
860*cdf0e10cSrcweir , msExtrusionSurface( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" ))
861*cdf0e10cSrcweir {
862*cdf0e10cSrcweir 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir 	SetHelpId( HID_MENU_EXTRUSION_SURFACE );
865*cdf0e10cSrcweir 	SetSelectHdl( LINK( this, ExtrusionSurfaceWindow, SelectHdl ) );
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir 	appendEntry( 0, String( SVX_RES( STR_WIREFRAME ) ), bHighContrast ? maImgSurface1h : maImgSurface1 );
868*cdf0e10cSrcweir 	appendEntry( 1, String( SVX_RES( STR_MATTE ) ), bHighContrast ? maImgSurface2h : maImgSurface2 );
869*cdf0e10cSrcweir 	appendEntry( 2, String( SVX_RES( STR_PLASTIC ) ), bHighContrast ? maImgSurface3h : maImgSurface3 );
870*cdf0e10cSrcweir 	appendEntry( 3, String( SVX_RES( STR_METAL ) ), bHighContrast ? maImgSurface4h : maImgSurface4 );
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 	SetOutputSizePixel( getMenuSize() );
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir 	FreeResource();
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir     AddStatusListener( msExtrusionSurface );
877*cdf0e10cSrcweir }
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir // -----------------------------------------------------------------------
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
882*cdf0e10cSrcweir {
883*cdf0e10cSrcweir //	if( mpMenu )
884*cdf0e10cSrcweir 	{
885*cdf0e10cSrcweir 		int i;
886*cdf0e10cSrcweir 		for( i = 0; i < 4; i++ )
887*cdf0e10cSrcweir 		{
888*cdf0e10cSrcweir 			checkEntry( i, (i == nSurface) && bEnabled );
889*cdf0e10cSrcweir 			enableEntry( i, bEnabled );
890*cdf0e10cSrcweir 		}
891*cdf0e10cSrcweir 	}
892*cdf0e10cSrcweir }
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir // -----------------------------------------------------------------------
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir void SAL_CALL ExtrusionSurfaceWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir 	if( Event.FeatureURL.Main.equals( msExtrusionSurface ) )
899*cdf0e10cSrcweir 	{
900*cdf0e10cSrcweir 		if( !Event.IsEnabled )
901*cdf0e10cSrcweir 		{
902*cdf0e10cSrcweir 			implSetSurface( 0, false );
903*cdf0e10cSrcweir 		}
904*cdf0e10cSrcweir 		else
905*cdf0e10cSrcweir 		{
906*cdf0e10cSrcweir 			sal_Int32 nValue = 0;
907*cdf0e10cSrcweir 			if( Event.State >>= nValue )
908*cdf0e10cSrcweir 				implSetSurface( nValue, true );
909*cdf0e10cSrcweir 		}
910*cdf0e10cSrcweir 	}
911*cdf0e10cSrcweir }
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir // -----------------------------------------------------------------------
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir IMPL_LINK( ExtrusionSurfaceWindow, SelectHdl, void *, EMPTYARG )
916*cdf0e10cSrcweir {
917*cdf0e10cSrcweir 	if ( IsInPopupMode() )
918*cdf0e10cSrcweir 		EndPopupMode();
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir 	sal_Int32 nSurface = getSelectedEntryId();
921*cdf0e10cSrcweir 	if( nSurface >= 0 )
922*cdf0e10cSrcweir 	{
923*cdf0e10cSrcweir         Sequence< PropertyValue > aArgs( 1 );
924*cdf0e10cSrcweir         aArgs[0].Name = msExtrusionSurface.copy(5);
925*cdf0e10cSrcweir         aArgs[0].Value <<= (sal_Int32)nSurface;
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir 		mrController.dispatchCommand( msExtrusionSurface, aArgs );
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 		implSetSurface( nSurface, true );
930*cdf0e10cSrcweir 	}
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir 	return 0;
933*cdf0e10cSrcweir }
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir // ========================================================================
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir ExtrusionSurfaceControl::ExtrusionSurfaceControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
938*cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurfaceFloater" ) ) )
939*cdf0e10cSrcweir {
940*cdf0e10cSrcweir }
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir // -----------------------------------------------------------------------
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir ::Window* ExtrusionSurfaceControl::createPopupWindow( ::Window* pParent )
945*cdf0e10cSrcweir {
946*cdf0e10cSrcweir     return new ExtrusionSurfaceWindow( *this, m_xFrame, pParent );
947*cdf0e10cSrcweir }
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir // -----------------------------------------------------------------------
950*cdf0e10cSrcweir // XServiceInfo
951*cdf0e10cSrcweir // -----------------------------------------------------------------------
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir OUString SAL_CALL ExtrusionSurfaceControl_getImplementationName()
954*cdf0e10cSrcweir {
955*cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionSurfaceController" ));
956*cdf0e10cSrcweir }
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir // --------------------------------------------------------------------
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException )
961*cdf0e10cSrcweir {
962*cdf0e10cSrcweir     Sequence< OUString > aSNS( 1 );
963*cdf0e10cSrcweir     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
964*cdf0e10cSrcweir     return aSNS;
965*cdf0e10cSrcweir }
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir // --------------------------------------------------------------------
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir Reference< XInterface > SAL_CALL SAL_CALL ExtrusionSurfaceControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
970*cdf0e10cSrcweir {
971*cdf0e10cSrcweir 	return *new ExtrusionSurfaceControl( rSMgr );
972*cdf0e10cSrcweir }
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir // --------------------------------------------------------------------
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir OUString SAL_CALL ExtrusionSurfaceControl::getImplementationName(  ) throw (RuntimeException)
977*cdf0e10cSrcweir {
978*cdf0e10cSrcweir 	return ExtrusionSurfaceControl_getImplementationName();
979*cdf0e10cSrcweir }
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir // --------------------------------------------------------------------
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ExtrusionSurfaceControl::getSupportedServiceNames(  ) throw (RuntimeException)
984*cdf0e10cSrcweir {
985*cdf0e10cSrcweir 	return ExtrusionSurfaceControl_getSupportedServiceNames();
986*cdf0e10cSrcweir }
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir //========================================================================
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( ExtrusionColorControl, SvxColorItem );
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir ExtrusionColorControl::ExtrusionColorControl(
993*cdf0e10cSrcweir 	sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
994*cdf0e10cSrcweir : SfxToolBoxControl	( nSlotId, nId, rTbx )
995*cdf0e10cSrcweir {
996*cdf0e10cSrcweir 	rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
997*cdf0e10cSrcweir     mpBtnUpdater = new ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW );
998*cdf0e10cSrcweir }
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir // -----------------------------------------------------------------------
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir ExtrusionColorControl::~ExtrusionColorControl()
1003*cdf0e10cSrcweir {
1004*cdf0e10cSrcweir 	delete mpBtnUpdater;
1005*cdf0e10cSrcweir }
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir // -----------------------------------------------------------------------
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir SfxPopupWindowType ExtrusionColorControl::GetPopupWindowType() const
1010*cdf0e10cSrcweir {
1011*cdf0e10cSrcweir 	return SFX_POPUPWINDOW_ONCLICK;
1012*cdf0e10cSrcweir }
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir // -----------------------------------------------------------------------
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir SfxPopupWindow*	ExtrusionColorControl::CreatePopupWindow()
1017*cdf0e10cSrcweir {
1018*cdf0e10cSrcweir     SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
1019*cdf0e10cSrcweir 		rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Extrusion3DColor" )),
1020*cdf0e10cSrcweir 		SID_EXTRUSION_3D_COLOR,
1021*cdf0e10cSrcweir 		m_xFrame,
1022*cdf0e10cSrcweir 		SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR ),
1023*cdf0e10cSrcweir         &GetToolBox() );
1024*cdf0e10cSrcweir     pColorWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
1025*cdf0e10cSrcweir 	pColorWin->StartSelection();
1026*cdf0e10cSrcweir     SetPopupWindow( pColorWin );
1027*cdf0e10cSrcweir 	return pColorWin;
1028*cdf0e10cSrcweir }
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir // -----------------------------------------------------------------------
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir void ExtrusionColorControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1033*cdf0e10cSrcweir {
1034*cdf0e10cSrcweir 	sal_uInt16 nId = GetId();
1035*cdf0e10cSrcweir 	ToolBox& rTbx = GetToolBox();
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir 	if( nSID == SID_EXTRUSION_3D_COLOR )
1038*cdf0e10cSrcweir 	{
1039*cdf0e10cSrcweir 		const SvxColorItem*	pItem = 0;
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir 		if( SFX_ITEM_DONTCARE != eState )
1042*cdf0e10cSrcweir 			pItem = PTR_CAST( SvxColorItem, pState );
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 		if ( pItem )
1045*cdf0e10cSrcweir 			mpBtnUpdater->Update( pItem->GetValue());
1046*cdf0e10cSrcweir 	}
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
1049*cdf0e10cSrcweir 	rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
1050*cdf0e10cSrcweir }
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir }
1053