bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / tbxctrls / extrusioncontrols.cxx
blobb9d988ae37b1a7293ad8937aa0abcfd00b77fe1c
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 <osl/mutex.hxx>
25 #include <svtools/toolbarmenu.hxx>
26 #include <vcl/toolbox.hxx>
27 #include <sfx2/app.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <svl/eitem.hxx>
31 #include <vcl/settings.hxx>
32 #include <svl/intitem.hxx>
33 #include <editeng/colritem.hxx>
35 #include <svx/dialogs.hrc>
36 #include <svx/svdtrans.hxx>
37 #include <svx/sdasitm.hxx>
38 #include <svx/dialmgr.hxx>
40 #include "coreservices.hxx"
41 #include "helpid.hrc"
42 #include "extrusioncontrols.hxx"
43 #include "extrusioncontrols.hrc"
44 #include "colorwindow.hxx"
45 #include "extrusiondepthdialog.hxx"
49 //using ::svtools::ToolbarMenu;
51 using namespace ::com::sun::star;
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::beans;
55 using namespace ::com::sun::star::util;
56 using namespace ::com::sun::star::graphic;
58 namespace svx
61 static const sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
63 ExtrusionDirectionWindow::ExtrusionDirectionWindow(
64 svt::ToolboxController& rController,
65 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
66 vcl::Window* pParentWindow
68 : ToolbarMenu(rFrame, pParentWindow,
69 WB_MOVEABLE|WB_CLOSEABLE|WB_HIDE|WB_3DLOOK)
70 , mrController(rController)
71 , maImgPerspective(SVX_RES(RID_SVXIMG_PERSPECTIVE))
72 , maImgParallel(SVX_RES(RID_SVXIMG_PARALLEL))
73 , msExtrusionDirection(".uno:ExtrusionDirection")
74 , msExtrusionProjection(".uno:ExtrusionProjection")
76 for(sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
78 maImgDirection[i] = Image( SVX_RES( RID_SVXIMG_DIRECTION + i ) );
81 SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
82 mpDirectionSet = createEmptyValueSetControl();
84 mpDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
85 mpDirectionSet->SetColCount( 3 );
86 mpDirectionSet->EnableFullItemMode( false );
88 for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
90 OUString aText(SVX_RESSTR(RID_SVXSTR_DIRECTION + i));
91 mpDirectionSet->InsertItem(i + 1, maImgDirection[i], aText);
94 mpDirectionSet->SetOutputSizePixel(Size(72, 72));
96 appendEntry(2, mpDirectionSet );
97 appendSeparator();
98 appendEntry(0, SVX_RESSTR(RID_SVXSTR_PERSPECTIVE), maImgPerspective);
99 appendEntry(1, SVX_RESSTR(RID_SVXSTR_PARALLEL), maImgParallel);
101 SetOutputSizePixel( getMenuSize() );
103 AddStatusListener( msExtrusionDirection );
104 AddStatusListener( msExtrusionProjection );
107 ExtrusionDirectionWindow::~ExtrusionDirectionWindow()
109 disposeOnce();
112 void ExtrusionDirectionWindow::dispose()
114 mpDirectionSet.clear();
115 ToolbarMenu::dispose();
118 void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt )
120 ToolbarMenu::DataChanged( rDCEvt );
122 if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
124 for( sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
126 mpDirectionSet->SetItemImage( i+1, maImgDirection[ i ] );
129 setEntryImage( 0, maImgPerspective );
130 setEntryImage( 1, maImgParallel );
136 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
138 if( mpDirectionSet )
140 sal_uInt16 nItemId;
141 for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
143 if( gSkewList[nItemId] == nSkew )
144 break;
147 if( nItemId <= DIRECTION_SE )
149 mpDirectionSet->SelectItem( nItemId+1 );
151 else
153 mpDirectionSet->SetNoSelection();
156 enableEntry( 2, bEnabled );
161 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
163 checkEntry( 0, (nProjection == 0) && bEnabled );
164 checkEntry( 1, (nProjection == 1 ) && bEnabled );
165 enableEntry( 0, bEnabled );
166 enableEntry( 1, bEnabled );
171 void ExtrusionDirectionWindow::statusChanged(
172 const ::com::sun::star::frame::FeatureStateEvent& Event
173 ) throw ( ::com::sun::star::uno::RuntimeException )
175 if( Event.FeatureURL.Main.equals( msExtrusionDirection ) )
177 if( !Event.IsEnabled )
179 implSetDirection( -1, false );
181 else
183 sal_Int32 nValue = 0;
184 if( Event.State >>= nValue )
185 implSetDirection( nValue, true );
188 else if( Event.FeatureURL.Main.equals( msExtrusionProjection ) )
190 if( !Event.IsEnabled )
192 implSetProjection( -1, false );
194 else
196 sal_Int32 nValue = 0;
197 if( Event.State >>= nValue )
198 implSetProjection( nValue, true );
205 IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl )
207 if ( IsInPopupMode() )
208 EndPopupMode();
210 if( pControl == mpDirectionSet )
212 Sequence< PropertyValue > aArgs( 1 );
213 aArgs[0].Name = msExtrusionDirection.copy(5);
214 aArgs[0].Value <<= (sal_Int32)gSkewList[mpDirectionSet->GetSelectItemId()-1];
216 mrController.dispatchCommand( msExtrusionDirection, aArgs );
218 else
220 int nProjection = getSelectedEntryId();
221 if( (nProjection >= 0) && (nProjection < 2 ) )
223 Sequence< PropertyValue > aArgs( 1 );
224 aArgs[0].Name = msExtrusionProjection.copy(5);
225 aArgs[0].Value <<= (sal_Int32)nProjection;
227 mrController.dispatchCommand( msExtrusionProjection, aArgs );
228 implSetProjection( nProjection, true );
232 return 0;
235 ExtrusionDirectionControl::ExtrusionDirectionControl(
236 const Reference< XComponentContext >& rxContext
237 ) : svt::PopupWindowController(
238 rxContext,
239 Reference< frame::XFrame >(),
240 OUString( ".uno:ExtrusionDirectionFloater" )
247 VclPtr<vcl::Window> ExtrusionDirectionControl::createPopupWindow( vcl::Window* pParent )
249 return VclPtr<ExtrusionDirectionWindow>::Create( *this, m_xFrame, pParent );
252 // XInitialization
253 void SAL_CALL ExtrusionDirectionControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
254 throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
256 svt::PopupWindowController::initialize( aArguments );
258 ToolBox* pToolBox = 0;
259 sal_uInt16 nId = 0;
260 if ( getToolboxId( nId, &pToolBox ) )
261 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
264 // XServiceInfo
267 OUString SAL_CALL ExtrusionDirectionControl_getImplementationName()
269 return OUString( "com.sun.star.comp.svx.ExtrusionDirectionController" );
274 Sequence< OUString > SAL_CALL ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException )
276 Sequence< OUString > aSNS( 1 );
277 aSNS.getArray()[0] = "com.sun.star.frame.ToolbarController";
278 return aSNS;
283 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDirectionControl_createInstance(
284 const Reference< XMultiServiceFactory >& rSMgr
285 ) throw( RuntimeException )
287 return *new ExtrusionDirectionControl( comphelper::getComponentContext(rSMgr) );
292 OUString SAL_CALL ExtrusionDirectionControl::getImplementationName( ) throw (RuntimeException, std::exception)
294 return ExtrusionDirectionControl_getImplementationName();
299 Sequence< OUString > SAL_CALL ExtrusionDirectionControl::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
301 return ExtrusionDirectionControl_getSupportedServiceNames();
304 ExtrusionDepthDialog::ExtrusionDepthDialog( vcl::Window* pParent, double fDepth, FieldUnit eDefaultUnit )
305 : ModalDialog( pParent, "ExtrustionDepthDialog", "svx/ui/extrustiondepthdialog.ui" )
307 get(m_pMtrDepth, "depth");
308 m_pMtrDepth->SetUnit( eDefaultUnit );
309 m_pMtrDepth->SetValue( (int) fDepth * 100, FUNIT_100TH_MM );
312 ExtrusionDepthDialog::~ExtrusionDepthDialog()
314 disposeOnce();
317 void ExtrusionDepthDialog::dispose()
319 m_pMtrDepth.clear();
320 ModalDialog::dispose();
323 double ExtrusionDepthDialog::getDepth() const
325 return (double)( m_pMtrDepth->GetValue( FUNIT_100TH_MM ) ) / 100.0;
328 double aDepthListInch[] = { 0, 1270,2540,5080,10160 };
329 double aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
331 ExtrusionDepthWindow::ExtrusionDepthWindow(
332 svt::ToolboxController& rController,
333 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
334 vcl::Window* pParentWindow
335 ) : ToolbarMenu( rFrame, pParentWindow, WB_MOVEABLE|WB_CLOSEABLE|WB_HIDE|WB_3DLOOK)
336 , mrController( rController )
337 , maImgDepth0(SVX_RES(RID_SVXIMG_DEPTH_0))
338 , maImgDepth1(SVX_RES(RID_SVXIMG_DEPTH_1))
339 , maImgDepth2(SVX_RES(RID_SVXIMG_DEPTH_2))
340 , maImgDepth3(SVX_RES(RID_SVXIMG_DEPTH_3))
341 , maImgDepth4(SVX_RES(RID_SVXIMG_DEPTH_4))
342 , maImgDepthInfinity(SVX_RES(RID_SVXIMG_DEPTH_INFINITY))
343 , meUnit(FUNIT_NONE)
344 , mfDepth( -1.0 )
345 , msExtrusionDepth( ".uno:ExtrusionDepth" )
346 , msMetricUnit( ".uno:MetricUnit" )
348 SetSelectHdl( LINK( this, ExtrusionDepthWindow, SelectHdl ) );
350 OUString aEmpty;
351 appendEntry(0, aEmpty, maImgDepth0);
352 appendEntry(1, aEmpty, maImgDepth1);
353 appendEntry(2, aEmpty, maImgDepth2);
354 appendEntry(3, aEmpty, maImgDepth3);
355 appendEntry(4, aEmpty, maImgDepth4);
356 appendEntry(5, SVX_RESSTR(RID_SVXSTR_INFINITY), maImgDepthInfinity);
357 appendEntry(6, SVX_RESSTR(RID_SVXSTR_CUSTOM));
359 SetOutputSizePixel( getMenuSize() );
361 AddStatusListener( msExtrusionDepth );
362 AddStatusListener( msMetricUnit );
365 void ExtrusionDepthWindow::implSetDepth( double fDepth )
367 mfDepth = fDepth;
368 int i;
369 for( i = 0; i < 7; i++ )
371 if( i == 5 )
373 checkEntry( i, fDepth >= 338666 );
375 else if( i != 6 )
377 checkEntry( i, (fDepth == (IsMetric( meUnit ) ? aDepthListMM[i] : aDepthListInch[i]) ) );
384 void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit )
386 meUnit = eUnit;
387 sal_uInt16 nResource = IsMetric( eUnit ) ? RID_SVXSTR_DEPTH_0 : RID_SVXSTR_DEPTH_0_INCH;
389 for( int i = 0; i < 5; i++ )
391 OUString aStr( SVX_RESSTR( nResource + i ) );
392 setEntryText( i, aStr );
398 void ExtrusionDepthWindow::statusChanged(
399 const ::com::sun::star::frame::FeatureStateEvent& Event
400 ) throw ( ::com::sun::star::uno::RuntimeException )
402 if( Event.FeatureURL.Main.equals( msExtrusionDepth ) )
404 if( !Event.IsEnabled )
406 implSetDepth( 0 );
408 else
410 double fValue = 0.0;
411 if( Event.State >>= fValue )
412 implSetDepth( fValue );
415 else if( Event.FeatureURL.Main.equals( msMetricUnit ) )
417 if( Event.IsEnabled )
419 sal_Int32 nValue = 0;
420 if( Event.State >>= nValue )
422 implFillStrings( static_cast<FieldUnit>(nValue) );
423 if( mfDepth >= 0.0 )
424 implSetDepth( mfDepth );
430 IMPL_LINK_NOARG(ExtrusionDepthWindow, SelectHdl)
432 int nSelected = getSelectedEntryId();
433 if( nSelected != -1 )
435 if( nSelected == 6 )
437 if ( IsInPopupMode() )
438 EndPopupMode();
440 const OUString aCommand( ".uno:ExtrusionDepthDialog" );
442 Sequence< PropertyValue > aArgs( 2 );
443 aArgs[0].Name = "Depth";
444 aArgs[0].Value <<= mfDepth;
445 aArgs[1].Name = "Metric";
446 aArgs[1].Value <<= static_cast<sal_Int32>( meUnit );
448 mrController.dispatchCommand( aCommand, aArgs );
450 else
452 double fDepth;
454 if( nSelected == 5 )
456 fDepth = 338666.6;
458 else
460 fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
463 Sequence< PropertyValue > aArgs( 1 );
464 aArgs[0].Name = msExtrusionDepth.copy(5);
465 aArgs[0].Value <<= fDepth;
467 mrController.dispatchCommand( msExtrusionDepth, aArgs );
468 implSetDepth( fDepth );
470 if ( IsInPopupMode() )
471 EndPopupMode();
474 return 0;
478 // ExtrusionDirectionControl
481 ExtrusionDepthController::ExtrusionDepthController(
482 const Reference< XComponentContext >& rxContext
483 ) : svt::PopupWindowController(
484 rxContext,
485 Reference< frame::XFrame >(),
486 OUString( ".uno:ExtrusionDepthFloater" )
493 VclPtr<vcl::Window> ExtrusionDepthController::createPopupWindow( vcl::Window* pParent )
495 return VclPtr<ExtrusionDepthWindow>::Create( *this, m_xFrame, pParent );
498 // XInitialization
499 void SAL_CALL ExtrusionDepthController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
500 throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
502 svt::PopupWindowController::initialize( aArguments );
504 ToolBox* pToolBox = 0;
505 sal_uInt16 nId = 0;
506 if ( getToolboxId( nId, &pToolBox ) )
507 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
510 // XServiceInfo
513 OUString SAL_CALL ExtrusionDepthController_getImplementationName()
515 return OUString( "com.sun.star.comp.svx.ExtrusionDepthController" );
520 Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException )
522 Sequence< OUString > aSNS( 1 );
523 aSNS.getArray()[0] = "com.sun.star.frame.ToolbarController";
524 return aSNS;
529 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDepthController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
531 return *new ExtrusionDepthController( comphelper::getComponentContext(rSMgr) );
534 OUString SAL_CALL ExtrusionDepthController::getImplementationName( ) throw (RuntimeException, std::exception)
536 return ExtrusionDepthController_getImplementationName();
539 Sequence< OUString > SAL_CALL ExtrusionDepthController::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
541 return ExtrusionDepthController_getSupportedServiceNames();
544 ExtrusionLightingWindow::ExtrusionLightingWindow(svt::ToolboxController& rController,
545 const css::uno::Reference<css::frame::XFrame >& rFrame,
546 vcl::Window* pParentWindow)
547 : ToolbarMenu(rFrame, pParentWindow, WB_MOVEABLE|WB_CLOSEABLE|WB_HIDE|WB_3DLOOK)
548 , mrController(rController)
549 , maImgBright(SVX_RES(RID_SVXIMG_LIGHTING_BRIGHT))
550 , maImgNormal(SVX_RES(RID_SVXIMG_LIGHTING_NORMAL))
551 , maImgDim(SVX_RES(RID_SVXIMG_LIGHTING_DIM))
552 , mnLevel(0)
553 , mbLevelEnabled(false)
554 , mnDirection(FROM_FRONT)
555 , mbDirectionEnabled(false)
556 , msExtrusionLightingDirection(".uno:ExtrusionLightingDirection")
557 , msExtrusionLightingIntensity(".uno:ExtrusionLightingIntensity")
559 for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
561 if( i != FROM_FRONT )
563 maImgLightingOff[i] = Image(SVX_RES(RID_SVXIMG_LIGHT_OFF + i));
564 maImgLightingOn[i] = Image(SVX_RES(RID_SVXIMG_LIGHT_ON + i));
566 maImgLightingPreview[i] = Image(SVX_RES(RID_SVXIMG_LIGHT_PREVIEW + i));
569 SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
571 mpLightingSet = createEmptyValueSetControl();
572 mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
574 mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
575 mpLightingSet->SetColCount( 3 );
576 mpLightingSet->EnableFullItemMode( false );
578 for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
580 if( i != FROM_FRONT )
582 mpLightingSet->InsertItem( i+1, maImgLightingOff[i] );
584 else
586 mpLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
589 mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) );
591 appendEntry(3, mpLightingSet);
592 appendSeparator();
593 appendEntry(0, SVX_RESSTR(RID_SVXSTR_BRIGHT), maImgBright);
594 appendEntry(1, SVX_RESSTR(RID_SVXSTR_NORMAL), maImgNormal);
595 appendEntry(2, SVX_RESSTR(RID_SVXSTR_DIM), maImgDim);
597 SetOutputSizePixel( getMenuSize() );
599 AddStatusListener( msExtrusionLightingDirection );
600 AddStatusListener( msExtrusionLightingIntensity );
603 ExtrusionLightingWindow::~ExtrusionLightingWindow()
605 disposeOnce();
608 void ExtrusionLightingWindow::dispose()
610 mpLightingSet.clear();
611 ToolbarMenu::dispose();
614 void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
616 mnLevel = nLevel;
617 mbLevelEnabled = bEnabled;
618 for (int i = 0; i < 3; ++i)
620 checkEntry( i, (i == nLevel) && bEnabled );
621 enableEntry( i, bEnabled );
625 void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
627 mnDirection = nDirection;
628 mbDirectionEnabled = bEnabled;
630 if( !bEnabled )
631 nDirection = FROM_FRONT;
633 sal_uInt16 nItemId;
634 for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
636 if( nItemId == FROM_FRONT )
638 mpLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
640 else
642 mpLightingSet->SetItemImage(
643 nItemId + 1,
644 (sal_uInt16)nDirection == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
649 enableEntry( 3, bEnabled );
654 void ExtrusionLightingWindow::statusChanged(
655 const ::com::sun::star::frame::FeatureStateEvent& Event
656 ) throw ( ::com::sun::star::uno::RuntimeException )
658 if( Event.FeatureURL.Main.equals( msExtrusionLightingIntensity ) )
660 if( !Event.IsEnabled )
662 implSetIntensity( 0, false );
664 else
666 sal_Int32 nValue = 0;
667 if( Event.State >>= nValue )
668 implSetIntensity( nValue, true );
671 else if( Event.FeatureURL.Main.equals( msExtrusionLightingDirection ) )
673 if( !Event.IsEnabled )
675 implSetDirection( 0, false );
677 else
679 sal_Int32 nValue = 0;
680 if( Event.State >>= nValue )
681 implSetDirection( nValue, true );
688 void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt )
690 ToolbarMenu::DataChanged( rDCEvt );
692 if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
694 implSetDirection( mnDirection, mbDirectionEnabled );
695 setEntryImage( 0, maImgBright );
696 setEntryImage( 1, maImgNormal );
697 setEntryImage( 2, maImgDim );
703 IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl )
705 if ( IsInPopupMode() )
706 EndPopupMode();
708 if( pControl == this )
710 int nLevel = getSelectedEntryId();
711 if( nLevel >= 0 )
713 if( nLevel != 3 )
715 Sequence< PropertyValue > aArgs( 1 );
716 aArgs[0].Name = msExtrusionLightingIntensity.copy(5);
717 aArgs[0].Value <<= (sal_Int32)nLevel;
719 mrController.dispatchCommand( msExtrusionLightingIntensity, aArgs );
721 implSetIntensity( nLevel, true );
725 else
727 sal_Int32 nDirection = mpLightingSet->GetSelectItemId();
729 if( (nDirection > 0) && (nDirection < 10) )
731 nDirection--;
733 Sequence< PropertyValue > aArgs( 1 );
734 aArgs[0].Name = msExtrusionLightingDirection.copy(5);
735 aArgs[0].Value <<= (sal_Int32)nDirection;
737 mrController.dispatchCommand( msExtrusionLightingDirection, aArgs );
739 implSetDirection( nDirection, true );
744 return 0;
749 ExtrusionLightingControl::ExtrusionLightingControl(
750 const Reference< XComponentContext >& rxContext
751 ) : svt::PopupWindowController( rxContext,
752 Reference< frame::XFrame >(),
753 OUString( ".uno:ExtrusionDirectionFloater" )
760 VclPtr<vcl::Window> ExtrusionLightingControl::createPopupWindow( vcl::Window* pParent )
762 return VclPtr<ExtrusionLightingWindow>::Create( *this, m_xFrame, pParent );
765 // XInitialization
766 void SAL_CALL ExtrusionLightingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
767 throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
769 svt::PopupWindowController::initialize( aArguments );
771 ToolBox* pToolBox = 0;
772 sal_uInt16 nId = 0;
773 if ( getToolboxId( nId, &pToolBox ) )
774 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
777 // XServiceInfo
780 OUString SAL_CALL ExtrusionLightingControl_getImplementationName()
782 return OUString( "com.sun.star.comp.svx.ExtrusionLightingController" );
787 Sequence< OUString > SAL_CALL ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException )
789 Sequence< OUString > aSNS( 1 );
790 aSNS.getArray()[0] = "com.sun.star.frame.ToolbarController";
791 return aSNS;
796 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionLightingControl_createInstance(
797 const Reference< XMultiServiceFactory >& rSMgr
798 ) throw( RuntimeException )
800 return *new ExtrusionLightingControl( comphelper::getComponentContext(rSMgr) );
805 OUString SAL_CALL ExtrusionLightingControl::getImplementationName( ) throw (RuntimeException, std::exception)
807 return ExtrusionLightingControl_getImplementationName();
812 Sequence< OUString > SAL_CALL ExtrusionLightingControl::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
814 return ExtrusionLightingControl_getSupportedServiceNames();
817 ExtrusionSurfaceWindow::ExtrusionSurfaceWindow(
818 svt::ToolboxController& rController,
819 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
820 vcl::Window* pParentWindow)
821 : ToolbarMenu(rFrame, pParentWindow, WB_MOVEABLE|WB_CLOSEABLE|WB_HIDE|WB_3DLOOK)
822 , mrController(rController)
823 , maImgSurface1(SVX_RES(RID_SVXIMG_WIRE_FRAME))
824 , maImgSurface2(SVX_RES(RID_SVXIMG_MATTE))
825 , maImgSurface3(SVX_RES(RID_SVXIMG_PLASTIC))
826 , maImgSurface4(SVX_RES(RID_SVXIMG_METAL))
827 , msExtrusionSurface(".uno:ExtrusionSurface")
829 SetSelectHdl( LINK( this, ExtrusionSurfaceWindow, SelectHdl ) );
831 appendEntry(0, SVX_RESSTR(RID_SVXSTR_WIREFRAME), maImgSurface1);
832 appendEntry(1, SVX_RESSTR(RID_SVXSTR_MATTE), maImgSurface2);
833 appendEntry(2, SVX_RESSTR(RID_SVXSTR_PLASTIC), maImgSurface3);
834 appendEntry(3, SVX_RESSTR(RID_SVXSTR_METAL), maImgSurface4);
836 SetOutputSizePixel( getMenuSize() );
838 AddStatusListener( msExtrusionSurface );
841 void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
843 for(int i = 0; i < 4; ++i)
845 checkEntry( i, (i == nSurface) && bEnabled );
846 enableEntry( i, bEnabled );
850 void ExtrusionSurfaceWindow::statusChanged(
851 const ::com::sun::star::frame::FeatureStateEvent& Event
852 ) throw ( ::com::sun::star::uno::RuntimeException )
854 if( Event.FeatureURL.Main.equals( msExtrusionSurface ) )
856 if( !Event.IsEnabled )
858 implSetSurface( 0, false );
860 else
862 sal_Int32 nValue = 0;
863 if( Event.State >>= nValue )
864 implSetSurface( nValue, true );
871 IMPL_LINK_NOARG(ExtrusionSurfaceWindow, SelectHdl)
873 if ( IsInPopupMode() )
874 EndPopupMode();
876 sal_Int32 nSurface = getSelectedEntryId();
877 if( nSurface >= 0 )
879 Sequence< PropertyValue > aArgs( 1 );
880 aArgs[0].Name = msExtrusionSurface.copy(5);
881 aArgs[0].Value <<= (sal_Int32)nSurface;
883 mrController.dispatchCommand( msExtrusionSurface, aArgs );
885 implSetSurface( nSurface, true );
888 return 0;
893 ExtrusionSurfaceControl::ExtrusionSurfaceControl(
894 const Reference< XComponentContext >& rxContext
896 : svt::PopupWindowController(
897 rxContext,
898 Reference< frame::XFrame >(),
899 OUString( ".uno:ExtrusionSurfaceFloater" )
906 VclPtr<vcl::Window> ExtrusionSurfaceControl::createPopupWindow( vcl::Window* pParent )
908 return VclPtr<ExtrusionSurfaceWindow>::Create( *this, m_xFrame, pParent );
911 // XInitialization
912 void SAL_CALL ExtrusionSurfaceControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
913 throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
915 svt::PopupWindowController::initialize( aArguments );
917 ToolBox* pToolBox = 0;
918 sal_uInt16 nId = 0;
919 if ( getToolboxId( nId, &pToolBox ) )
920 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
923 // XServiceInfo
926 OUString SAL_CALL ExtrusionSurfaceControl_getImplementationName()
928 return OUString( "com.sun.star.comp.svx.ExtrusionSurfaceController" );
933 Sequence< OUString > SAL_CALL ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException )
935 Sequence< OUString > aSNS( 1 );
936 aSNS.getArray()[0] = "com.sun.star.frame.ToolbarController";
937 return aSNS;
942 Reference< XInterface > SAL_CALL SAL_CALL ExtrusionSurfaceControl_createInstance(
943 const Reference< XMultiServiceFactory >& rSMgr
944 ) throw( RuntimeException )
946 return *new ExtrusionSurfaceControl( comphelper::getComponentContext(rSMgr) );
951 OUString SAL_CALL ExtrusionSurfaceControl::getImplementationName( ) throw (RuntimeException, std::exception)
953 return ExtrusionSurfaceControl_getImplementationName();
958 Sequence< OUString > SAL_CALL ExtrusionSurfaceControl::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
960 return ExtrusionSurfaceControl_getSupportedServiceNames();
965 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */