LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/dialogs - tp_3D_SceneIllumination.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 327 0.3 %
Date: 2012-12-27 Functions: 2 38 5.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "tp_3D_SceneIllumination.hxx"
      22             : #include "tp_3D_SceneIllumination.hrc"
      23             : #include "ResId.hxx"
      24             : #include "Strings.hrc"
      25             : #include "Bitmaps.hrc"
      26             : #include "CommonConverters.hxx"
      27             : #include "NoWarningThisInCTOR.hxx"
      28             : 
      29             : #include "svx/dialogs.hrc"
      30             : // header for define SVX_RES
      31             : #include <svx/dialmgr.hxx>
      32             : #include <rtl/math.hxx>
      33             : 
      34             : // header for class SvColorDialog
      35             : #include <svtools/colrdlg.hxx>
      36             : 
      37             : // header for define RET_OK
      38             : #include <vcl/msgbox.hxx>
      39             : 
      40             : #include <svx/svx3ditems.hxx>
      41             : #include <svx/svddef.hxx>
      42             : 
      43             : //.............................................................................
      44             : namespace chart
      45             : {
      46             : //.............................................................................
      47             : 
      48             : using namespace ::com::sun::star;
      49             : using namespace ::com::sun::star::chart2;
      50             : 
      51           0 : LightButton::LightButton( Window* pParent, const ResId& rResId, sal_Int32 nLightNumber )
      52             :             : ImageButton( pParent, rResId )
      53           0 :             , m_bLightOn(false)
      54             : {
      55           0 :     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF)   ) );
      56             : 
      57           0 :     String aTipHelpStr( SchResId(STR_TIP_LIGHTSOURCE_X) );
      58           0 :     rtl::OUString aTipHelp( aTipHelpStr  );
      59           0 :     const rtl::OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%LIGHTNUMBER" ));
      60           0 :     sal_Int32 nIndex = aTipHelp.indexOf( aReplacementStr );
      61           0 :     if( nIndex != -1 )
      62             :     {
      63             :         aTipHelp = aTipHelp.replaceAt(nIndex, aReplacementStr.getLength(),
      64           0 :             rtl::OUString::valueOf( nLightNumber ) );
      65             :     }
      66           0 :     this->SetQuickHelpText( String( aTipHelp ) );
      67           0 : }
      68             : 
      69           0 : LightButton::~LightButton()
      70             : {
      71           0 : }
      72             : 
      73           0 : void LightButton::switchLightOn(bool bOn)
      74             : {
      75           0 :     if( m_bLightOn==bOn )
      76           0 :         return;
      77           0 :     m_bLightOn = bOn;
      78           0 :     if(m_bLightOn)
      79             :     {
      80           0 :         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON) ) );
      81             :     }
      82             :     else
      83             :     {
      84           0 :         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF) ) );
      85             :     }
      86             : }
      87             : 
      88           0 : bool LightButton::isLightOn() const
      89             : {
      90           0 :     return m_bLightOn;
      91             : }
      92             : 
      93             : //-----------------------------------------------------------------------------
      94             : 
      95           0 : ColorButton::ColorButton( Window* pParent, const ResId& rResId )
      96           0 :             : ImageButton( pParent, rResId )
      97             : {
      98           0 :     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG) ) );
      99           0 :     this->SetQuickHelpText( String( SchResId(STR_TIP_CHOOSECOLOR) ) );
     100           0 : }
     101             : 
     102           0 : ColorButton::~ColorButton()
     103             : {
     104           0 : }
     105             : 
     106             : //-----------------------------------------------------------------------------
     107             : 
     108             : struct LightSource
     109             : {
     110             :     long nDiffuseColor;
     111             :     ::com::sun::star::drawing::Direction3D aDirection;
     112             :     bool bIsEnabled;
     113             : 
     114           0 :     LightSource() :
     115             :             nDiffuseColor( 0xcccccc ),
     116             :             aDirection( 1.0, 1.0, -1.0 ),
     117           0 :             bIsEnabled( false )
     118           0 :     {}
     119             : };
     120             : 
     121             : struct LightSourceInfo
     122             : {
     123             :     LightButton* pButton;
     124             :     LightSource  aLightSource;
     125             : 
     126             :     LightSourceInfo();
     127             :     void initButtonFromSource();
     128             : };
     129             : 
     130           0 : LightSourceInfo::LightSourceInfo()
     131             :     : pButton(0)
     132           0 :     , aLightSource()
     133             : {
     134           0 :     aLightSource.nDiffuseColor = 0xffffff; // white
     135           0 :     aLightSource.aDirection = drawing::Direction3D(1,1,1);
     136           0 :     aLightSource.bIsEnabled = sal_False;
     137           0 : }
     138             : 
     139           0 : void LightSourceInfo::initButtonFromSource()
     140             : {
     141           0 :     if(!pButton)
     142           0 :         return;
     143           0 :     pButton->SetModeImage( Image( SVX_RES(
     144             :         aLightSource.bIsEnabled ? RID_SVXIMAGE_LIGHT_ON : RID_SVXIMAGE_LIGHT_OFF
     145           0 :     ) ) );
     146             : }
     147             : 
     148             : //-----------------------------------------------------------------------------
     149             : 
     150             : namespace
     151             : {
     152           0 :     rtl::OUString lcl_makeColorName( Color rColor )
     153             :     {
     154           0 :         rtl::OUStringBuffer aStr(SVX_RESSTR(RID_SVXFLOAT3D_FIX_R));
     155           0 :         aStr.append((sal_Int32)rColor.GetRed());
     156           0 :         aStr.append(' ');
     157           0 :         aStr.append(SVX_RESSTR(RID_SVXFLOAT3D_FIX_G));
     158           0 :         aStr.append((sal_Int32)rColor.GetGreen());
     159           0 :         aStr.append(' ');
     160           0 :         aStr.append(SVX_RESSTR(RID_SVXFLOAT3D_FIX_B));
     161           0 :         aStr.append((sal_Int32)rColor.GetBlue());
     162           0 :         return aStr.makeStringAndClear();
     163             :     }
     164           0 :     void lcl_selectColor( ColorListBox& rListBox, const Color& rColor )
     165             :     {
     166           0 :         rListBox.SetNoSelection();
     167           0 :         rListBox.SelectEntry( rColor );
     168           0 :         if( rListBox.GetSelectEntryCount() == 0 )
     169             :         {
     170           0 :             sal_uInt16 nPos = rListBox.InsertEntry( rColor, lcl_makeColorName( rColor ) );
     171           0 :             rListBox.SelectEntryPos( nPos );
     172             :         }
     173           0 :     }
     174             : 
     175           0 :     ::chart::LightSource lcl_getLightSourceFromProperties(
     176             :         const uno::Reference< beans::XPropertySet > & xSceneProperties,
     177             :         sal_Int32 nIndex )
     178             :     {
     179           0 :         ::chart::LightSource aResult;
     180           0 :         if( 0 <= nIndex && nIndex < 8 )
     181             :         {
     182           0 :             ::rtl::OUString aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor"));
     183           0 :             ::rtl::OUString aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection"));
     184           0 :             ::rtl::OUString aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn"));
     185           0 :             ::rtl::OUString aIndex( ::rtl::OUString::valueOf( nIndex + 1 ));
     186             : 
     187             :             try
     188             :             {
     189           0 :                 xSceneProperties->getPropertyValue( aColorPropertyPrefix + aIndex ) >>= aResult.nDiffuseColor;
     190           0 :                 xSceneProperties->getPropertyValue( aDirectionPropertyPrefix + aIndex ) >>= aResult.aDirection;
     191           0 :                 xSceneProperties->getPropertyValue( aEnabledPropertyPrefix + aIndex ) >>= aResult.bIsEnabled;
     192             :             }
     193           0 :             catch( const uno::Exception & ex )
     194             :             {
     195             :                 (void)(ex); // no warning in non-debug builds
     196             :                 OSL_FAIL( ::rtl::OUStringToOString(
     197             :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
     198             :                                 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     199           0 :             }
     200             :         }
     201           0 :         return aResult;
     202             :     }
     203             : 
     204           0 :     void lcl_setLightSource(
     205             :         const uno::Reference< beans::XPropertySet > & xSceneProperties,
     206             :         const ::chart::LightSource & rLightSource,
     207             :         sal_Int32 nIndex )
     208             :     {
     209           0 :         if( 0 <= nIndex && nIndex < 8 )
     210             :         {
     211           0 :             ::rtl::OUString aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor"));
     212           0 :             ::rtl::OUString aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection"));
     213           0 :             ::rtl::OUString aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn"));
     214           0 :             ::rtl::OUString aIndex( ::rtl::OUString::valueOf( nIndex + 1 ));
     215             : 
     216             :             try
     217             :             {
     218           0 :                 xSceneProperties->setPropertyValue( aColorPropertyPrefix + aIndex,
     219           0 :                                                     uno::makeAny( rLightSource.nDiffuseColor ));
     220           0 :                 xSceneProperties->setPropertyValue( aDirectionPropertyPrefix + aIndex,
     221           0 :                                                     uno::makeAny( rLightSource.aDirection ));
     222           0 :                 xSceneProperties->setPropertyValue( aEnabledPropertyPrefix + aIndex,
     223           0 :                                                     uno::makeAny( rLightSource.bIsEnabled ));
     224             :             }
     225           0 :             catch( const uno::Exception & ex )
     226             :             {
     227             :                 (void)(ex); // no warning in non-debug builds
     228             :                 OSL_FAIL( ::rtl::OUStringToOString(
     229             :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
     230             :                                 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     231           0 :             }
     232             :         }
     233           0 :     }
     234             : 
     235           0 :     Color lcl_getAmbientColor(
     236             :         const uno::Reference< beans::XPropertySet > & xSceneProperties )
     237             :     {
     238           0 :         sal_Int32 nResult = 0x000000;
     239             :         try
     240             :         {
     241           0 :             xSceneProperties->getPropertyValue(
     242           0 :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))) >>= nResult;
     243             :         }
     244           0 :         catch( const uno::Exception & ex )
     245             :         {
     246             :             (void)(ex); // no warning in non-debug builds
     247             :             OSL_FAIL( ::rtl::OUStringToOString(
     248             :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
     249             :                             ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     250             :         }
     251           0 :         return Color( nResult );
     252             :     }
     253             : 
     254           0 :     void lcl_setAmbientColor(
     255             :         const uno::Reference< beans::XPropertySet > & xSceneProperties,
     256             :         const Color & rColor )
     257             :     {
     258             :         try
     259             :         {
     260           0 :             xSceneProperties->setPropertyValue(
     261             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")),
     262           0 :                 uno::makeAny( rColor.GetColor()));
     263             :         }
     264           0 :         catch( const uno::Exception & ex )
     265             :         {
     266             :             (void)(ex); // no warning in non-debug builds
     267             :             OSL_FAIL( ::rtl::OUStringToOString(
     268             :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
     269             :                             ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     270             :         }
     271           0 :     }
     272             : }
     273             : 
     274             : //-----------------------------------------------------------------------------
     275             : 
     276           0 : ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( Window* pWindow
     277             :                 , const uno::Reference< beans::XPropertySet > & xSceneProperties
     278             :                 , const uno::Reference< frame::XModel >& xChartModel
     279             :                 , const XColorListRef & pColorTable )
     280             :                 : TabPage           ( pWindow, SchResId( TP_3D_SCENEILLUMINATION ) )
     281             :                 , m_aFT_LightSource( this, SchResId( FT_LIGHTSOURCE ) )
     282             :                 , m_aBtn_Light1( this, SchResId( BTN_LIGHT_1 ), 1 )
     283             :                 , m_aBtn_Light2( this, SchResId( BTN_LIGHT_2 ), 2 )
     284             :                 , m_aBtn_Light3( this, SchResId( BTN_LIGHT_3 ), 3 )
     285             :                 , m_aBtn_Light4( this, SchResId( BTN_LIGHT_4 ), 4 )
     286             :                 , m_aBtn_Light5( this, SchResId( BTN_LIGHT_5 ), 5 )
     287             :                 , m_aBtn_Light6( this, SchResId( BTN_LIGHT_6 ), 6 )
     288             :                 , m_aBtn_Light7( this, SchResId( BTN_LIGHT_7 ), 7 )
     289             :                 , m_aBtn_Light8( this, SchResId( BTN_LIGHT_8 ), 8 )
     290             :                 , m_aLB_LightSource( this, SchResId( LB_LIGHTSOURCE ) )
     291             :                 , m_aBtn_LightSource_Color( this, SchResId( BTN_LIGHTSOURCE_COLOR ) )
     292             :                 , m_aFT_AmbientLight( this, SchResId( FT_AMBIENTLIGHT ) )
     293             :                 , m_aLB_AmbientLight( this, SchResId( LB_AMBIENTLIGHT ) )
     294             :                 , m_aBtn_AmbientLight_Color( this, SchResId( BTN_AMBIENT_COLOR ) )
     295             :                 , m_aCtl_Preview( this, SchResId( CTL_LIGHT_PREVIEW ) )
     296             :                 , m_pLightSourceInfoList(0)
     297             :                 , m_xSceneProperties( xSceneProperties )
     298             :                 , m_aTimerTriggeredControllerLock( xChartModel )
     299             :                 , m_bInCommitToModel( false )
     300             :                 , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage, fillControlsFromModel ) )
     301           0 :                 , m_xChartModel( xChartModel )
     302             : {
     303           0 :     FreeResource();
     304             : 
     305           0 :     if( pColorTable.is() )
     306             :     {
     307           0 :         m_aLB_AmbientLight.Fill( pColorTable );
     308           0 :         m_aLB_LightSource.Fill( pColorTable );
     309             :     }
     310           0 :     m_aLB_AmbientLight.SetDropDownLineCount(10);
     311           0 :     m_aLB_LightSource.SetDropDownLineCount(10);
     312             : 
     313           0 :     m_pLightSourceInfoList = new LightSourceInfo[8];
     314           0 :     m_pLightSourceInfoList[0].pButton = &m_aBtn_Light1;
     315           0 :     m_pLightSourceInfoList[1].pButton = &m_aBtn_Light2;
     316           0 :     m_pLightSourceInfoList[2].pButton = &m_aBtn_Light3;
     317           0 :     m_pLightSourceInfoList[3].pButton = &m_aBtn_Light4;
     318           0 :     m_pLightSourceInfoList[4].pButton = &m_aBtn_Light5;
     319           0 :     m_pLightSourceInfoList[5].pButton = &m_aBtn_Light6;
     320           0 :     m_pLightSourceInfoList[6].pButton = &m_aBtn_Light7;
     321           0 :     m_pLightSourceInfoList[7].pButton = &m_aBtn_Light8;
     322             : 
     323           0 :     fillControlsFromModel(0);
     324             : 
     325           0 :     m_aBtn_Light1.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     326           0 :     m_aBtn_Light2.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     327           0 :     m_aBtn_Light3.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     328           0 :     m_aBtn_Light4.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     329           0 :     m_aBtn_Light5.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     330           0 :     m_aBtn_Light6.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     331           0 :     m_aBtn_Light7.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     332           0 :     m_aBtn_Light8.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     333             : 
     334           0 :     m_aLB_AmbientLight.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
     335           0 :     m_aLB_LightSource.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
     336             : 
     337           0 :     m_aBtn_AmbientLight_Color.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
     338           0 :     m_aBtn_LightSource_Color.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
     339             : 
     340           0 :     m_aCtl_Preview.SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) );
     341           0 :     m_aCtl_Preview.SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) );
     342             : 
     343           0 :     ClickLightSourceButtonHdl(&m_aBtn_Light2);
     344             : 
     345           0 :     m_aModelChangeListener.startListening( uno::Reference< util::XModifyBroadcaster >(m_xSceneProperties, uno::UNO_QUERY) );
     346           0 :     m_aBtn_Light1.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     347           0 :     m_aBtn_Light2.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     348           0 :     m_aBtn_Light3.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     349           0 :     m_aBtn_Light4.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     350           0 :     m_aBtn_Light5.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     351           0 :     m_aBtn_Light6.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     352           0 :     m_aBtn_Light7.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     353           0 :     m_aBtn_Light8.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
     354           0 :     m_aCtl_Preview.SetAccessibleName(String(SchResId( STR_LIGHT_PREVIEW )));
     355           0 : }
     356             : 
     357           0 : ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
     358             : {
     359           0 :     delete[] m_pLightSourceInfoList;
     360           0 : }
     361             : 
     362           0 : void ThreeD_SceneIllumination_TabPage::commitPendingChanges()
     363             : {
     364           0 : }
     365             : 
     366           0 : IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel)
     367             : {
     368           0 :     if( m_bInCommitToModel )//don't read own changes
     369           0 :         return 0;
     370             : 
     371           0 :     sal_Int32 nL=0;
     372           0 :     for( nL=0; nL<8; nL++)
     373           0 :         m_pLightSourceInfoList[nL].aLightSource = lcl_getLightSourceFromProperties( m_xSceneProperties, nL );
     374           0 :     for( nL=0; nL<8; nL++)
     375           0 :         m_pLightSourceInfoList[nL].initButtonFromSource();
     376             : 
     377           0 :     lcl_selectColor( m_aLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties ));
     378             : 
     379           0 :     this->updatePreview();
     380             : 
     381           0 :     return 0;
     382             : }
     383             : 
     384           0 : void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber )
     385             : {
     386           0 :     ControllerLockGuard aGuard( m_xChartModel );
     387           0 :     m_bInCommitToModel = true;
     388           0 :     sal_Int32 nIndex( nLightNumber );
     389           0 :     lcl_setLightSource( m_xSceneProperties, m_pLightSourceInfoList[nIndex].aLightSource, nIndex );
     390           0 :     m_bInCommitToModel = false;
     391           0 : }
     392             : 
     393           0 : void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel()
     394             : {
     395           0 :     m_aTimerTriggeredControllerLock.startTimer();
     396           0 :     ControllerLockGuard aGuard( m_xChartModel );
     397           0 :     for( sal_Int32 nL=0; nL<8; nL++)
     398           0 :         applyLightSourceToModel( nL );
     399           0 :     m_aTimerTriggeredControllerLock.startTimer();
     400           0 : }
     401             : 
     402           0 : IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewChangeHdl)
     403             : {
     404           0 :     m_aTimerTriggeredControllerLock.startTimer();
     405             : 
     406             :     //update m_pLightSourceInfoList from preview
     407           0 :     const SfxItemSet a3DLightAttributes(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes());
     408           0 :     LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
     409             : 
     410           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().GetColor();
     411           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
     412           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
     413             : 
     414           0 :     pInfo = &m_pLightSourceInfoList[1];
     415           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().GetColor();
     416           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
     417           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
     418             : 
     419           0 :     pInfo = &m_pLightSourceInfoList[2];
     420           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().GetColor();
     421           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
     422           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
     423             : 
     424           0 :     pInfo = &m_pLightSourceInfoList[3];
     425           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().GetColor();
     426           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
     427           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
     428             : 
     429           0 :     pInfo = &m_pLightSourceInfoList[4];
     430           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().GetColor();
     431           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
     432           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
     433             : 
     434           0 :     pInfo = &m_pLightSourceInfoList[5];
     435           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().GetColor();
     436           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
     437           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
     438             : 
     439           0 :     pInfo = &m_pLightSourceInfoList[6];
     440           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().GetColor();
     441           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
     442           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
     443             : 
     444           0 :     pInfo = &m_pLightSourceInfoList[7];
     445           0 :     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().GetColor();
     446           0 :     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
     447           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
     448             : 
     449           0 :     applyLightSourcesToModel();
     450             : 
     451           0 :     return 0;
     452             : }
     453             : 
     454           0 : IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewSelectHdl)
     455             : {
     456           0 :     sal_uInt32 nLightNumber = m_aCtl_Preview.GetSvx3DLightControl().GetSelectedLight();
     457           0 :     if(nLightNumber<8)
     458             :     {
     459           0 :         LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton;
     460           0 :         if(!pButton->IsChecked())
     461           0 :             ClickLightSourceButtonHdl(pButton);
     462             : 
     463           0 :         applyLightSourcesToModel();
     464             :     }
     465           0 :     return 0;
     466             : }
     467             : 
     468           0 : IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton )
     469             : {
     470           0 :     bool bIsAmbientLight = (pButton==&m_aBtn_AmbientLight_Color);
     471           0 :     ColorLB* pListBox = ( bIsAmbientLight ? &m_aLB_AmbientLight : &m_aLB_LightSource);
     472             : 
     473           0 :     SvColorDialog aColorDlg( this );
     474           0 :     aColorDlg.SetColor( pListBox->GetSelectEntryColor() );
     475           0 :     if( aColorDlg.Execute() == RET_OK )
     476             :     {
     477           0 :         Color aColor( aColorDlg.GetColor());
     478           0 :         lcl_selectColor( *pListBox, aColor );
     479           0 :         if( bIsAmbientLight )
     480             :         {
     481           0 :             m_bInCommitToModel = true;
     482           0 :             lcl_setAmbientColor( m_xSceneProperties, aColor );
     483           0 :             m_bInCommitToModel = false;
     484             :         }
     485             :         else
     486             :         {
     487             :         //get active lightsource:
     488           0 :             LightSourceInfo* pInfo = 0;
     489           0 :             sal_Int32 nL=0;
     490           0 :             for( nL=0; nL<8; nL++)
     491             :             {
     492           0 :                 pInfo = &m_pLightSourceInfoList[nL];
     493           0 :                 if(pInfo->pButton->IsChecked())
     494           0 :                     break;
     495           0 :                 pInfo = 0;
     496             :             }
     497           0 :             if(pInfo)
     498           0 :                 applyLightSourceToModel( nL );
     499             :         }
     500           0 :         SelectColorHdl( pListBox );
     501             :     }
     502           0 :     return 0;
     503             : }
     504             : 
     505           0 : IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, ColorLB*, pListBox )
     506             : {
     507           0 :     if(pListBox==&m_aLB_AmbientLight)
     508             :     {
     509           0 :         m_bInCommitToModel = true;
     510           0 :         lcl_setAmbientColor( m_xSceneProperties, pListBox->GetSelectEntryColor().GetColor());
     511           0 :         m_bInCommitToModel = false;
     512             :     }
     513           0 :     else if(pListBox==&m_aLB_LightSource)
     514             :     {
     515             :         //get active lightsource:
     516           0 :         LightSourceInfo* pInfo = 0;
     517           0 :         sal_Int32 nL=0;
     518           0 :         for( nL=0; nL<8; nL++)
     519             :         {
     520           0 :             pInfo = &m_pLightSourceInfoList[nL];
     521           0 :             if(pInfo->pButton->IsChecked())
     522           0 :                 break;
     523           0 :             pInfo = 0;
     524             :         }
     525           0 :         if(pInfo)
     526             :         {
     527           0 :             pInfo->aLightSource.nDiffuseColor = pListBox->GetSelectEntryColor().GetColor();
     528           0 :             applyLightSourceToModel( nL );
     529             :         }
     530             :     }
     531           0 :     this->updatePreview();
     532           0 :     return 0;
     533             : }
     534             : 
     535           0 : IMPL_LINK( ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, LightButton*, pButton )
     536             : {
     537           0 :     if( !pButton )
     538           0 :         return 0;
     539             : 
     540           0 :     LightSourceInfo* pInfo = 0;
     541           0 :     sal_Int32 nL=0;
     542           0 :     for( nL=0; nL<8; nL++)
     543             :     {
     544           0 :         if( m_pLightSourceInfoList[nL].pButton == pButton )
     545             :         {
     546           0 :             pInfo = &m_pLightSourceInfoList[nL];
     547           0 :             break;
     548             :         }
     549             :     }
     550             : 
     551             :     //update light button
     552           0 :     bool bIsChecked = pButton->IsChecked();
     553           0 :     if(bIsChecked)
     554             :     {
     555           0 :         pButton->switchLightOn(!pButton->isLightOn());
     556           0 :         if(pInfo)
     557             :         {
     558           0 :             pInfo->aLightSource.bIsEnabled=pButton->isLightOn();
     559           0 :             applyLightSourceToModel( nL );
     560             :         }
     561             :     }
     562             :     else
     563             :     {
     564           0 :         ControllerLockGuard aGuard( m_xChartModel );
     565           0 :         for( nL=0; nL<8; nL++)
     566             :         {
     567           0 :             LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton;
     568           0 :             pLightButton->Check( pLightButton == pButton );
     569           0 :         }
     570             :     }
     571             : 
     572             :     //update color list box
     573           0 :     if(pInfo)
     574             :     {
     575           0 :         lcl_selectColor( m_aLB_LightSource, pInfo->aLightSource.nDiffuseColor );
     576             :     }
     577           0 :     this->updatePreview();
     578           0 :     return 0;
     579             : }
     580             : 
     581           0 : void ThreeD_SceneIllumination_TabPage::updatePreview()
     582             : {
     583           0 :     SfxItemSet aItemSet(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes());
     584           0 :     LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
     585             : 
     586             :     // AmbientColor
     587           0 :     aItemSet.Put(Svx3DAmbientcolorItem(m_aLB_AmbientLight.GetSelectEntryColor()));
     588             : 
     589           0 :     aItemSet.Put(Svx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor));
     590           0 :     aItemSet.Put(Svx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled));
     591           0 :     aItemSet.Put(Svx3DLightDirection1Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     592             : 
     593           0 :     pInfo = &m_pLightSourceInfoList[1];
     594           0 :     aItemSet.Put(Svx3DLightcolor2Item(pInfo->aLightSource.nDiffuseColor));
     595           0 :     aItemSet.Put(Svx3DLightOnOff2Item(pInfo->aLightSource.bIsEnabled));
     596           0 :     aItemSet.Put(Svx3DLightDirection2Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     597             : 
     598           0 :     pInfo = &m_pLightSourceInfoList[2];
     599           0 :     aItemSet.Put(Svx3DLightcolor3Item(pInfo->aLightSource.nDiffuseColor));
     600           0 :     aItemSet.Put(Svx3DLightOnOff3Item(pInfo->aLightSource.bIsEnabled));
     601           0 :     aItemSet.Put(Svx3DLightDirection3Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     602             : 
     603           0 :     pInfo = &m_pLightSourceInfoList[3];
     604           0 :     aItemSet.Put(Svx3DLightcolor4Item(pInfo->aLightSource.nDiffuseColor));
     605           0 :     aItemSet.Put(Svx3DLightOnOff4Item(pInfo->aLightSource.bIsEnabled));
     606           0 :     aItemSet.Put(Svx3DLightDirection4Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     607             : 
     608           0 :     pInfo = &m_pLightSourceInfoList[4];
     609           0 :     aItemSet.Put(Svx3DLightcolor5Item(pInfo->aLightSource.nDiffuseColor));
     610           0 :     aItemSet.Put(Svx3DLightOnOff5Item(pInfo->aLightSource.bIsEnabled));
     611           0 :     aItemSet.Put(Svx3DLightDirection5Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     612             : 
     613           0 :     pInfo = &m_pLightSourceInfoList[5];
     614           0 :     aItemSet.Put(Svx3DLightcolor6Item(pInfo->aLightSource.nDiffuseColor));
     615           0 :     aItemSet.Put(Svx3DLightOnOff6Item(pInfo->aLightSource.bIsEnabled));
     616           0 :     aItemSet.Put(Svx3DLightDirection6Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     617             : 
     618           0 :     pInfo = &m_pLightSourceInfoList[6];
     619           0 :     aItemSet.Put(Svx3DLightcolor7Item(pInfo->aLightSource.nDiffuseColor));
     620           0 :     aItemSet.Put(Svx3DLightOnOff7Item(pInfo->aLightSource.bIsEnabled));
     621           0 :     aItemSet.Put(Svx3DLightDirection7Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     622             : 
     623           0 :     pInfo = &m_pLightSourceInfoList[7];
     624           0 :     aItemSet.Put(Svx3DLightcolor8Item(pInfo->aLightSource.nDiffuseColor));
     625           0 :     aItemSet.Put(Svx3DLightOnOff8Item(pInfo->aLightSource.bIsEnabled));
     626           0 :     aItemSet.Put(Svx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     627             : 
     628             :     // set lights and ambient light
     629           0 :     m_aCtl_Preview.GetSvx3DLightControl().Set3DAttributes(aItemSet);
     630             : 
     631             :     // select light
     632           0 :     for(sal_uInt32 a(0); a < 8; a++)
     633             :     {
     634           0 :         if(m_pLightSourceInfoList[a].pButton->IsChecked())
     635             :         {
     636           0 :             m_aCtl_Preview.GetSvx3DLightControl().SelectLight(a);
     637           0 :             m_aCtl_Preview.CheckSelection();
     638           0 :             break;
     639             :         }
     640           0 :     }
     641           0 : }
     642             : 
     643             : //.............................................................................
     644           3 : } //namespace chart
     645             : //.............................................................................
     646             : 
     647             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10