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

Generated by: LCOV version 1.11