bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / tbxctrls / extrusioncontrols.cxx
blobb4ce7cde262e2d9d4a5c6cca98ff20dbf6c028fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <string>
23 #include <com/sun/star/util/XURLTransformer.hpp>
24 #include <com/sun/star/awt/MenuItemStyle.hpp>
25 #include <com/sun/star/awt/XPopupMenuExtended.hpp>
26 #include <com/sun/star/graphic/XGraphic.hpp>
28 #include <osl/mutex.hxx>
30 #include <svtools/toolbarmenu.hxx>
31 #include <vcl/toolbox.hxx>
32 #include <sfx2/app.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <sfx2/objsh.hxx>
35 #include <svl/eitem.hxx>
36 #include <vcl/settings.hxx>
37 #include <svl/intitem.hxx>
38 #include <editeng/colritem.hxx>
40 #include <svx/dialogs.hrc>
41 #include <svx/svdtrans.hxx>
42 #include <svx/sdasitm.hxx>
43 #include <svx/dialmgr.hxx>
44 #include "svx/extrusioncolorcontrol.hxx"
46 #include "helpid.hrc"
47 #include "extrusioncontrols.hxx"
48 #include "extrusioncontrols.hrc"
49 #include "colorwindow.hxx"
50 #include "extrusiondepthdialog.hxx"
52 ////////////
54 //using ::svtools::ToolbarMenu;
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::lang;
59 using namespace ::com::sun::star::beans;
60 using namespace ::com::sun::star::util;
61 using namespace ::com::sun::star::graphic;
63 namespace svx
66 /*************************************************************************
68 |* ExtrusionDirectionWindow
70 \************************************************************************/
72 static sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
74 ExtrusionDirectionWindow::ExtrusionDirectionWindow(
75 svt::ToolboxController& rController,
76 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
77 Window* pParentWindow
79 : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION )) ,
80 mrController( rController ) ,
81 maImgPerspective( SVX_RES( IMG_PERSPECTIVE ) ) ,
82 maImgParallel( SVX_RES( IMG_PARALLEL ) ) ,
83 msExtrusionDirection( ".uno:ExtrusionDirection" ) ,
84 msExtrusionProjection( ".uno:ExtrusionProjection" )
86 SetHelpId( HID_MENU_EXTRUSION_DIRECTION );
88 sal_uInt16 i;
89 for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
91 maImgDirection[i] = Image( SVX_RES( IMG_DIRECTION + i ) );
94 SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
95 mpDirectionSet = createEmptyValueSetControl();
96 mpDirectionSet->SetHelpId( HID_VALUESET_EXTRUSION_DIRECTION );
98 mpDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
99 mpDirectionSet->SetColCount( 3 );
100 mpDirectionSet->EnableFullItemMode( sal_False );
102 for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
104 String aText( SVX_RES( STR_DIRECTION + i ) );
105 mpDirectionSet->InsertItem( i+1, maImgDirection[ i ], aText );
108 mpDirectionSet->SetOutputSizePixel( Size( 72, 72 ) );
110 appendEntry( 2, mpDirectionSet );
111 appendSeparator();
112 appendEntry( 0, String( SVX_RES( STR_PERSPECTIVE ) ), maImgPerspective );
113 appendEntry( 1, String( SVX_RES( STR_PARALLEL ) ), maImgParallel );
115 SetOutputSizePixel( getMenuSize() );
117 FreeResource();
119 AddStatusListener( msExtrusionDirection );
120 AddStatusListener( msExtrusionProjection );
123 void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt )
125 ToolbarMenu::DataChanged( rDCEvt );
127 if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
129 for( sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
131 mpDirectionSet->SetItemImage( i+1, maImgDirection[ i ] );
134 setEntryImage( 0, maImgPerspective );
135 setEntryImage( 1, maImgParallel );
139 // -----------------------------------------------------------------------
141 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
143 if( mpDirectionSet )
145 sal_uInt16 nItemId;
146 for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
148 if( gSkewList[nItemId] == nSkew )
149 break;
152 if( nItemId <= DIRECTION_SE )
154 mpDirectionSet->SelectItem( nItemId+1 );
156 else
158 mpDirectionSet->SetNoSelection();
161 enableEntry( 2, bEnabled );
164 // -----------------------------------------------------------------------
166 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
168 checkEntry( 0, (nProjection == 0) && bEnabled );
169 checkEntry( 1, (nProjection == 1 ) && bEnabled );
170 enableEntry( 0, bEnabled );
171 enableEntry( 1, bEnabled );
174 // -----------------------------------------------------------------------
176 void SAL_CALL ExtrusionDirectionWindow::statusChanged(
177 const ::com::sun::star::frame::FeatureStateEvent& Event
178 ) throw ( ::com::sun::star::uno::RuntimeException )
180 if( Event.FeatureURL.Main.equals( msExtrusionDirection ) )
182 if( !Event.IsEnabled )
184 implSetDirection( -1, false );
186 else
188 sal_Int32 nValue = 0;
189 if( Event.State >>= nValue )
190 implSetDirection( nValue, true );
193 else if( Event.FeatureURL.Main.equals( msExtrusionProjection ) )
195 if( !Event.IsEnabled )
197 implSetProjection( -1, false );
199 else
201 sal_Int32 nValue = 0;
202 if( Event.State >>= nValue )
203 implSetProjection( nValue, true );
208 // -----------------------------------------------------------------------
210 IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl )
212 if ( IsInPopupMode() )
213 EndPopupMode();
215 if( pControl == mpDirectionSet )
217 Sequence< PropertyValue > aArgs( 1 );
218 aArgs[0].Name = msExtrusionDirection.copy(5);
219 aArgs[0].Value <<= (sal_Int32)gSkewList[mpDirectionSet->GetSelectItemId()-1];
221 mrController.dispatchCommand( msExtrusionDirection, aArgs );
223 else
225 int nProjection = getSelectedEntryId();
226 if( (nProjection >= 0) && (nProjection < 2 ) )
228 Sequence< PropertyValue > aArgs( 1 );
229 aArgs[0].Name = msExtrusionProjection.copy(5);
230 aArgs[0].Value <<= (sal_Int32)nProjection;
232 mrController.dispatchCommand( msExtrusionProjection, aArgs );
233 implSetProjection( nProjection, true );
237 return 0;
240 // =======================================================================
241 // ExtrusionDirectionControl
242 // =======================================================================
244 ExtrusionDirectionControl::ExtrusionDirectionControl(
245 const Reference< XComponentContext >& rxContext
246 ) : svt::PopupWindowController(
247 rxContext,
248 Reference< frame::XFrame >(),
249 OUString( ".uno:ExtrusionDirectionFloater" )
254 // -----------------------------------------------------------------------
256 ::Window* ExtrusionDirectionControl::createPopupWindow( ::Window* pParent )
258 return new ExtrusionDirectionWindow( *this, m_xFrame, pParent );
261 // -----------------------------------------------------------------------
262 // XServiceInfo
263 // -----------------------------------------------------------------------
265 OUString SAL_CALL ExtrusionDirectionControl_getImplementationName()
267 return OUString( "com.sun.star.comp.svx.ExtrusionDirectionController" );
270 // --------------------------------------------------------------------
272 Sequence< OUString > SAL_CALL ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException )
274 Sequence< OUString > aSNS( 1 );
275 aSNS.getArray()[0] = OUString( "com.sun.star.frame.ToolbarController" );
276 return aSNS;
279 // --------------------------------------------------------------------
281 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDirectionControl_createInstance(
282 const Reference< XMultiServiceFactory >& rSMgr
283 ) throw( RuntimeException )
285 return *new ExtrusionDirectionControl( comphelper::getComponentContext(rSMgr) );
288 // --------------------------------------------------------------------
290 OUString SAL_CALL ExtrusionDirectionControl::getImplementationName( ) throw (RuntimeException)
292 return ExtrusionDirectionControl_getImplementationName();
295 // --------------------------------------------------------------------
297 Sequence< OUString > SAL_CALL ExtrusionDirectionControl::getSupportedServiceNames( ) throw (RuntimeException)
299 return ExtrusionDirectionControl_getSupportedServiceNames();
302 // ####################################################################
304 ExtrusionDepthDialog::ExtrusionDepthDialog( Window* pParent, double fDepth, FieldUnit eDefaultUnit )
305 : ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_EXTRUSION_DEPTH ) ),
306 maFLDepth( this, SVX_RES( FL_DEPTH ) ),
307 maMtrDepth( this, SVX_RES( MTR_DEPTH ) ),
308 maOKButton( this, SVX_RES( BTN_OK ) ),
309 maCancelButton( this, SVX_RES( BTN_CANCEL ) ),
310 maHelpButton( this, SVX_RES( BTN_HELP ) )
312 bool bMetric = IsMetric( eDefaultUnit );
313 maMtrDepth.SetUnit( bMetric ? FUNIT_CM : FUNIT_INCH );
314 maMtrDepth.SetValue( (int) fDepth * 100, FUNIT_100TH_MM );
316 FreeResource();
319 ExtrusionDepthDialog::~ExtrusionDepthDialog()
323 double ExtrusionDepthDialog::getDepth() const
325 return (double)( maMtrDepth.GetValue( FUNIT_100TH_MM ) ) / 100.0;
328 // ####################################################################
330 double aDepthListInch[] = { 0, 1270,2540,5080,10160 };
331 double aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
333 ExtrusionDepthWindow::ExtrusionDepthWindow(
334 svt::ToolboxController& rController,
335 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
336 Window* pParentWindow
337 ) : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH ))
338 , mrController( rController )
339 , maImgDepth0( SVX_RES( IMG_DEPTH_0 ) )
340 , maImgDepth1( SVX_RES( IMG_DEPTH_1 ) )
341 , maImgDepth2( SVX_RES( IMG_DEPTH_2 ) )
342 , maImgDepth3( SVX_RES( IMG_DEPTH_3 ) )
343 , maImgDepth4( SVX_RES( IMG_DEPTH_4 ) )
344 , maImgDepthInfinity( SVX_RES( IMG_DEPTH_INFINITY ) )
345 , mfDepth( -1.0 )
346 , msExtrusionDepth( ".uno:ExtrusionDepth" )
347 , msMetricUnit( ".uno:MetricUnit" )
349 SetHelpId( HID_MENU_EXTRUSION_DEPTH );
351 SetSelectHdl( LINK( this, ExtrusionDepthWindow, SelectHdl ) );
353 String aEmpty;
354 appendEntry( 0, aEmpty, maImgDepth0 );
355 appendEntry( 1, aEmpty, maImgDepth1 );
356 appendEntry( 2, aEmpty, maImgDepth2 );
357 appendEntry( 3, aEmpty, maImgDepth3 );
358 appendEntry( 4, aEmpty, maImgDepth4 );
359 appendEntry( 5, String( SVX_RES( STR_INFINITY ) ), maImgDepthInfinity );
360 appendEntry( 6, String( SVX_RES( STR_CUSTOM ) ) );
362 SetOutputSizePixel( getMenuSize() );
364 FreeResource();
366 AddStatusListener( msExtrusionDepth );
367 AddStatusListener( msMetricUnit );
370 // -----------------------------------------------------------------------
372 void ExtrusionDepthWindow::implSetDepth( double fDepth )
374 mfDepth = fDepth;
375 int i;
376 for( i = 0; i < 7; i++ )
378 if( i == 5 )
380 checkEntry( i, fDepth >= 338666 );
382 else if( i != 6 )
384 checkEntry( i, (fDepth == (IsMetric( meUnit ) ? aDepthListMM[i] : aDepthListInch[i]) ) );
389 // -----------------------------------------------------------------------
391 void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit )
393 meUnit = eUnit;
394 sal_uInt16 nResource = IsMetric( eUnit ) ? RID_SVXSTR_DEPTH_0 : RID_SVXSTR_DEPTH_0_INCH;
396 for( int i = 0; i < 5; i++ )
398 String aStr( SVX_RES( nResource + i ) );
399 setEntryText( i, aStr );
403 // -----------------------------------------------------------------------
405 void SAL_CALL ExtrusionDepthWindow::statusChanged(
406 const ::com::sun::star::frame::FeatureStateEvent& Event
407 ) throw ( ::com::sun::star::uno::RuntimeException )
409 if( Event.FeatureURL.Main.equals( msExtrusionDepth ) )
411 if( !Event.IsEnabled )
413 implSetDepth( 0 );
415 else
417 double fValue = 0.0;
418 if( Event.State >>= fValue )
419 implSetDepth( fValue );
422 else if( Event.FeatureURL.Main.equals( msMetricUnit ) )
424 if( Event.IsEnabled )
426 sal_Int32 nValue = 0;
427 if( Event.State >>= nValue )
429 implFillStrings( static_cast<FieldUnit>(nValue) );
430 if( mfDepth >= 0.0 )
431 implSetDepth( mfDepth );
437 // -----------------------------------------------------------------------
439 void ExtrusionDepthWindow::DataChanged( const DataChangedEvent& rDCEvt )
441 ToolbarMenu::DataChanged( rDCEvt );
443 if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
445 setEntryImage( 0, maImgDepth0 );
446 setEntryImage( 1, maImgDepth1 );
447 setEntryImage( 2, maImgDepth2 );
448 setEntryImage( 3, maImgDepth3 );
449 setEntryImage( 4, maImgDepth4 );
450 setEntryImage( 5, maImgDepthInfinity );
455 // -----------------------------------------------------------------------
457 IMPL_LINK_NOARG(ExtrusionDepthWindow, SelectHdl)
459 int nSelected = getSelectedEntryId();
460 if( nSelected != -1 )
462 if( nSelected == 6 )
464 if ( IsInPopupMode() )
465 EndPopupMode();
467 const OUString aCommand( ".uno:ExtrusionDepthDialog" );
469 Any a;
470 Sequence< PropertyValue > aArgs( 2 );
471 aArgs[0].Name = OUString( "Depth" );
472 aArgs[0].Value <<= mfDepth;
473 aArgs[1].Name = OUString( "Metric" );
474 aArgs[1].Value <<= static_cast<sal_Int32>( meUnit );
476 mrController.dispatchCommand( aCommand, aArgs );
478 else
480 double fDepth;
482 if( nSelected == 5 )
484 fDepth = 338666.6;
486 else
488 fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
491 Sequence< PropertyValue > aArgs( 1 );
492 aArgs[0].Name = msExtrusionDepth.copy(5);
493 aArgs[0].Value <<= fDepth;
495 mrController.dispatchCommand( msExtrusionDepth, aArgs );
496 implSetDepth( fDepth );
498 if ( IsInPopupMode() )
499 EndPopupMode();
502 return 0;
505 // =======================================================================
506 // ExtrusionDirectionControl
507 // =======================================================================
509 ExtrusionDepthController::ExtrusionDepthController(
510 const Reference< XComponentContext >& rxContext
511 ) : svt::PopupWindowController(
512 rxContext,
513 Reference< frame::XFrame >(),
514 OUString( ".uno:ExtrusionDepthFloater" )
519 // -----------------------------------------------------------------------
521 ::Window* ExtrusionDepthController::createPopupWindow( ::Window* pParent )
523 return new ExtrusionDepthWindow( *this, m_xFrame, pParent );
527 // -----------------------------------------------------------------------
528 // XServiceInfo
529 // -----------------------------------------------------------------------
531 OUString SAL_CALL ExtrusionDepthController_getImplementationName()
533 return OUString( "com.sun.star.comp.svx.ExtrusionDepthController" );
536 // --------------------------------------------------------------------
538 Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException )
540 Sequence< OUString > aSNS( 1 );
541 aSNS.getArray()[0] = OUString( "com.sun.star.frame.PopupMenuController" );
542 return aSNS;
545 // --------------------------------------------------------------------
547 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDepthController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
549 return *new ExtrusionDepthController( comphelper::getComponentContext(rSMgr) );
552 // --------------------------------------------------------------------
554 OUString SAL_CALL ExtrusionDepthController::getImplementationName( ) throw (RuntimeException)
556 return ExtrusionDepthController_getImplementationName();
559 // --------------------------------------------------------------------
561 Sequence< OUString > SAL_CALL ExtrusionDepthController::getSupportedServiceNames( ) throw (RuntimeException)
563 return ExtrusionDepthController_getSupportedServiceNames();
567 // ####################################################################
569 // -------------------------------------------------------------------------
571 ExtrusionLightingWindow::ExtrusionLightingWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
572 : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING ))
573 , mrController( rController )
574 , maImgBright( SVX_RES( IMG_LIGHTING_BRIGHT ) )
575 , maImgNormal( SVX_RES( IMG_LIGHTING_NORMAL ) )
576 , maImgDim( SVX_RES( IMG_LIGHTING_DIM ) )
577 , mnLevel( 0 )
578 , mbLevelEnabled( false )
579 , mnDirection( FROM_FRONT )
580 , mbDirectionEnabled( false )
581 , msExtrusionLightingDirection( ".uno:ExtrusionLightingDirection" )
582 , msExtrusionLightingIntensity( ".uno:ExtrusionLightingIntensity" )
584 sal_uInt16 i;
585 for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ )
587 if( i != FROM_FRONT )
589 maImgLightingOff[ i ] = Image( SVX_RES( IMG_LIGHT_OFF + i ) );
590 maImgLightingOn[ i ] = Image( SVX_RES( IMG_LIGHT_ON + i ) );
592 maImgLightingPreview[i] = Image( SVX_RES( IMG_LIGHT_PREVIEW + i ) );
595 SetHelpId( HID_MENU_EXTRUSION_LIGHTING );
596 SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
598 mpLightingSet = createEmptyValueSetControl();
599 mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
601 mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
602 mpLightingSet->SetColCount( 3 );
603 mpLightingSet->EnableFullItemMode( sal_False );
605 for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ )
607 if( i != FROM_FRONT )
609 mpLightingSet->InsertItem( i+1, maImgLightingOff[i] );
611 else
613 mpLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
616 mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) );
618 appendEntry( 3, mpLightingSet );
619 appendSeparator();
620 appendEntry( 0, String( SVX_RES( STR_BRIGHT ) ), maImgBright );
621 appendEntry( 1, String( SVX_RES( STR_NORMAL ) ), maImgNormal );
622 appendEntry( 2, String( SVX_RES( STR_DIM ) ), maImgDim );
624 SetOutputSizePixel( getMenuSize() );
626 FreeResource();
628 AddStatusListener( msExtrusionLightingDirection );
629 AddStatusListener( msExtrusionLightingIntensity );
632 // -----------------------------------------------------------------------
634 void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
636 mnLevel = nLevel;
637 mbLevelEnabled = bEnabled;
638 int i = 0;
639 for( i = 0; i < 3; i++ )
641 checkEntry( i, (i == nLevel) && bEnabled );
642 enableEntry( i, bEnabled );
646 // -----------------------------------------------------------------------
648 void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
650 mnDirection = nDirection;
651 mbDirectionEnabled = bEnabled;
653 if( !bEnabled )
654 nDirection = FROM_FRONT;
656 sal_uInt16 nItemId;
657 for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
659 if( nItemId == FROM_FRONT )
661 mpLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
663 else
665 mpLightingSet->SetItemImage(
666 nItemId + 1,
667 (sal_uInt16)nDirection == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
672 enableEntry( 3, bEnabled );
675 // -----------------------------------------------------------------------
677 void SAL_CALL ExtrusionLightingWindow::statusChanged(
678 const ::com::sun::star::frame::FeatureStateEvent& Event
679 ) throw ( ::com::sun::star::uno::RuntimeException )
681 if( Event.FeatureURL.Main.equals( msExtrusionLightingIntensity ) )
683 if( !Event.IsEnabled )
685 implSetIntensity( 0, false );
687 else
689 sal_Int32 nValue = 0;
690 if( Event.State >>= nValue )
691 implSetIntensity( nValue, true );
694 else if( Event.FeatureURL.Main.equals( msExtrusionLightingDirection ) )
696 if( !Event.IsEnabled )
698 implSetDirection( 0, false );
700 else
702 sal_Int32 nValue = 0;
703 if( Event.State >>= nValue )
704 implSetDirection( nValue, true );
709 // -----------------------------------------------------------------------
711 void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt )
713 ToolbarMenu::DataChanged( rDCEvt );
715 if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
717 implSetDirection( mnDirection, mbDirectionEnabled );
718 setEntryImage( 0, maImgBright );
719 setEntryImage( 1, maImgNormal );
720 setEntryImage( 2, maImgDim );
724 // -----------------------------------------------------------------------
726 IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl )
728 if ( IsInPopupMode() )
729 EndPopupMode();
731 if( pControl == this )
733 int nLevel = getSelectedEntryId();
734 if( nLevel >= 0 )
736 if( nLevel != 3 )
738 Sequence< PropertyValue > aArgs( 1 );
739 aArgs[0].Name = msExtrusionLightingIntensity.copy(5);
740 aArgs[0].Value <<= (sal_Int32)nLevel;
742 mrController.dispatchCommand( msExtrusionLightingIntensity, aArgs );
744 implSetIntensity( nLevel, true );
748 else
750 sal_Int32 nDirection = mpLightingSet->GetSelectItemId();
752 if( (nDirection > 0) && (nDirection < 10) )
754 nDirection--;
756 Sequence< PropertyValue > aArgs( 1 );
757 aArgs[0].Name = msExtrusionLightingDirection.copy(5);
758 aArgs[0].Value <<= (sal_Int32)nDirection;
760 mrController.dispatchCommand( msExtrusionLightingDirection, aArgs );
762 implSetDirection( nDirection, true );
767 return 0;
770 // ========================================================================
772 ExtrusionLightingControl::ExtrusionLightingControl(
773 const Reference< XComponentContext >& rxContext
774 ) : svt::PopupWindowController( rxContext,
775 Reference< frame::XFrame >(),
776 OUString( ".uno:ExtrusionDirectionFloater" )
781 // -----------------------------------------------------------------------
783 ::Window* ExtrusionLightingControl::createPopupWindow( ::Window* pParent )
785 return new ExtrusionLightingWindow( *this, m_xFrame, pParent );
788 // -----------------------------------------------------------------------
789 // XServiceInfo
790 // -----------------------------------------------------------------------
792 OUString SAL_CALL ExtrusionLightingControl_getImplementationName()
794 return OUString( "com.sun.star.comp.svx.ExtrusionLightingController" );
797 // --------------------------------------------------------------------
799 Sequence< OUString > SAL_CALL ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException )
801 Sequence< OUString > aSNS( 1 );
802 aSNS.getArray()[0] = OUString( "com.sun.star.frame.ToolbarController" );
803 return aSNS;
806 // --------------------------------------------------------------------
808 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionLightingControl_createInstance(
809 const Reference< XMultiServiceFactory >& rSMgr
810 ) throw( RuntimeException )
812 return *new ExtrusionLightingControl( comphelper::getComponentContext(rSMgr) );
815 // --------------------------------------------------------------------
817 OUString SAL_CALL ExtrusionLightingControl::getImplementationName( ) throw (RuntimeException)
819 return ExtrusionLightingControl_getImplementationName();
822 // --------------------------------------------------------------------
824 Sequence< OUString > SAL_CALL ExtrusionLightingControl::getSupportedServiceNames( ) throw (RuntimeException)
826 return ExtrusionLightingControl_getSupportedServiceNames();
829 // ####################################################################
831 ExtrusionSurfaceWindow::ExtrusionSurfaceWindow(
832 svt::ToolboxController& rController,
833 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
834 Window* pParentWindow
835 ) : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE ) )
836 , mrController( rController )
837 , maImgSurface1( SVX_RES( IMG_WIRE_FRAME ) )
838 , maImgSurface2( SVX_RES( IMG_MATTE ) )
839 , maImgSurface3( SVX_RES( IMG_PLASTIC ) )
840 , maImgSurface4( SVX_RES( IMG_METAL ) )
841 , msExtrusionSurface( ".uno:ExtrusionSurface" )
843 SetHelpId( HID_MENU_EXTRUSION_SURFACE );
844 SetSelectHdl( LINK( this, ExtrusionSurfaceWindow, SelectHdl ) );
846 appendEntry( 0, String( SVX_RES( STR_WIREFRAME ) ), maImgSurface1 );
847 appendEntry( 1, String( SVX_RES( STR_MATTE ) ), maImgSurface2 );
848 appendEntry( 2, String( SVX_RES( STR_PLASTIC ) ), maImgSurface3 );
849 appendEntry( 3, String( SVX_RES( STR_METAL ) ), maImgSurface4 );
851 SetOutputSizePixel( getMenuSize() );
853 FreeResource();
855 AddStatusListener( msExtrusionSurface );
858 // -----------------------------------------------------------------------
860 void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
862 int i;
863 for( i = 0; i < 4; i++ )
865 checkEntry( i, (i == nSurface) && bEnabled );
866 enableEntry( i, bEnabled );
870 // -----------------------------------------------------------------------
872 void SAL_CALL ExtrusionSurfaceWindow::statusChanged(
873 const ::com::sun::star::frame::FeatureStateEvent& Event
874 ) throw ( ::com::sun::star::uno::RuntimeException )
876 if( Event.FeatureURL.Main.equals( msExtrusionSurface ) )
878 if( !Event.IsEnabled )
880 implSetSurface( 0, false );
882 else
884 sal_Int32 nValue = 0;
885 if( Event.State >>= nValue )
886 implSetSurface( nValue, true );
891 // -----------------------------------------------------------------------
893 IMPL_LINK_NOARG(ExtrusionSurfaceWindow, SelectHdl)
895 if ( IsInPopupMode() )
896 EndPopupMode();
898 sal_Int32 nSurface = getSelectedEntryId();
899 if( nSurface >= 0 )
901 Sequence< PropertyValue > aArgs( 1 );
902 aArgs[0].Name = msExtrusionSurface.copy(5);
903 aArgs[0].Value <<= (sal_Int32)nSurface;
905 mrController.dispatchCommand( msExtrusionSurface, aArgs );
907 implSetSurface( nSurface, true );
910 return 0;
913 // ========================================================================
915 ExtrusionSurfaceControl::ExtrusionSurfaceControl(
916 const Reference< XComponentContext >& rxContext
918 : svt::PopupWindowController(
919 rxContext,
920 Reference< frame::XFrame >(),
921 OUString( ".uno:ExtrusionSurfaceFloater" )
926 // -----------------------------------------------------------------------
928 ::Window* ExtrusionSurfaceControl::createPopupWindow( ::Window* pParent )
930 return new ExtrusionSurfaceWindow( *this, m_xFrame, pParent );
933 // -----------------------------------------------------------------------
934 // XServiceInfo
935 // -----------------------------------------------------------------------
937 OUString SAL_CALL ExtrusionSurfaceControl_getImplementationName()
939 return OUString( "com.sun.star.comp.svx.ExtrusionSurfaceController" );
942 // --------------------------------------------------------------------
944 Sequence< OUString > SAL_CALL ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException )
946 Sequence< OUString > aSNS( 1 );
947 aSNS.getArray()[0] = OUString( "com.sun.star.frame.ToolbarController" );
948 return aSNS;
951 // --------------------------------------------------------------------
953 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionSurfaceControl_createInstance(
954 const Reference< XMultiServiceFactory >& rSMgr
955 ) throw( RuntimeException )
957 return *new ExtrusionSurfaceControl( comphelper::getComponentContext(rSMgr) );
960 // --------------------------------------------------------------------
962 OUString SAL_CALL ExtrusionSurfaceControl::getImplementationName( ) throw (RuntimeException)
964 return ExtrusionSurfaceControl_getImplementationName();
967 // --------------------------------------------------------------------
969 Sequence< OUString > SAL_CALL ExtrusionSurfaceControl::getSupportedServiceNames( ) throw (RuntimeException)
971 return ExtrusionSurfaceControl_getSupportedServiceNames();
974 //========================================================================
976 SFX_IMPL_TOOLBOX_CONTROL( ExtrusionColorControl, SvxColorItem );
978 ExtrusionColorControl::ExtrusionColorControl(
979 sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
980 : SfxToolBoxControl ( nSlotId, nId, rTbx ),
981 mLastColor( COL_AUTO )
983 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
984 mpBtnUpdater = new ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW );
987 // -----------------------------------------------------------------------
989 ExtrusionColorControl::~ExtrusionColorControl()
991 delete mpBtnUpdater;
994 // -----------------------------------------------------------------------
996 SfxPopupWindowType ExtrusionColorControl::GetPopupWindowType() const
998 return SFX_POPUPWINDOW_ONCLICK;
1001 // -----------------------------------------------------------------------
1003 SfxPopupWindow* ExtrusionColorControl::CreatePopupWindow()
1005 SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
1006 OUString( ".uno:Extrusion3DColor" ),
1007 SID_EXTRUSION_3D_COLOR,
1008 m_xFrame,
1009 SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR ),
1010 &GetToolBox(),
1011 mLastColor );
1012 pColorWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
1013 pColorWin->StartSelection();
1014 SetPopupWindow( pColorWin );
1015 return pColorWin;
1018 // -----------------------------------------------------------------------
1020 void ExtrusionColorControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1022 sal_uInt16 nId = GetId();
1023 ToolBox& rTbx = GetToolBox();
1025 if( nSID == SID_EXTRUSION_3D_COLOR )
1027 const SvxColorItem* pItem = 0;
1029 if( SFX_ITEM_DONTCARE != eState )
1030 pItem = PTR_CAST( SvxColorItem, pState );
1032 if ( pItem )
1034 mpBtnUpdater->Update( pItem->GetValue());
1035 mLastColor = pItem->GetValue();
1039 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
1040 rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
1045 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */