LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - tp_3D_SceneIllumination.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 314 0.3 %
Date: 2014-11-03 Functions: 2 35 5.7 %
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             : #include "tp_3D_SceneIllumination.hxx"
      21             : #include "ResId.hxx"
      22             : #include "Bitmaps.hrc"
      23             : #include "CommonConverters.hxx"
      24             : 
      25             : #include "svx/dialogs.hrc"
      26             : #include <svx/dialmgr.hxx>
      27             : #include <rtl/math.hxx>
      28             : #include <svtools/colrdlg.hxx>
      29             : #include <vcl/msgbox.hxx>
      30             : #include <svx/svx3ditems.hxx>
      31             : #include <svx/svddef.hxx>
      32             : 
      33             : namespace chart
      34             : {
      35             : 
      36             : using namespace ::com::sun::star;
      37             : using namespace ::com::sun::star::chart2;
      38             : 
      39           0 : LightButton::LightButton( vcl::Window* pParent)
      40             :             : ImageButton( pParent)
      41           0 :             , m_bLightOn(false)
      42             : {
      43           0 :     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF)   ) );
      44           0 : }
      45             : 
      46           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeLightButton(vcl::Window *pParent, VclBuilder::stringmap &)
      47             : {
      48           0 :     return new LightButton(pParent);
      49             : }
      50             : 
      51           0 : LightButton::~LightButton()
      52             : {
      53           0 : }
      54             : 
      55           0 : void LightButton::switchLightOn(bool bOn)
      56             : {
      57           0 :     if( m_bLightOn==bOn )
      58           0 :         return;
      59           0 :     m_bLightOn = bOn;
      60           0 :     if(m_bLightOn)
      61             :     {
      62           0 :         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON) ) );
      63             :     }
      64             :     else
      65             :     {
      66           0 :         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF) ) );
      67             :     }
      68             : }
      69             : 
      70             : struct LightSource
      71             : {
      72             :     long nDiffuseColor;
      73             :     ::com::sun::star::drawing::Direction3D aDirection;
      74             :     bool bIsEnabled;
      75             : 
      76           0 :     LightSource() :
      77             :             nDiffuseColor( 0xcccccc ),
      78             :             aDirection( 1.0, 1.0, -1.0 ),
      79           0 :             bIsEnabled( false )
      80           0 :     {}
      81             : };
      82             : 
      83             : struct LightSourceInfo
      84             : {
      85             :     LightButton* pButton;
      86             :     LightSource  aLightSource;
      87             : 
      88             :     LightSourceInfo();
      89             :     void initButtonFromSource();
      90             : };
      91             : 
      92           0 : LightSourceInfo::LightSourceInfo()
      93             :     : pButton(0)
      94           0 :     , aLightSource()
      95             : {
      96           0 :     aLightSource.nDiffuseColor = 0xffffff; // white
      97           0 :     aLightSource.aDirection = drawing::Direction3D(1,1,1);
      98           0 :     aLightSource.bIsEnabled = false;
      99           0 : }
     100             : 
     101           0 : void LightSourceInfo::initButtonFromSource()
     102             : {
     103           0 :     if(!pButton)
     104           0 :         return;
     105           0 :     pButton->SetModeImage( Image( SVX_RES(
     106             :         aLightSource.bIsEnabled ? RID_SVXIMAGE_LIGHT_ON : RID_SVXIMAGE_LIGHT_OFF
     107           0 :     ) ) );
     108             : }
     109             : 
     110             : namespace
     111             : {
     112           0 :     OUString lcl_makeColorName( Color rColor )
     113             :     {
     114           0 :         OUString aStr = SVX_RESSTR(RID_SVXFLOAT3D_FIX_R) +
     115           0 :                         OUString::number(rColor.GetRed()) +
     116           0 :                         " " +
     117           0 :                         SVX_RESSTR(RID_SVXFLOAT3D_FIX_G) +
     118           0 :                         OUString::number(rColor.GetGreen()) +
     119           0 :                         " " +
     120           0 :                         SVX_RESSTR(RID_SVXFLOAT3D_FIX_B) +
     121           0 :                         OUString::number(rColor.GetBlue());
     122           0 :         return aStr;
     123             :     }
     124           0 :     void lcl_selectColor( ColorListBox& rListBox, const Color& rColor )
     125             :     {
     126           0 :         rListBox.SetNoSelection();
     127           0 :         rListBox.SelectEntry( rColor );
     128           0 :         if( rListBox.GetSelectEntryCount() == 0 )
     129             :         {
     130           0 :             sal_uInt16 nPos = rListBox.InsertEntry( rColor, lcl_makeColorName( rColor ) );
     131           0 :             rListBox.SelectEntryPos( nPos );
     132             :         }
     133           0 :     }
     134             : 
     135           0 :     ::chart::LightSource lcl_getLightSourceFromProperties(
     136             :         const uno::Reference< beans::XPropertySet > & xSceneProperties,
     137             :         sal_Int32 nIndex )
     138             :     {
     139           0 :         ::chart::LightSource aResult;
     140           0 :         if( 0 <= nIndex && nIndex < 8 )
     141             :         {
     142           0 :             OUString aColorPropertyPrefix("D3DSceneLightColor");
     143           0 :             OUString aDirectionPropertyPrefix("D3DSceneLightDirection");
     144           0 :             OUString aEnabledPropertyPrefix("D3DSceneLightOn");
     145           0 :             OUString aIndex( OUString::number( nIndex + 1 ));
     146             : 
     147             :             try
     148             :             {
     149           0 :                 xSceneProperties->getPropertyValue( aColorPropertyPrefix + aIndex ) >>= aResult.nDiffuseColor;
     150           0 :                 xSceneProperties->getPropertyValue( aDirectionPropertyPrefix + aIndex ) >>= aResult.aDirection;
     151           0 :                 xSceneProperties->getPropertyValue( aEnabledPropertyPrefix + aIndex ) >>= aResult.bIsEnabled;
     152             :             }
     153           0 :             catch( const uno::Exception & ex )
     154             :             {
     155             :                 (void)(ex); // no warning in non-debug builds
     156             :                 OSL_FAIL( OUStringToOString(OUString( "Property Exception caught. Message: " ) +
     157             :                                             ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     158           0 :             }
     159             :         }
     160           0 :         return aResult;
     161             :     }
     162             : 
     163           0 :     void lcl_setLightSource(
     164             :         const uno::Reference< beans::XPropertySet > & xSceneProperties,
     165             :         const ::chart::LightSource & rLightSource,
     166             :         sal_Int32 nIndex )
     167             :     {
     168           0 :         if( 0 <= nIndex && nIndex < 8 )
     169             :         {
     170           0 :             OUString aColorPropertyPrefix("D3DSceneLightColor");
     171           0 :             OUString aDirectionPropertyPrefix("D3DSceneLightDirection");
     172           0 :             OUString aEnabledPropertyPrefix("D3DSceneLightOn");
     173           0 :             OUString aIndex( OUString::number( nIndex + 1 ));
     174             : 
     175             :             try
     176             :             {
     177           0 :                 xSceneProperties->setPropertyValue( aColorPropertyPrefix + aIndex,
     178           0 :                                                     uno::makeAny( rLightSource.nDiffuseColor ));
     179           0 :                 xSceneProperties->setPropertyValue( aDirectionPropertyPrefix + aIndex,
     180           0 :                                                     uno::makeAny( rLightSource.aDirection ));
     181           0 :                 xSceneProperties->setPropertyValue( aEnabledPropertyPrefix + aIndex,
     182           0 :                                                     uno::makeAny( rLightSource.bIsEnabled ));
     183             :             }
     184           0 :             catch( const uno::Exception & ex )
     185             :             {
     186             :                 (void)(ex); // no warning in non-debug builds
     187             :                 OSL_FAIL( OUStringToOString(OUString("Property Exception caught. Message: " ) +
     188             :                                             ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     189           0 :             }
     190             :         }
     191           0 :     }
     192             : 
     193           0 :     Color lcl_getAmbientColor(
     194             :         const uno::Reference< beans::XPropertySet > & xSceneProperties )
     195             :     {
     196           0 :         sal_Int32 nResult = 0x000000;
     197             :         try
     198             :         {
     199           0 :             xSceneProperties->getPropertyValue("D3DSceneAmbientColor") >>= nResult;
     200             :         }
     201           0 :         catch( const uno::Exception & ex )
     202             :         {
     203             :             (void)(ex); // no warning in non-debug builds
     204             :             OSL_FAIL( OUStringToOString(OUString("Property Exception caught. Message: " ) +
     205             :                                         ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     206             :         }
     207           0 :         return Color( nResult );
     208             :     }
     209             : 
     210           0 :     void lcl_setAmbientColor(
     211             :         const uno::Reference< beans::XPropertySet > & xSceneProperties,
     212             :         const Color & rColor )
     213             :     {
     214             :         try
     215             :         {
     216           0 :             xSceneProperties->setPropertyValue("D3DSceneAmbientColor",
     217           0 :                                                uno::makeAny( rColor.GetColor()));
     218             :         }
     219           0 :         catch( const uno::Exception & ex )
     220             :         {
     221             :             (void)(ex); // no warning in non-debug builds
     222             :             OSL_FAIL( OUStringToOString(OUString( "Property Exception caught. Message: " ) +
     223             :                                         ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     224             :         }
     225           0 :     }
     226             : }
     227             : 
     228           0 : ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( vcl::Window* pWindow
     229             :                 , const uno::Reference< beans::XPropertySet > & xSceneProperties
     230             :                 , const uno::Reference< frame::XModel >& xChartModel
     231             :                 , const XColorListRef & pColorTable )
     232             :                 : TabPage ( pWindow
     233             :                           ,"tp_3D_SceneIllumination"
     234             :                           ,"modules/schart/ui/tp_3D_SceneIllumination.ui")
     235             :                 , m_pLightSourceInfoList(0)
     236             :                 , m_xSceneProperties( xSceneProperties )
     237             :                 , m_aTimerTriggeredControllerLock( xChartModel )
     238             :                 , m_bInCommitToModel( false )
     239             :                 , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage, fillControlsFromModel ) )
     240           0 :                 , m_xChartModel( xChartModel )
     241             : {
     242           0 :     get(m_pBtn_Light1, "BTN_LIGHT_1");
     243           0 :     get(m_pBtn_Light2, "BTN_LIGHT_2");
     244           0 :     get(m_pBtn_Light3, "BTN_LIGHT_3");
     245           0 :     get(m_pBtn_Light4, "BTN_LIGHT_4");
     246           0 :     get(m_pBtn_Light5, "BTN_LIGHT_5");
     247           0 :     get(m_pBtn_Light6, "BTN_LIGHT_6");
     248           0 :     get(m_pBtn_Light7, "BTN_LIGHT_7");
     249           0 :     get(m_pBtn_Light8, "BTN_LIGHT_8");
     250             : 
     251           0 :     get(m_pLB_LightSource, "LB_LIGHTSOURCE");
     252           0 :     get(m_pLB_AmbientLight, "LB_AMBIENTLIGHT");
     253           0 :     get(m_pBtn_LightSource_Color, "BTN_LIGHTSOURCE_COLOR");
     254           0 :     get(m_pBtn_AmbientLight_Color, "BTN_AMBIENT_COLOR");
     255             : 
     256           0 :     get(m_pCtl_Preview, "CTL_LIGHT_PREVIEW");
     257             : 
     258           0 :     if( pColorTable.is() )
     259             :     {
     260           0 :         m_pLB_AmbientLight->Fill( pColorTable );
     261           0 :         m_pLB_LightSource->Fill( pColorTable );
     262             :     }
     263           0 :     m_pLB_AmbientLight->SetDropDownLineCount(10);
     264           0 :     m_pLB_LightSource->SetDropDownLineCount(10);
     265             : 
     266           0 :     m_pLightSourceInfoList = new LightSourceInfo[8];
     267           0 :     m_pLightSourceInfoList[0].pButton = m_pBtn_Light1;
     268           0 :     m_pLightSourceInfoList[1].pButton = m_pBtn_Light2;
     269           0 :     m_pLightSourceInfoList[2].pButton = m_pBtn_Light3;
     270           0 :     m_pLightSourceInfoList[3].pButton = m_pBtn_Light4;
     271           0 :     m_pLightSourceInfoList[4].pButton = m_pBtn_Light5;
     272           0 :     m_pLightSourceInfoList[5].pButton = m_pBtn_Light6;
     273           0 :     m_pLightSourceInfoList[6].pButton = m_pBtn_Light7;
     274           0 :     m_pLightSourceInfoList[7].pButton = m_pBtn_Light8;
     275             : 
     276           0 :     fillControlsFromModel(0);
     277             : 
     278           0 :     m_pBtn_Light1->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     279           0 :     m_pBtn_Light2->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     280           0 :     m_pBtn_Light3->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     281           0 :     m_pBtn_Light4->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     282           0 :     m_pBtn_Light5->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     283           0 :     m_pBtn_Light6->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     284           0 :     m_pBtn_Light7->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     285           0 :     m_pBtn_Light8->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
     286             : 
     287           0 :     m_pLB_AmbientLight->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
     288           0 :     m_pLB_LightSource->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
     289             : 
     290           0 :     m_pBtn_AmbientLight_Color->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
     291           0 :     m_pBtn_LightSource_Color->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
     292             : 
     293           0 :     m_pCtl_Preview->SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) );
     294           0 :     m_pCtl_Preview->SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) );
     295             : 
     296           0 :     ClickLightSourceButtonHdl(m_pBtn_Light2);
     297           0 : }
     298             : 
     299           0 : ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
     300             : {
     301           0 :     delete[] m_pLightSourceInfoList;
     302           0 : }
     303             : 
     304           0 : void ThreeD_SceneIllumination_TabPage::commitPendingChanges()
     305             : {
     306           0 : }
     307             : 
     308           0 : IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel)
     309             : {
     310           0 :     if( m_bInCommitToModel )//don't read own changes
     311           0 :         return 0;
     312             : 
     313           0 :     sal_Int32 nL=0;
     314           0 :     for( nL=0; nL<8; nL++)
     315           0 :         m_pLightSourceInfoList[nL].aLightSource = lcl_getLightSourceFromProperties( m_xSceneProperties, nL );
     316           0 :     for( nL=0; nL<8; nL++)
     317           0 :         m_pLightSourceInfoList[nL].initButtonFromSource();
     318             : 
     319           0 :     lcl_selectColor( *m_pLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties ));
     320             : 
     321           0 :     this->updatePreview();
     322             : 
     323           0 :     return 0;
     324             : }
     325             : 
     326           0 : void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber )
     327             : {
     328           0 :     ControllerLockGuardUNO aGuard( m_xChartModel );
     329           0 :     m_bInCommitToModel = true;
     330           0 :     sal_Int32 nIndex( nLightNumber );
     331           0 :     lcl_setLightSource( m_xSceneProperties, m_pLightSourceInfoList[nIndex].aLightSource, nIndex );
     332           0 :     m_bInCommitToModel = false;
     333           0 : }
     334             : 
     335           0 : void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel()
     336             : {
     337           0 :     m_aTimerTriggeredControllerLock.startTimer();
     338           0 :     ControllerLockGuardUNO aGuard( m_xChartModel );
     339           0 :     for( sal_Int32 nL=0; nL<8; nL++)
     340           0 :         applyLightSourceToModel( nL );
     341           0 :     m_aTimerTriggeredControllerLock.startTimer();
     342           0 : }
     343             : 
     344           0 : IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewChangeHdl)
     345             : {
     346           0 :     m_aTimerTriggeredControllerLock.startTimer();
     347             : 
     348             :     //update m_pLightSourceInfoList from preview
     349           0 :     const SfxItemSet a3DLightAttributes(m_pCtl_Preview->GetSvx3DLightControl().Get3DAttributes());
     350           0 :     LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
     351             : 
     352           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().GetColor();
     353           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
     354           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
     355             : 
     356           0 :     pInfo = &m_pLightSourceInfoList[1];
     357           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().GetColor();
     358           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
     359           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
     360             : 
     361           0 :     pInfo = &m_pLightSourceInfoList[2];
     362           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().GetColor();
     363           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
     364           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
     365             : 
     366           0 :     pInfo = &m_pLightSourceInfoList[3];
     367           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().GetColor();
     368           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
     369           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
     370             : 
     371           0 :     pInfo = &m_pLightSourceInfoList[4];
     372           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().GetColor();
     373           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
     374           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
     375             : 
     376           0 :     pInfo = &m_pLightSourceInfoList[5];
     377           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().GetColor();
     378           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
     379           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
     380             : 
     381           0 :     pInfo = &m_pLightSourceInfoList[6];
     382           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().GetColor();
     383           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
     384           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
     385             : 
     386           0 :     pInfo = &m_pLightSourceInfoList[7];
     387           0 :     pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().GetColor();
     388           0 :     pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
     389           0 :     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
     390             : 
     391           0 :     applyLightSourcesToModel();
     392             : 
     393           0 :     return 0;
     394             : }
     395             : 
     396           0 : IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewSelectHdl)
     397             : {
     398           0 :     sal_uInt32 nLightNumber = m_pCtl_Preview->GetSvx3DLightControl().GetSelectedLight();
     399           0 :     if(nLightNumber<8)
     400             :     {
     401           0 :         LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton;
     402           0 :         if(!pButton->IsChecked())
     403           0 :             ClickLightSourceButtonHdl(pButton);
     404             : 
     405           0 :         applyLightSourcesToModel();
     406             :     }
     407           0 :     return 0;
     408             : }
     409             : 
     410           0 : IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton )
     411             : {
     412           0 :     bool bIsAmbientLight = (pButton==m_pBtn_AmbientLight_Color);
     413           0 :     ColorLB* pListBox = ( bIsAmbientLight ? m_pLB_AmbientLight : m_pLB_LightSource);
     414             : 
     415           0 :     SvColorDialog aColorDlg( this );
     416           0 :     aColorDlg.SetColor( pListBox->GetSelectEntryColor() );
     417           0 :     if( aColorDlg.Execute() == RET_OK )
     418             :     {
     419           0 :         Color aColor( aColorDlg.GetColor());
     420           0 :         lcl_selectColor( *pListBox, aColor );
     421           0 :         if( bIsAmbientLight )
     422             :         {
     423           0 :             m_bInCommitToModel = true;
     424           0 :             lcl_setAmbientColor( m_xSceneProperties, aColor );
     425           0 :             m_bInCommitToModel = false;
     426             :         }
     427             :         else
     428             :         {
     429             :         //get active lightsource:
     430           0 :             LightSourceInfo* pInfo = 0;
     431           0 :             sal_Int32 nL=0;
     432           0 :             for( nL=0; nL<8; nL++)
     433             :             {
     434           0 :                 pInfo = &m_pLightSourceInfoList[nL];
     435           0 :                 if(pInfo->pButton->IsChecked())
     436           0 :                     break;
     437           0 :                 pInfo = 0;
     438             :             }
     439           0 :             if(pInfo)
     440           0 :                 applyLightSourceToModel( nL );
     441             :         }
     442           0 :         SelectColorHdl( pListBox );
     443             :     }
     444           0 :     return 0;
     445             : }
     446             : 
     447           0 : IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, ColorLB*, pListBox )
     448             : {
     449           0 :     if(pListBox==m_pLB_AmbientLight)
     450             :     {
     451           0 :         m_bInCommitToModel = true;
     452           0 :         lcl_setAmbientColor( m_xSceneProperties, pListBox->GetSelectEntryColor().GetColor());
     453           0 :         m_bInCommitToModel = false;
     454             :     }
     455           0 :     else if(pListBox==m_pLB_LightSource)
     456             :     {
     457             :         //get active lightsource:
     458           0 :         LightSourceInfo* pInfo = 0;
     459           0 :         sal_Int32 nL=0;
     460           0 :         for( nL=0; nL<8; nL++)
     461             :         {
     462           0 :             pInfo = &m_pLightSourceInfoList[nL];
     463           0 :             if(pInfo->pButton->IsChecked())
     464           0 :                 break;
     465           0 :             pInfo = 0;
     466             :         }
     467           0 :         if(pInfo)
     468             :         {
     469           0 :             pInfo->aLightSource.nDiffuseColor = pListBox->GetSelectEntryColor().GetColor();
     470           0 :             applyLightSourceToModel( nL );
     471             :         }
     472             :     }
     473           0 :     this->updatePreview();
     474           0 :     return 0;
     475             : }
     476             : 
     477           0 : IMPL_LINK( ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, LightButton*, pButton )
     478             : {
     479           0 :     if( !pButton )
     480           0 :         return 0;
     481             : 
     482           0 :     LightSourceInfo* pInfo = 0;
     483           0 :     sal_Int32 nL=0;
     484           0 :     for( nL=0; nL<8; nL++)
     485             :     {
     486           0 :         if( m_pLightSourceInfoList[nL].pButton == pButton )
     487             :         {
     488           0 :             pInfo = &m_pLightSourceInfoList[nL];
     489           0 :             break;
     490             :         }
     491             :     }
     492             : 
     493             :     //update light button
     494           0 :     bool bIsChecked = pButton->IsChecked();
     495           0 :     if(bIsChecked)
     496             :     {
     497           0 :         pButton->switchLightOn(!pButton->isLightOn());
     498           0 :         if(pInfo)
     499             :         {
     500           0 :             pInfo->aLightSource.bIsEnabled=pButton->isLightOn();
     501           0 :             applyLightSourceToModel( nL );
     502             :         }
     503             :     }
     504             :     else
     505             :     {
     506           0 :         ControllerLockGuardUNO aGuard( m_xChartModel );
     507           0 :         for( nL=0; nL<8; nL++)
     508             :         {
     509           0 :             LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton;
     510           0 :             pLightButton->Check( pLightButton == pButton );
     511           0 :         }
     512             :     }
     513             : 
     514             :     //update color list box
     515           0 :     if(pInfo)
     516             :     {
     517           0 :         lcl_selectColor( *m_pLB_LightSource, pInfo->aLightSource.nDiffuseColor );
     518             :     }
     519           0 :     this->updatePreview();
     520           0 :     return 0;
     521             : }
     522             : 
     523           0 : void ThreeD_SceneIllumination_TabPage::updatePreview()
     524             : {
     525           0 :     SfxItemSet aItemSet(m_pCtl_Preview->GetSvx3DLightControl().Get3DAttributes());
     526           0 :     LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
     527             : 
     528             :     // AmbientColor
     529           0 :     aItemSet.Put(makeSvx3DAmbientcolorItem(m_pLB_AmbientLight->GetSelectEntryColor()));
     530             : 
     531           0 :     aItemSet.Put(makeSvx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor));
     532           0 :     aItemSet.Put(makeSvx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled));
     533           0 :     aItemSet.Put(makeSvx3DLightDirection1Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     534             : 
     535           0 :     pInfo = &m_pLightSourceInfoList[1];
     536           0 :     aItemSet.Put(makeSvx3DLightcolor2Item(pInfo->aLightSource.nDiffuseColor));
     537           0 :     aItemSet.Put(makeSvx3DLightOnOff2Item(pInfo->aLightSource.bIsEnabled));
     538           0 :     aItemSet.Put(makeSvx3DLightDirection2Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     539             : 
     540           0 :     pInfo = &m_pLightSourceInfoList[2];
     541           0 :     aItemSet.Put(makeSvx3DLightcolor3Item(pInfo->aLightSource.nDiffuseColor));
     542           0 :     aItemSet.Put(makeSvx3DLightOnOff3Item(pInfo->aLightSource.bIsEnabled));
     543           0 :     aItemSet.Put(makeSvx3DLightDirection3Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     544             : 
     545           0 :     pInfo = &m_pLightSourceInfoList[3];
     546           0 :     aItemSet.Put(makeSvx3DLightcolor4Item(pInfo->aLightSource.nDiffuseColor));
     547           0 :     aItemSet.Put(makeSvx3DLightOnOff4Item(pInfo->aLightSource.bIsEnabled));
     548           0 :     aItemSet.Put(makeSvx3DLightDirection4Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     549             : 
     550           0 :     pInfo = &m_pLightSourceInfoList[4];
     551           0 :     aItemSet.Put(makeSvx3DLightcolor5Item(pInfo->aLightSource.nDiffuseColor));
     552           0 :     aItemSet.Put(makeSvx3DLightOnOff5Item(pInfo->aLightSource.bIsEnabled));
     553           0 :     aItemSet.Put(makeSvx3DLightDirection5Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     554             : 
     555           0 :     pInfo = &m_pLightSourceInfoList[5];
     556           0 :     aItemSet.Put(makeSvx3DLightcolor6Item(pInfo->aLightSource.nDiffuseColor));
     557           0 :     aItemSet.Put(makeSvx3DLightOnOff6Item(pInfo->aLightSource.bIsEnabled));
     558           0 :     aItemSet.Put(makeSvx3DLightDirection6Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     559             : 
     560           0 :     pInfo = &m_pLightSourceInfoList[6];
     561           0 :     aItemSet.Put(makeSvx3DLightcolor7Item(pInfo->aLightSource.nDiffuseColor));
     562           0 :     aItemSet.Put(makeSvx3DLightOnOff7Item(pInfo->aLightSource.bIsEnabled));
     563           0 :     aItemSet.Put(makeSvx3DLightDirection7Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     564             : 
     565           0 :     pInfo = &m_pLightSourceInfoList[7];
     566           0 :     aItemSet.Put(makeSvx3DLightcolor8Item(pInfo->aLightSource.nDiffuseColor));
     567           0 :     aItemSet.Put(makeSvx3DLightOnOff8Item(pInfo->aLightSource.bIsEnabled));
     568           0 :     aItemSet.Put(makeSvx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
     569             : 
     570             :     // set lights and ambient light
     571           0 :     m_pCtl_Preview->GetSvx3DLightControl().Set3DAttributes(aItemSet);
     572             : 
     573             :     // select light
     574           0 :     for(sal_uInt32 a(0); a < 8; a++)
     575             :     {
     576           0 :         if(m_pLightSourceInfoList[a].pButton->IsChecked())
     577             :         {
     578           0 :             m_pCtl_Preview->GetSvx3DLightControl().SelectLight(a);
     579           0 :             m_pCtl_Preview->CheckSelection();
     580           0 :             break;
     581             :         }
     582           0 :     }
     583           0 : }
     584             : 
     585         102 : } //namespace chart
     586             : 
     587             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10