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