LCOV - code coverage report
Current view: top level - svx/source/sidebar/graphic - GraphicPropertyPanel.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 196 0.5 %
Date: 2014-11-03 Functions: 2 26 7.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             : #include <sfx2/sidebar/ResourceDefinitions.hrc>
      20             : #include <sfx2/sidebar/Theme.hxx>
      21             : #include <sfx2/sidebar/ControlFactory.hxx>
      22             : #include <GraphicPropertyPanel.hxx>
      23             : #include <svx/dialogs.hrc>
      24             : #include <svx/dialmgr.hxx>
      25             : #include <vcl/field.hxx>
      26             : #include <vcl/lstbox.hxx>
      27             : #include <svl/intitem.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/dispatch.hxx>
      30             : 
      31             : using namespace css;
      32             : using namespace css::uno;
      33             : using ::sfx2::sidebar::Theme;
      34             : 
      35             : 
      36             : // namespace open
      37             : 
      38             : namespace svx { namespace sidebar {
      39             : 
      40             : 
      41             : 
      42           0 : GraphicPropertyPanel::GraphicPropertyPanel(
      43             :     vcl::Window* pParent,
      44             :     const css::uno::Reference<css::frame::XFrame>& rxFrame,
      45             :     SfxBindings* pBindings)
      46             : :   PanelLayout(pParent, "GraphicPropertyPanel", "svx/ui/sidebargraphic.ui", rxFrame),
      47             :     maBrightControl(SID_ATTR_GRAF_LUMINANCE, *pBindings, *this),
      48             :     maContrastControl(SID_ATTR_GRAF_CONTRAST, *pBindings, *this),
      49             :     maTransparenceControl(SID_ATTR_GRAF_TRANSPARENCE, *pBindings, *this),
      50             :     maRedControl(SID_ATTR_GRAF_RED, *pBindings, *this),
      51             :     maGreenControl(SID_ATTR_GRAF_GREEN, *pBindings, *this),
      52             :     maBlueControl(SID_ATTR_GRAF_BLUE, *pBindings, *this),
      53             :     maGammaControl(SID_ATTR_GRAF_GAMMA, *pBindings, *this),
      54             :     maModeControl(SID_ATTR_GRAF_MODE, *pBindings, *this),
      55             :     mxFrame(rxFrame),
      56           0 :     mpBindings(pBindings)
      57             : {
      58           0 :     get(mpMtrBrightness, "setbrightness");
      59           0 :     get(mpMtrContrast, "setcontrast");
      60           0 :     get(mpLBColorMode, "setcolormode");
      61           0 :     get(mpMtrTrans, "settransparency");
      62           0 :     get(mpMtrRed, "setred");
      63           0 :     get(mpMtrGreen, "setgreen");
      64           0 :     get(mpMtrBlue, "setblue");
      65           0 :     get(mpMtrGamma, "setgamma");
      66           0 :     Initialize();
      67           0 : }
      68             : 
      69             : 
      70             : 
      71           0 : GraphicPropertyPanel::~GraphicPropertyPanel()
      72             : {
      73           0 : }
      74             : 
      75             : 
      76             : 
      77           0 : void GraphicPropertyPanel::Initialize()
      78             : {
      79           0 :     mpMtrBrightness->SetModifyHdl( LINK( this, GraphicPropertyPanel, ModifyBrightnessHdl ) );
      80           0 :     mpMtrBrightness->SetAccessibleName(::rtl::OUString( "Brightness"));
      81           0 :     mpMtrContrast->SetModifyHdl( LINK( this, GraphicPropertyPanel, ModifyContrastHdl ) );
      82           0 :     mpMtrContrast->SetAccessibleName(::rtl::OUString( "Contrast"));
      83           0 :     mpMtrTrans->SetModifyHdl( LINK( this, GraphicPropertyPanel, ModifyTransHdl ) );
      84           0 :     mpMtrTrans->SetAccessibleName(::rtl::OUString( "Transparency"));
      85             : 
      86           0 :     mpLBColorMode->InsertEntry(SVX_RESSTR(RID_SVXSTR_GRAFMODE_STANDARD));
      87           0 :     mpLBColorMode->InsertEntry(SVX_RESSTR(RID_SVXSTR_GRAFMODE_GREYS));
      88           0 :     mpLBColorMode->InsertEntry(SVX_RESSTR(RID_SVXSTR_GRAFMODE_MONO));
      89           0 :     mpLBColorMode->InsertEntry(SVX_RESSTR(RID_SVXSTR_GRAFMODE_WATERMARK));
      90           0 :     mpLBColorMode->SetSelectHdl( LINK( this, GraphicPropertyPanel, ClickColorModeHdl ));
      91           0 :     mpLBColorMode->SetAccessibleName(::rtl::OUString( "Color mode"));
      92             : 
      93           0 :     mpMtrRed->SetModifyHdl( LINK( this, GraphicPropertyPanel, RedHdl ) );
      94           0 :     mpMtrGreen->SetModifyHdl( LINK( this, GraphicPropertyPanel, GreenHdl ) );
      95           0 :     mpMtrBlue->SetModifyHdl( LINK( this, GraphicPropertyPanel, BlueHdl ) );
      96           0 :     mpMtrGamma->SetModifyHdl( LINK( this, GraphicPropertyPanel, GammaHdl ) );
      97           0 :     mpMtrRed->SetAccessibleName(mpMtrRed->GetQuickHelpText());
      98           0 :     mpMtrGreen->SetAccessibleName(mpMtrGreen->GetQuickHelpText());
      99           0 :     mpMtrBlue->SetAccessibleName(mpMtrBlue->GetQuickHelpText());
     100           0 :     mpMtrGamma->SetAccessibleName(::rtl::OUString( "Gamma value"));
     101             : 
     102           0 :     mpMtrRed->SetAccessibleRelationLabeledBy(mpMtrRed);
     103           0 :     mpMtrGreen->SetAccessibleRelationLabeledBy(mpMtrGreen);
     104           0 :     mpMtrBlue->SetAccessibleRelationLabeledBy(mpMtrBlue);
     105           0 :     mpMtrGamma->SetAccessibleRelationLabeledBy(mpMtrGamma);
     106             : 
     107             :     // Fix left position of some controls that may be wrong due to
     108             :     // rounding errors.
     109           0 :     const sal_Int32 nRight0 (mpLBColorMode->GetPosPixel().X() + mpLBColorMode->GetSizePixel().Width());
     110           0 :     const sal_Int32 nRight1 (mpMtrTrans->GetPosPixel().X() + mpMtrTrans->GetSizePixel().Width());
     111             :     mpMtrRed->SetPosPixel(Point(
     112           0 :             nRight0 - mpMtrRed->GetSizePixel().Width(),
     113           0 :             mpMtrRed->GetPosPixel().Y()));
     114             :     mpMtrBlue->SetPosPixel(Point(
     115           0 :             nRight0 - mpMtrBlue->GetSizePixel().Width(),
     116           0 :             mpMtrBlue->GetPosPixel().Y()));
     117             :     mpMtrGreen->SetPosPixel(Point(
     118           0 :             nRight1 - mpMtrGreen->GetSizePixel().Width(),
     119           0 :             mpMtrGreen->GetPosPixel().Y()));
     120             :     mpMtrGamma->SetPosPixel(Point(
     121           0 :             nRight1 - mpMtrGamma->GetSizePixel().Width(),
     122           0 :             mpMtrGamma->GetPosPixel().Y()));
     123           0 : }
     124             : 
     125             : 
     126             : 
     127             : 
     128             : 
     129             : 
     130           0 : IMPL_LINK( GraphicPropertyPanel, ModifyBrightnessHdl, void *, EMPTYARG )
     131             : {
     132           0 :     const sal_Int16 nBright = mpMtrBrightness->GetValue();
     133           0 :     const SfxInt16Item aBrightItem( SID_ATTR_GRAF_LUMINANCE, nBright );
     134           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_LUMINANCE, SfxCallMode::RECORD, &aBrightItem, 0L);
     135           0 :     return 0L;
     136             : }
     137             : 
     138             : 
     139             : 
     140           0 : IMPL_LINK( GraphicPropertyPanel, ModifyContrastHdl, void *, EMPTYARG )
     141             : {
     142           0 :     const sal_Int16 nContrast = mpMtrContrast->GetValue();
     143           0 :     const SfxInt16Item aContrastItem( SID_ATTR_GRAF_CONTRAST, nContrast );
     144           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_CONTRAST, SfxCallMode::RECORD, &aContrastItem, 0L);
     145           0 :     return 0L;
     146             : }
     147             : 
     148             : 
     149             : 
     150           0 : IMPL_LINK( GraphicPropertyPanel, ModifyTransHdl, void *, EMPTYARG )
     151             : {
     152           0 :     const sal_Int16 nTrans = mpMtrTrans->GetValue();
     153           0 :     const SfxInt16Item aTransItem( SID_ATTR_GRAF_TRANSPARENCE, nTrans );
     154           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_TRANSPARENCE, SfxCallMode::RECORD, &aTransItem, 0L);
     155           0 :     return 0L;
     156             : }
     157             : 
     158             : 
     159             : 
     160           0 : IMPL_LINK_NOARG( GraphicPropertyPanel, ClickColorModeHdl )
     161             : {
     162           0 :     const sal_Int16 nTrans = mpLBColorMode->GetSelectEntryPos();
     163           0 :     const SfxInt16Item aTransItem( SID_ATTR_GRAF_MODE, nTrans );
     164           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_MODE, SfxCallMode::RECORD, &aTransItem, 0L);
     165           0 :     return 0L;
     166             : }
     167             : 
     168             : 
     169             : 
     170           0 : IMPL_LINK( GraphicPropertyPanel, RedHdl, void*, EMPTYARG )
     171             : {
     172           0 :     const sal_Int16 nRed = mpMtrRed->GetValue();
     173           0 :     const SfxInt16Item aRedItem( SID_ATTR_GRAF_RED, nRed );
     174           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_RED, SfxCallMode::RECORD, &aRedItem, 0L);
     175           0 :     return 0L;
     176             : }
     177             : 
     178             : 
     179             : 
     180           0 : IMPL_LINK( GraphicPropertyPanel, GreenHdl, void*, EMPTYARG )
     181             : {
     182           0 :     const sal_Int16 nGreen = mpMtrGreen->GetValue();
     183           0 :     const SfxInt16Item aGreenItem( SID_ATTR_GRAF_GREEN, nGreen );
     184           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_GREEN, SfxCallMode::RECORD, &aGreenItem, 0L);
     185           0 :     return 0L;
     186             : }
     187             : 
     188             : 
     189             : 
     190           0 : IMPL_LINK(GraphicPropertyPanel, BlueHdl, void *, EMPTYARG)
     191             : {
     192           0 :     const sal_Int16 nBlue = mpMtrBlue->GetValue();
     193           0 :     const SfxInt16Item aBlueItem( SID_ATTR_GRAF_BLUE, nBlue );
     194           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_BLUE, SfxCallMode::RECORD, &aBlueItem, 0L);
     195           0 :     return 0L;
     196             : }
     197             : 
     198             : 
     199             : 
     200           0 : IMPL_LINK(GraphicPropertyPanel, GammaHdl, void *, EMPTYARG)
     201             : {
     202           0 :     const sal_Int32 nGamma = mpMtrGamma->GetValue();
     203           0 :     const SfxInt32Item nGammaItem( SID_ATTR_GRAF_GAMMA, nGamma );
     204           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_GAMMA, SfxCallMode::RECORD, &nGammaItem, 0L);
     205           0 :     return 0L;
     206             : }
     207             : 
     208             : 
     209             : 
     210           0 : void GraphicPropertyPanel::SetupIcons(void)
     211             : {
     212           0 :     if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
     213             :     {
     214             :         // todo
     215             :     }
     216             :     else
     217             :     {
     218             :         // todo
     219             :     }
     220           0 : }
     221             : 
     222             : 
     223             : 
     224           0 : GraphicPropertyPanel* GraphicPropertyPanel::Create (
     225             :     vcl::Window* pParent,
     226             :     const css::uno::Reference<css::frame::XFrame>& rxFrame,
     227             :     SfxBindings* pBindings)
     228             : {
     229           0 :     if (pParent == NULL)
     230           0 :         throw lang::IllegalArgumentException("no parent Window given to GraphicPropertyPanel::Create", NULL, 0);
     231           0 :     if ( ! rxFrame.is())
     232           0 :         throw lang::IllegalArgumentException("no XFrame given to GraphicPropertyPanel::Create", NULL, 1);
     233           0 :     if (pBindings == NULL)
     234           0 :         throw lang::IllegalArgumentException("no SfxBindings given to GraphicPropertyPanel::Create", NULL, 2);
     235             : 
     236             :     return new GraphicPropertyPanel(
     237             :         pParent,
     238             :         rxFrame,
     239           0 :         pBindings);
     240             : }
     241             : 
     242             : 
     243             : 
     244           0 : void GraphicPropertyPanel::DataChanged(
     245             :     const DataChangedEvent& rEvent)
     246             : {
     247             :     (void)rEvent;
     248             : 
     249           0 :     SetupIcons();
     250           0 : }
     251             : 
     252             : 
     253             : 
     254           0 : void GraphicPropertyPanel::NotifyItemUpdate(
     255             :     sal_uInt16 nSID,
     256             :     SfxItemState eState,
     257             :     const SfxPoolItem* pState,
     258             :     const bool bIsEnabled)
     259             : {
     260             :     (void)bIsEnabled;
     261             : 
     262           0 :     switch( nSID )
     263             :     {
     264             :         case SID_ATTR_GRAF_LUMINANCE:
     265             :         {
     266           0 :             if(eState >= SfxItemState::DEFAULT)
     267             :             {
     268           0 :                 mpMtrBrightness->Enable();
     269           0 :                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
     270             : 
     271           0 :                 if(pItem)
     272             :                 {
     273           0 :                     const sal_Int64 nBright = pItem->GetValue();
     274           0 :                     mpMtrBrightness->SetValue(nBright);
     275             :                 }
     276             :             }
     277           0 :             else if(SfxItemState::DISABLED == eState)
     278             :             {
     279           0 :                 mpMtrBrightness->Disable();
     280             :             }
     281             :             else
     282             :             {
     283           0 :                 mpMtrBrightness->Enable();
     284           0 :                 mpMtrBrightness->SetText(OUString());
     285             :             }
     286           0 :             break;
     287             :         }
     288             :         case SID_ATTR_GRAF_CONTRAST:
     289             :         {
     290           0 :             if(eState >= SfxItemState::DEFAULT)
     291             :             {
     292           0 :                 mpMtrContrast->Enable();
     293           0 :                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
     294             : 
     295           0 :                 if(pItem)
     296             :                 {
     297           0 :                     const sal_Int64 nContrast = pItem->GetValue();
     298           0 :                     mpMtrContrast->SetValue(nContrast);
     299             :                 }
     300             :             }
     301           0 :             else if(SfxItemState::DISABLED == eState)
     302             :             {
     303           0 :                 mpMtrContrast->Disable();
     304             :             }
     305             :             else
     306             :             {
     307           0 :                 mpMtrContrast->Enable();
     308           0 :                 mpMtrContrast->SetText(OUString());
     309             :             }
     310           0 :             break;
     311             :         }
     312             :         case SID_ATTR_GRAF_TRANSPARENCE:
     313             :         {
     314           0 :             if(eState >= SfxItemState::DEFAULT)
     315             :             {
     316           0 :                 mpMtrTrans->Enable();
     317           0 :                 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
     318             : 
     319           0 :                 if(pItem)
     320             :                 {
     321           0 :                     const sal_Int64 nTrans = pItem->GetValue();
     322           0 :                     mpMtrTrans->SetValue(nTrans);
     323             :                 }
     324             :             }
     325           0 :             else if(SfxItemState::DISABLED == eState)
     326             :             {
     327           0 :                 mpMtrTrans->Disable();
     328             :             }
     329             :             else
     330             :             {
     331           0 :                 mpMtrTrans->Enable();
     332           0 :                 mpMtrTrans->SetText(OUString());
     333             :             }
     334           0 :             break;
     335             :         }
     336             :         case SID_ATTR_GRAF_MODE:
     337             :         {
     338           0 :             if(eState >= SfxItemState::DEFAULT)
     339             :             {
     340           0 :                 mpLBColorMode->Enable();
     341           0 :                 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
     342             : 
     343           0 :                 if(pItem)
     344             :                 {
     345           0 :                     const sal_Int64 nTrans = pItem->GetValue();
     346           0 :                     mpLBColorMode->SelectEntryPos(nTrans);
     347             :                 }
     348             :             }
     349           0 :             else if(SfxItemState::DISABLED == eState)
     350             :             {
     351           0 :                 mpLBColorMode->Disable();
     352             :             }
     353             :             else
     354             :             {
     355           0 :                 mpLBColorMode->Enable();
     356           0 :                 mpLBColorMode->SetNoSelection();
     357             :             }
     358           0 :             break;
     359             :         }
     360             :         case SID_ATTR_GRAF_RED:
     361             :         {
     362           0 :             if(eState >= SfxItemState::DEFAULT)
     363             :             {
     364           0 :                 mpMtrRed->Enable();
     365           0 :                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
     366             : 
     367           0 :                 if(pItem)
     368             :                 {
     369           0 :                     const sal_Int64 nRed = pItem->GetValue();
     370           0 :                     mpMtrRed->SetValue( nRed );
     371             :                 }
     372             :             }
     373           0 :             else if(SfxItemState::DISABLED == eState)
     374             :             {
     375           0 :                 mpMtrRed->Disable();
     376             :             }
     377             :             else
     378             :             {
     379           0 :                 mpMtrRed->Enable();
     380           0 :                 mpMtrRed->SetText(OUString());
     381             :             }
     382           0 :             break;
     383             :         }
     384             :         case SID_ATTR_GRAF_GREEN:
     385             :         {
     386           0 :             if(eState >= SfxItemState::DEFAULT)
     387             :             {
     388           0 :                 mpMtrGreen->Enable();
     389           0 :                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
     390             : 
     391           0 :                 if(pItem)
     392             :                 {
     393           0 :                     const sal_Int64 nGreen = pItem->GetValue();
     394           0 :                     mpMtrGreen->SetValue( nGreen );
     395             :                 }
     396             :             }
     397           0 :             else if(SfxItemState::DISABLED == eState)
     398             :             {
     399           0 :                 mpMtrGreen->Disable();
     400             :             }
     401             :             else
     402             :             {
     403           0 :                 mpMtrGreen->Enable();
     404           0 :                 mpMtrGreen->SetText(OUString());
     405             :             }
     406           0 :             break;
     407             :         }
     408             :         case SID_ATTR_GRAF_BLUE:
     409             :         {
     410           0 :             if(eState >= SfxItemState::DEFAULT)
     411             :             {
     412           0 :                 mpMtrBlue->Enable();
     413           0 :                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
     414             : 
     415           0 :                 if(pItem)
     416             :                 {
     417           0 :                     const sal_Int64 nBlue = pItem->GetValue();
     418           0 :                     mpMtrBlue->SetValue( nBlue );
     419             :                 }
     420             :             }
     421           0 :             else if(SfxItemState::DISABLED == eState)
     422             :             {
     423           0 :                 mpMtrBlue->Disable();
     424             :             }
     425             :             else
     426             :             {
     427           0 :                 mpMtrBlue->Enable();
     428           0 :                 mpMtrBlue->SetText(OUString());
     429             :             }
     430           0 :             break;
     431             :         }
     432             :         case SID_ATTR_GRAF_GAMMA:
     433             :         {
     434           0 :             if(eState >= SfxItemState::DEFAULT)
     435             :             {
     436           0 :                 mpMtrGamma->Enable();
     437           0 :                 const SfxUInt32Item* pItem = dynamic_cast< const SfxUInt32Item* >(pState);
     438             : 
     439           0 :                 if(pItem)
     440             :                 {
     441           0 :                     const sal_Int64 nGamma = pItem->GetValue();
     442           0 :                     mpMtrGamma->SetValue( nGamma );
     443             :                 }
     444             :             }
     445           0 :             else if(SfxItemState::DISABLED == eState)
     446             :             {
     447           0 :                 mpMtrGamma->Disable();
     448             :             }
     449             :             else
     450             :             {
     451           0 :                 mpMtrGamma->Enable();
     452           0 :                 mpMtrGamma->SetText(OUString());
     453             :             }
     454           0 :             break;
     455             :         }
     456             :     }
     457           0 : }
     458             : 
     459             : 
     460             : 
     461             : 
     462             : 
     463             : 
     464             : 
     465             : 
     466             : // namespace close
     467             : 
     468         594 : }} // end of namespace ::svx::sidebar
     469             : 
     470             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10