1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
32 #include <com/sun/star/util/XURLTransformer.hpp>
33 #include <com/sun/star/awt/MenuItemStyle.hpp>
34 #include <com/sun/star/awt/XPopupMenuExtended.hpp>
35 #include <com/sun/star/graphic/XGraphic.hpp>
37 #include <osl/mutex.hxx>
39 #include <svtools/toolbarmenu.hxx>
40 #include <vcl/toolbox.hxx>
41 #include <sfx2/app.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <svl/eitem.hxx>
45 #include <vcl/settings.hxx>
46 #include <svl/intitem.hxx>
47 #include <editeng/colritem.hxx>
49 #include <svx/dialogs.hrc>
50 #include <svx/svdtrans.hxx>
51 #include <svx/sdasitm.hxx>
52 #include <svx/dialmgr.hxx>
53 #include "svx/extrusioncolorcontrol.hxx"
56 #include "extrusioncontrols.hxx"
57 #include "extrusioncontrols.hrc"
58 #include "colorwindow.hxx"
59 #include "extrusiondepthdialog.hxx"
63 using ::rtl::OUString
;
64 //using ::svtools::ToolbarMenu;
66 using namespace ::com::sun::star
;
67 using namespace ::com::sun::star::uno
;
68 using namespace ::com::sun::star::lang
;
69 using namespace ::com::sun::star::beans
;
70 using namespace ::com::sun::star::util
;
71 using namespace ::com::sun::star::graphic
;
76 /*************************************************************************
78 |* ExtrusionDirectionWindow
80 \************************************************************************/
82 static sal_Int32 gSkewList
[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
84 ExtrusionDirectionWindow::ExtrusionDirectionWindow(
85 svt::ToolboxController
& rController
,
86 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
89 : ToolbarMenu( rFrame
, pParentWindow
, SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION
)) ,
90 mrController( rController
) ,
91 maImgPerspective( SVX_RES( IMG_PERSPECTIVE
) ) ,
92 maImgParallel( SVX_RES( IMG_PARALLEL
) ) ,
93 msExtrusionDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" ) ) ,
94 msExtrusionProjection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" ) )
96 SetHelpId( HID_MENU_EXTRUSION_DIRECTION
);
99 for( i
= DIRECTION_NW
; i
<= DIRECTION_SE
; i
++ )
101 maImgDirection
[i
] = Image( SVX_RES( IMG_DIRECTION
+ i
) );
104 SetSelectHdl( LINK( this, ExtrusionDirectionWindow
, SelectHdl
) );
105 mpDirectionSet
= createEmptyValueSetControl();
106 mpDirectionSet
->SetHelpId( HID_VALUESET_EXTRUSION_DIRECTION
);
108 mpDirectionSet
->SetSelectHdl( LINK( this, ExtrusionDirectionWindow
, SelectHdl
) );
109 mpDirectionSet
->SetColCount( 3 );
110 mpDirectionSet
->EnableFullItemMode( sal_False
);
112 for( i
= DIRECTION_NW
; i
<= DIRECTION_SE
; i
++ )
114 String
aText( SVX_RES( STR_DIRECTION
+ i
) );
115 mpDirectionSet
->InsertItem( i
+1, maImgDirection
[ i
], aText
);
118 mpDirectionSet
->SetOutputSizePixel( Size( 72, 72 ) );
120 appendEntry( 2, mpDirectionSet
);
122 appendEntry( 0, String( SVX_RES( STR_PERSPECTIVE
) ), maImgPerspective
);
123 appendEntry( 1, String( SVX_RES( STR_PARALLEL
) ), maImgParallel
);
125 SetOutputSizePixel( getMenuSize() );
129 AddStatusListener( msExtrusionDirection
);
130 AddStatusListener( msExtrusionProjection
);
133 void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
135 ToolbarMenu::DataChanged( rDCEvt
);
137 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
139 for( sal_uInt16 i
= DIRECTION_NW
; i
<= DIRECTION_SE
; i
++ )
141 mpDirectionSet
->SetItemImage( i
+1, maImgDirection
[ i
] );
144 setEntryImage( 0, maImgPerspective
);
145 setEntryImage( 1, maImgParallel
);
149 // -----------------------------------------------------------------------
151 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew
, bool bEnabled
)
156 for( nItemId
= DIRECTION_NW
; nItemId
<= DIRECTION_SE
; nItemId
++ )
158 if( gSkewList
[nItemId
] == nSkew
)
162 if( nItemId
<= DIRECTION_SE
)
164 mpDirectionSet
->SelectItem( nItemId
+1 );
168 mpDirectionSet
->SetNoSelection();
171 enableEntry( 2, bEnabled
);
174 // -----------------------------------------------------------------------
176 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection
, bool bEnabled
)
178 checkEntry( 0, (nProjection
== 0) && bEnabled
);
179 checkEntry( 1, (nProjection
== 1 ) && bEnabled
);
180 enableEntry( 0, bEnabled
);
181 enableEntry( 1, bEnabled
);
184 // -----------------------------------------------------------------------
186 void SAL_CALL
ExtrusionDirectionWindow::statusChanged(
187 const ::com::sun::star::frame::FeatureStateEvent
& Event
188 ) throw ( ::com::sun::star::uno::RuntimeException
)
190 if( Event
.FeatureURL
.Main
.equals( msExtrusionDirection
) )
192 if( !Event
.IsEnabled
)
194 implSetDirection( -1, false );
198 sal_Int32 nValue
= 0;
199 if( Event
.State
>>= nValue
)
200 implSetDirection( nValue
, true );
203 else if( Event
.FeatureURL
.Main
.equals( msExtrusionProjection
) )
205 if( !Event
.IsEnabled
)
207 implSetProjection( -1, false );
211 sal_Int32 nValue
= 0;
212 if( Event
.State
>>= nValue
)
213 implSetProjection( nValue
, true );
218 // -----------------------------------------------------------------------
220 IMPL_LINK( ExtrusionDirectionWindow
, SelectHdl
, void *, pControl
)
222 if ( IsInPopupMode() )
225 if( pControl
== mpDirectionSet
)
227 Sequence
< PropertyValue
> aArgs( 1 );
228 aArgs
[0].Name
= msExtrusionDirection
.copy(5);
229 aArgs
[0].Value
<<= (sal_Int32
)gSkewList
[mpDirectionSet
->GetSelectItemId()-1];
231 mrController
.dispatchCommand( msExtrusionDirection
, aArgs
);
235 int nProjection
= getSelectedEntryId();
236 if( (nProjection
>= 0) && (nProjection
< 2 ) )
238 Sequence
< PropertyValue
> aArgs( 1 );
239 aArgs
[0].Name
= msExtrusionProjection
.copy(5);
240 aArgs
[0].Value
<<= (sal_Int32
)nProjection
;
242 mrController
.dispatchCommand( msExtrusionProjection
, aArgs
);
243 implSetProjection( nProjection
, true );
250 // =======================================================================
251 // ExtrusionDirectionControl
252 // =======================================================================
254 ExtrusionDirectionControl::ExtrusionDirectionControl(
255 const Reference
< lang::XMultiServiceFactory
>& rServiceManager
256 ) : svt::PopupWindowController(
258 Reference
< frame::XFrame
>(),
259 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) )
264 // -----------------------------------------------------------------------
266 ::Window
* ExtrusionDirectionControl::createPopupWindow( ::Window
* pParent
)
268 return new ExtrusionDirectionWindow( *this, m_xFrame
, pParent
);
271 // -----------------------------------------------------------------------
273 // -----------------------------------------------------------------------
275 OUString SAL_CALL
ExtrusionDirectionControl_getImplementationName()
277 return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDirectionController" ));
280 // --------------------------------------------------------------------
282 Sequence
< OUString
> SAL_CALL
ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException
)
284 Sequence
< OUString
> aSNS( 1 );
285 aSNS
.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
289 // --------------------------------------------------------------------
291 Reference
< XInterface
> SAL_CALL SAL_CALL
ExtrusionDirectionControl_createInstance(
292 const Reference
< XMultiServiceFactory
>& rSMgr
293 ) throw( RuntimeException
)
295 return *new ExtrusionDirectionControl( rSMgr
);
298 // --------------------------------------------------------------------
300 OUString SAL_CALL
ExtrusionDirectionControl::getImplementationName( ) throw (RuntimeException
)
302 return ExtrusionDirectionControl_getImplementationName();
305 // --------------------------------------------------------------------
307 Sequence
< OUString
> SAL_CALL
ExtrusionDirectionControl::getSupportedServiceNames( ) throw (RuntimeException
)
309 return ExtrusionDirectionControl_getSupportedServiceNames();
312 // ####################################################################
314 ExtrusionDepthDialog::ExtrusionDepthDialog( Window
* pParent
, double fDepth
, FieldUnit eDefaultUnit
)
315 : ModalDialog( pParent
, SVX_RES( RID_SVX_MDLG_EXTRUSION_DEPTH
) ),
316 maFLDepth( this, SVX_RES( FL_DEPTH
) ),
317 maMtrDepth( this, SVX_RES( MTR_DEPTH
) ),
318 maOKButton( this, SVX_RES( BTN_OK
) ),
319 maCancelButton( this, SVX_RES( BTN_CANCEL
) ),
320 maHelpButton( this, SVX_RES( BTN_HELP
) )
322 bool bMetric
= IsMetric( eDefaultUnit
);
323 maMtrDepth
.SetUnit( bMetric
? FUNIT_CM
: FUNIT_INCH
);
324 maMtrDepth
.SetValue( (int) fDepth
* 100, FUNIT_100TH_MM
);
329 ExtrusionDepthDialog::~ExtrusionDepthDialog()
333 double ExtrusionDepthDialog::getDepth() const
335 return (double)( maMtrDepth
.GetValue( FUNIT_100TH_MM
) ) / 100.0;
338 // ####################################################################
340 double aDepthListInch
[] = { 0, 1270,2540,5080,10160 };
341 double aDepthListMM
[] = { 0, 1000, 2500, 5000, 10000 };
343 ExtrusionDepthWindow::ExtrusionDepthWindow(
344 svt::ToolboxController
& rController
,
345 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
346 Window
* pParentWindow
347 ) : ToolbarMenu( rFrame
, pParentWindow
, SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH
))
348 , mrController( rController
)
349 , maImgDepth0( SVX_RES( IMG_DEPTH_0
) )
350 , maImgDepth1( SVX_RES( IMG_DEPTH_1
) )
351 , maImgDepth2( SVX_RES( IMG_DEPTH_2
) )
352 , maImgDepth3( SVX_RES( IMG_DEPTH_3
) )
353 , maImgDepth4( SVX_RES( IMG_DEPTH_4
) )
354 , maImgDepthInfinity( SVX_RES( IMG_DEPTH_INFINITY
) )
356 , msExtrusionDepth( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" ) )
357 , msMetricUnit( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ) )
359 SetHelpId( HID_MENU_EXTRUSION_DEPTH
);
361 SetSelectHdl( LINK( this, ExtrusionDepthWindow
, SelectHdl
) );
364 appendEntry( 0, aEmpty
, maImgDepth0
);
365 appendEntry( 1, aEmpty
, maImgDepth1
);
366 appendEntry( 2, aEmpty
, maImgDepth2
);
367 appendEntry( 3, aEmpty
, maImgDepth3
);
368 appendEntry( 4, aEmpty
, maImgDepth4
);
369 appendEntry( 5, String( SVX_RES( STR_INFINITY
) ), maImgDepthInfinity
);
370 appendEntry( 6, String( SVX_RES( STR_CUSTOM
) ) );
372 SetOutputSizePixel( getMenuSize() );
376 AddStatusListener( msExtrusionDepth
);
377 AddStatusListener( msMetricUnit
);
380 // -----------------------------------------------------------------------
382 void ExtrusionDepthWindow::implSetDepth( double fDepth
)
386 for( i
= 0; i
< 7; i
++ )
390 checkEntry( i
, fDepth
>= 338666 );
394 checkEntry( i
, (fDepth
== (IsMetric( meUnit
) ? aDepthListMM
[i
] : aDepthListInch
[i
]) ) );
399 // -----------------------------------------------------------------------
401 void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit
)
404 sal_uInt16 nResource
= IsMetric( eUnit
) ? RID_SVXSTR_DEPTH_0
: RID_SVXSTR_DEPTH_0_INCH
;
406 for( int i
= 0; i
< 5; i
++ )
408 String
aStr( SVX_RES( nResource
+ i
) );
409 setEntryText( i
, aStr
);
413 // -----------------------------------------------------------------------
415 void SAL_CALL
ExtrusionDepthWindow::statusChanged(
416 const ::com::sun::star::frame::FeatureStateEvent
& Event
417 ) throw ( ::com::sun::star::uno::RuntimeException
)
419 if( Event
.FeatureURL
.Main
.equals( msExtrusionDepth
) )
421 if( !Event
.IsEnabled
)
428 if( Event
.State
>>= fValue
)
429 implSetDepth( fValue
);
432 else if( Event
.FeatureURL
.Main
.equals( msMetricUnit
) )
434 if( Event
.IsEnabled
)
436 sal_Int32 nValue
= 0;
437 if( Event
.State
>>= nValue
)
439 implFillStrings( static_cast<FieldUnit
>(nValue
) );
441 implSetDepth( mfDepth
);
447 // -----------------------------------------------------------------------
449 void ExtrusionDepthWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
451 ToolbarMenu::DataChanged( rDCEvt
);
453 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
455 setEntryImage( 0, maImgDepth0
);
456 setEntryImage( 1, maImgDepth1
);
457 setEntryImage( 2, maImgDepth2
);
458 setEntryImage( 3, maImgDepth3
);
459 setEntryImage( 4, maImgDepth4
);
460 setEntryImage( 5, maImgDepthInfinity
);
465 // -----------------------------------------------------------------------
467 IMPL_LINK_NOARG(ExtrusionDepthWindow
, SelectHdl
)
469 int nSelected
= getSelectedEntryId();
470 if( nSelected
!= -1 )
474 if ( IsInPopupMode() )
477 const rtl::OUString
aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthDialog" ));
480 Sequence
< PropertyValue
> aArgs( 2 );
481 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Depth" ));
482 aArgs
[0].Value
<<= mfDepth
;
483 aArgs
[1].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ));
484 aArgs
[1].Value
<<= static_cast<sal_Int32
>( meUnit
);
486 mrController
.dispatchCommand( aCommand
, aArgs
);
498 fDepth
= IsMetric( meUnit
) ? aDepthListMM
[nSelected
] : aDepthListInch
[nSelected
];
501 Sequence
< PropertyValue
> aArgs( 1 );
502 aArgs
[0].Name
= msExtrusionDepth
.copy(5);
503 aArgs
[0].Value
<<= fDepth
;
505 mrController
.dispatchCommand( msExtrusionDepth
, aArgs
);
506 implSetDepth( fDepth
);
508 if ( IsInPopupMode() )
515 // =======================================================================
516 // ExtrusionDirectionControl
517 // =======================================================================
519 ExtrusionDepthController::ExtrusionDepthController(
520 const Reference
< lang::XMultiServiceFactory
>& rServiceManager
521 ) : svt::PopupWindowController(
523 Reference
< frame::XFrame
>(),
524 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthFloater" ) )
529 // -----------------------------------------------------------------------
531 ::Window
* ExtrusionDepthController::createPopupWindow( ::Window
* pParent
)
533 return new ExtrusionDepthWindow( *this, m_xFrame
, pParent
);
537 // -----------------------------------------------------------------------
539 // -----------------------------------------------------------------------
541 OUString SAL_CALL
ExtrusionDepthController_getImplementationName()
543 return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDepthController" ));
546 // --------------------------------------------------------------------
548 Sequence
< OUString
> SAL_CALL
ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException
)
550 Sequence
< OUString
> aSNS( 1 );
551 aSNS
.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuController" ));
555 // --------------------------------------------------------------------
557 Reference
< XInterface
> SAL_CALL SAL_CALL
ExtrusionDepthController_createInstance( const Reference
< XMultiServiceFactory
>& rSMgr
) throw( RuntimeException
)
559 return *new ExtrusionDepthController( rSMgr
);
562 // --------------------------------------------------------------------
564 OUString SAL_CALL
ExtrusionDepthController::getImplementationName( ) throw (RuntimeException
)
566 return ExtrusionDepthController_getImplementationName();
569 // --------------------------------------------------------------------
571 Sequence
< OUString
> SAL_CALL
ExtrusionDepthController::getSupportedServiceNames( ) throw (RuntimeException
)
573 return ExtrusionDepthController_getSupportedServiceNames();
577 // ####################################################################
579 // -------------------------------------------------------------------------
581 ExtrusionLightingWindow::ExtrusionLightingWindow( svt::ToolboxController
& rController
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
, Window
* pParentWindow
)
582 : ToolbarMenu( rFrame
, pParentWindow
, SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING
))
583 , mrController( rController
)
584 , maImgBright( SVX_RES( IMG_LIGHTING_BRIGHT
) )
585 , maImgNormal( SVX_RES( IMG_LIGHTING_NORMAL
) )
586 , maImgDim( SVX_RES( IMG_LIGHTING_DIM
) )
588 , mbLevelEnabled( false )
589 , mnDirection( FROM_FRONT
)
590 , mbDirectionEnabled( false )
591 , msExtrusionLightingDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" ))
592 , msExtrusionLightingIntensity( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" ))
595 for( i
= FROM_TOP_LEFT
; i
<= FROM_BOTTOM_RIGHT
; i
++ )
597 if( i
!= FROM_FRONT
)
599 maImgLightingOff
[ i
] = Image( SVX_RES( IMG_LIGHT_OFF
+ i
) );
600 maImgLightingOn
[ i
] = Image( SVX_RES( IMG_LIGHT_ON
+ i
) );
602 maImgLightingPreview
[i
] = Image( SVX_RES( IMG_LIGHT_PREVIEW
+ i
) );
605 SetHelpId( HID_MENU_EXTRUSION_LIGHTING
);
606 SetSelectHdl( LINK( this, ExtrusionLightingWindow
, SelectHdl
) );
608 mpLightingSet
= createEmptyValueSetControl();
609 mpLightingSet
->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING
);
611 mpLightingSet
->SetSelectHdl( LINK( this, ExtrusionLightingWindow
, SelectHdl
) );
612 mpLightingSet
->SetColCount( 3 );
613 mpLightingSet
->EnableFullItemMode( sal_False
);
615 for( i
= FROM_TOP_LEFT
; i
<= FROM_BOTTOM_RIGHT
; i
++ )
617 if( i
!= FROM_FRONT
)
619 mpLightingSet
->InsertItem( i
+1, maImgLightingOff
[i
] );
623 mpLightingSet
->InsertItem( 5, maImgLightingPreview
[FROM_FRONT
] );
626 mpLightingSet
->SetOutputSizePixel( Size( 72, 72 ) );
628 appendEntry( 3, mpLightingSet
);
630 appendEntry( 0, String( SVX_RES( STR_BRIGHT
) ), maImgBright
);
631 appendEntry( 1, String( SVX_RES( STR_NORMAL
) ), maImgNormal
);
632 appendEntry( 2, String( SVX_RES( STR_DIM
) ), maImgDim
);
634 SetOutputSizePixel( getMenuSize() );
638 AddStatusListener( msExtrusionLightingDirection
);
639 AddStatusListener( msExtrusionLightingIntensity
);
642 // -----------------------------------------------------------------------
644 void ExtrusionLightingWindow::implSetIntensity( int nLevel
, bool bEnabled
)
647 mbLevelEnabled
= bEnabled
;
649 for( i
= 0; i
< 3; i
++ )
651 checkEntry( i
, (i
== nLevel
) && bEnabled
);
652 enableEntry( i
, bEnabled
);
656 // -----------------------------------------------------------------------
658 void ExtrusionLightingWindow::implSetDirection( int nDirection
, bool bEnabled
)
660 mnDirection
= nDirection
;
661 mbDirectionEnabled
= bEnabled
;
664 nDirection
= FROM_FRONT
;
667 for( nItemId
= FROM_TOP_LEFT
; nItemId
<= FROM_BOTTOM_RIGHT
; nItemId
++ )
669 if( nItemId
== FROM_FRONT
)
671 mpLightingSet
->SetItemImage( nItemId
+ 1, maImgLightingPreview
[ nDirection
] );
675 mpLightingSet
->SetItemImage(
677 (sal_uInt16
)nDirection
== nItemId
? maImgLightingOn
[nItemId
] : maImgLightingOff
[nItemId
]
682 enableEntry( 3, bEnabled
);
685 // -----------------------------------------------------------------------
687 void SAL_CALL
ExtrusionLightingWindow::statusChanged(
688 const ::com::sun::star::frame::FeatureStateEvent
& Event
689 ) throw ( ::com::sun::star::uno::RuntimeException
)
691 if( Event
.FeatureURL
.Main
.equals( msExtrusionLightingIntensity
) )
693 if( !Event
.IsEnabled
)
695 implSetIntensity( 0, false );
699 sal_Int32 nValue
= 0;
700 if( Event
.State
>>= nValue
)
701 implSetIntensity( nValue
, true );
704 else if( Event
.FeatureURL
.Main
.equals( msExtrusionLightingDirection
) )
706 if( !Event
.IsEnabled
)
708 implSetDirection( 0, false );
712 sal_Int32 nValue
= 0;
713 if( Event
.State
>>= nValue
)
714 implSetDirection( nValue
, true );
719 // -----------------------------------------------------------------------
721 void ExtrusionLightingWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
723 ToolbarMenu::DataChanged( rDCEvt
);
725 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
727 implSetDirection( mnDirection
, mbDirectionEnabled
);
728 setEntryImage( 0, maImgBright
);
729 setEntryImage( 1, maImgNormal
);
730 setEntryImage( 2, maImgDim
);
734 // -----------------------------------------------------------------------
736 IMPL_LINK( ExtrusionLightingWindow
, SelectHdl
, void *, pControl
)
738 if ( IsInPopupMode() )
741 if( pControl
== this )
743 int nLevel
= getSelectedEntryId();
748 Sequence
< PropertyValue
> aArgs( 1 );
749 aArgs
[0].Name
= msExtrusionLightingIntensity
.copy(5);
750 aArgs
[0].Value
<<= (sal_Int32
)nLevel
;
752 mrController
.dispatchCommand( msExtrusionLightingIntensity
, aArgs
);
754 implSetIntensity( nLevel
, true );
760 sal_Int32 nDirection
= mpLightingSet
->GetSelectItemId();
762 if( (nDirection
> 0) && (nDirection
< 10) )
766 Sequence
< PropertyValue
> aArgs( 1 );
767 aArgs
[0].Name
= msExtrusionLightingDirection
.copy(5);
768 aArgs
[0].Value
<<= (sal_Int32
)nDirection
;
770 mrController
.dispatchCommand( msExtrusionLightingDirection
, aArgs
);
772 implSetDirection( nDirection
, true );
780 // ========================================================================
782 ExtrusionLightingControl::ExtrusionLightingControl(
783 const Reference
< lang::XMultiServiceFactory
>& rServiceManager
784 ) : svt::PopupWindowController( rServiceManager
,
785 Reference
< frame::XFrame
>(),
786 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) )
791 // -----------------------------------------------------------------------
793 ::Window
* ExtrusionLightingControl::createPopupWindow( ::Window
* pParent
)
795 return new ExtrusionLightingWindow( *this, m_xFrame
, pParent
);
798 // -----------------------------------------------------------------------
800 // -----------------------------------------------------------------------
802 OUString SAL_CALL
ExtrusionLightingControl_getImplementationName()
804 return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionLightingController" ));
807 // --------------------------------------------------------------------
809 Sequence
< OUString
> SAL_CALL
ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException
)
811 Sequence
< OUString
> aSNS( 1 );
812 aSNS
.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
816 // --------------------------------------------------------------------
818 Reference
< XInterface
> SAL_CALL SAL_CALL
ExtrusionLightingControl_createInstance(
819 const Reference
< XMultiServiceFactory
>& rSMgr
820 ) throw( RuntimeException
)
822 return *new ExtrusionLightingControl( rSMgr
);
825 // --------------------------------------------------------------------
827 OUString SAL_CALL
ExtrusionLightingControl::getImplementationName( ) throw (RuntimeException
)
829 return ExtrusionLightingControl_getImplementationName();
832 // --------------------------------------------------------------------
834 Sequence
< OUString
> SAL_CALL
ExtrusionLightingControl::getSupportedServiceNames( ) throw (RuntimeException
)
836 return ExtrusionLightingControl_getSupportedServiceNames();
839 // ####################################################################
841 ExtrusionSurfaceWindow::ExtrusionSurfaceWindow(
842 svt::ToolboxController
& rController
,
843 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
844 Window
* pParentWindow
845 ) : ToolbarMenu( rFrame
, pParentWindow
, SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE
) )
846 , mrController( rController
)
847 , maImgSurface1( SVX_RES( IMG_WIRE_FRAME
) )
848 , maImgSurface2( SVX_RES( IMG_MATTE
) )
849 , maImgSurface3( SVX_RES( IMG_PLASTIC
) )
850 , maImgSurface4( SVX_RES( IMG_METAL
) )
851 , msExtrusionSurface( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" ) )
853 SetHelpId( HID_MENU_EXTRUSION_SURFACE
);
854 SetSelectHdl( LINK( this, ExtrusionSurfaceWindow
, SelectHdl
) );
856 appendEntry( 0, String( SVX_RES( STR_WIREFRAME
) ), maImgSurface1
);
857 appendEntry( 1, String( SVX_RES( STR_MATTE
) ), maImgSurface2
);
858 appendEntry( 2, String( SVX_RES( STR_PLASTIC
) ), maImgSurface3
);
859 appendEntry( 3, String( SVX_RES( STR_METAL
) ), maImgSurface4
);
861 SetOutputSizePixel( getMenuSize() );
865 AddStatusListener( msExtrusionSurface
);
868 // -----------------------------------------------------------------------
870 void ExtrusionSurfaceWindow::implSetSurface( int nSurface
, bool bEnabled
)
873 for( i
= 0; i
< 4; i
++ )
875 checkEntry( i
, (i
== nSurface
) && bEnabled
);
876 enableEntry( i
, bEnabled
);
880 // -----------------------------------------------------------------------
882 void SAL_CALL
ExtrusionSurfaceWindow::statusChanged(
883 const ::com::sun::star::frame::FeatureStateEvent
& Event
884 ) throw ( ::com::sun::star::uno::RuntimeException
)
886 if( Event
.FeatureURL
.Main
.equals( msExtrusionSurface
) )
888 if( !Event
.IsEnabled
)
890 implSetSurface( 0, false );
894 sal_Int32 nValue
= 0;
895 if( Event
.State
>>= nValue
)
896 implSetSurface( nValue
, true );
901 // -----------------------------------------------------------------------
903 IMPL_LINK_NOARG(ExtrusionSurfaceWindow
, SelectHdl
)
905 if ( IsInPopupMode() )
908 sal_Int32 nSurface
= getSelectedEntryId();
911 Sequence
< PropertyValue
> aArgs( 1 );
912 aArgs
[0].Name
= msExtrusionSurface
.copy(5);
913 aArgs
[0].Value
<<= (sal_Int32
)nSurface
;
915 mrController
.dispatchCommand( msExtrusionSurface
, aArgs
);
917 implSetSurface( nSurface
, true );
923 // ========================================================================
925 ExtrusionSurfaceControl::ExtrusionSurfaceControl(
926 const Reference
< lang::XMultiServiceFactory
>& rServiceManager
928 : svt::PopupWindowController(
930 Reference
< frame::XFrame
>(),
931 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurfaceFloater" ) )
936 // -----------------------------------------------------------------------
938 ::Window
* ExtrusionSurfaceControl::createPopupWindow( ::Window
* pParent
)
940 return new ExtrusionSurfaceWindow( *this, m_xFrame
, pParent
);
943 // -----------------------------------------------------------------------
945 // -----------------------------------------------------------------------
947 OUString SAL_CALL
ExtrusionSurfaceControl_getImplementationName()
949 return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionSurfaceController" ));
952 // --------------------------------------------------------------------
954 Sequence
< OUString
> SAL_CALL
ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException
)
956 Sequence
< OUString
> aSNS( 1 );
957 aSNS
.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
961 // --------------------------------------------------------------------
963 Reference
< XInterface
> SAL_CALL SAL_CALL
ExtrusionSurfaceControl_createInstance(
964 const Reference
< XMultiServiceFactory
>& rSMgr
965 ) throw( RuntimeException
)
967 return *new ExtrusionSurfaceControl( rSMgr
);
970 // --------------------------------------------------------------------
972 OUString SAL_CALL
ExtrusionSurfaceControl::getImplementationName( ) throw (RuntimeException
)
974 return ExtrusionSurfaceControl_getImplementationName();
977 // --------------------------------------------------------------------
979 Sequence
< OUString
> SAL_CALL
ExtrusionSurfaceControl::getSupportedServiceNames( ) throw (RuntimeException
)
981 return ExtrusionSurfaceControl_getSupportedServiceNames();
984 //========================================================================
986 SFX_IMPL_TOOLBOX_CONTROL( ExtrusionColorControl
, SvxColorItem
);
988 ExtrusionColorControl::ExtrusionColorControl(
989 sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
)
990 : SfxToolBoxControl ( nSlotId
, nId
, rTbx
),
991 mLastColor( COL_AUTO
)
993 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
994 mpBtnUpdater
= new ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW
);
997 // -----------------------------------------------------------------------
999 ExtrusionColorControl::~ExtrusionColorControl()
1001 delete mpBtnUpdater
;
1004 // -----------------------------------------------------------------------
1006 SfxPopupWindowType
ExtrusionColorControl::GetPopupWindowType() const
1008 return SFX_POPUPWINDOW_ONCLICK
;
1011 // -----------------------------------------------------------------------
1013 SfxPopupWindow
* ExtrusionColorControl::CreatePopupWindow()
1015 SvxColorWindow_Impl
* pColorWin
= new SvxColorWindow_Impl(
1016 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Extrusion3DColor" )),
1017 SID_EXTRUSION_3D_COLOR
,
1019 SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR
),
1022 pColorWin
->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
1023 pColorWin
->StartSelection();
1024 SetPopupWindow( pColorWin
);
1028 // -----------------------------------------------------------------------
1030 void ExtrusionColorControl::StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
1032 sal_uInt16 nId
= GetId();
1033 ToolBox
& rTbx
= GetToolBox();
1035 if( nSID
== SID_EXTRUSION_3D_COLOR
)
1037 const SvxColorItem
* pItem
= 0;
1039 if( SFX_ITEM_DONTCARE
!= eState
)
1040 pItem
= PTR_CAST( SvxColorItem
, pState
);
1044 mpBtnUpdater
->Update( pItem
->GetValue());
1045 mLastColor
= pItem
->GetValue();
1049 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
1050 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
1055 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */