LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/sidebar - WrapPropertyPanel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 104 1.0 %
Date: 2013-07-09 Functions: 2 10 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : 
      19             : #include "WrapPropertyPanel.hxx"
      20             : #include "WrapPropertyPanel.hrc"
      21             : #include "PropertyPanel.hrc"
      22             : 
      23             : #include <cmdid.h>
      24             : #include <swtypes.hxx>
      25             : 
      26             : #include <sfx2/bindings.hxx>
      27             : #include <sfx2/dispatch.hxx>
      28             : #include <sfx2/sidebar/ControlFactory.hxx>
      29             : #include <sfx2/imagemgr.hxx>
      30             : #include <svl/eitem.hxx>
      31             : #include <vcl/svapp.hxx>
      32             : 
      33             : #include "com/sun/star/lang/IllegalArgumentException.hpp"
      34             : 
      35             : #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
      36             : 
      37             : 
      38             : namespace sw { namespace sidebar {
      39             : 
      40           0 : WrapPropertyPanel* WrapPropertyPanel::Create (
      41             :     Window* pParent,
      42             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
      43             :     SfxBindings* pBindings)
      44             : {
      45           0 :     if (pParent == NULL)
      46           0 :         throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to WrapPropertyPanel::Create"), NULL, 0);
      47           0 :     if ( ! rxFrame.is())
      48           0 :         throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to WrapPropertyPanel::Create"), NULL, 1);
      49           0 :     if (pBindings == NULL)
      50           0 :         throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to WrapPropertyPanel::Create"), NULL, 2);
      51             : 
      52             :     return new WrapPropertyPanel(
      53             :         pParent,
      54             :         rxFrame,
      55           0 :         pBindings);
      56             : }
      57             : 
      58             : 
      59           0 : WrapPropertyPanel::WrapPropertyPanel(
      60             :     Window* pParent,
      61             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
      62             :     SfxBindings* pBindings )
      63             :     : Control(pParent, SW_RES(RID_PROPERTYPANEL_SWOBJWRAP_PAGE))
      64             :     , mxFrame( rxFrame )
      65             :     , mpBindings(pBindings)
      66             :     // visible controls
      67             :     , mpRBNoWrap( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_NO_WRAP) ) )
      68             :     , mpRBWrapLeft( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_LEFT) ) )
      69             :     , mpRBWrapRight( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_RIGHT) ) )
      70             :     , mpRBWrapParallel( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_PARALLEL) ) )
      71             :     , mpRBWrapThrough( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_THROUGH) ) )
      72             :     , mpRBIdealWrap( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_IDEAL) ) )
      73             :     // resources
      74             :     , aWrapIL(6,2)
      75             :     // controller items
      76             :     , maSwNoWrapControl(FN_FRAME_NOWRAP, *pBindings, *this)
      77             :     , maSwWrapLeftControl(FN_FRAME_WRAP, *pBindings, *this)
      78             :     , maSwWrapRightControl(FN_FRAME_WRAP_RIGHT, *pBindings, *this)
      79             :     , maSwWrapParallelControl(FN_FRAME_WRAP_LEFT, *pBindings, *this)
      80             :     , maSwWrapThroughControl(FN_FRAME_WRAPTHRU, *pBindings, *this)
      81           0 :     , maSwWrapIdealControl(FN_FRAME_WRAP_IDEAL, *pBindings, *this)
      82             : {
      83           0 :     Initialize();
      84           0 :     FreeResource();
      85           0 : }
      86             : 
      87             : 
      88           0 : WrapPropertyPanel::~WrapPropertyPanel()
      89             : {
      90           0 : }
      91             : 
      92             : 
      93           0 : void WrapPropertyPanel::Initialize()
      94             : {
      95           0 :     Link aLink = LINK(this, WrapPropertyPanel, WrapTypeHdl);
      96           0 :     mpRBNoWrap->SetClickHdl(aLink);
      97           0 :     mpRBWrapLeft->SetClickHdl(aLink);
      98           0 :     mpRBWrapRight->SetClickHdl(aLink);
      99           0 :     mpRBWrapParallel->SetClickHdl(aLink);
     100           0 :     mpRBWrapThrough->SetClickHdl(aLink);
     101           0 :     mpRBIdealWrap->SetClickHdl(aLink);
     102             : 
     103             :     aWrapIL.AddImage( IMG_NONE,
     104           0 :                       ::GetImage( mxFrame, A2S(".uno:WrapOff"), sal_False ) );
     105             :     aWrapIL.AddImage( IMG_LEFT,
     106           0 :                       ::GetImage( mxFrame, A2S(".uno:WrapLeft"), sal_False ) );
     107             :     aWrapIL.AddImage( IMG_RIGHT,
     108           0 :                       ::GetImage( mxFrame, A2S(".uno:WrapRight"), sal_False ) );
     109             :     aWrapIL.AddImage( IMG_PARALLEL,
     110           0 :                       ::GetImage( mxFrame, A2S(".uno:WrapOn"), sal_False ) );
     111             :     aWrapIL.AddImage( IMG_THROUGH,
     112           0 :                       ::GetImage( mxFrame, A2S(".uno:WrapThrough"), sal_False ) );
     113             :     aWrapIL.AddImage( IMG_IDEAL,
     114           0 :                       ::GetImage( mxFrame, A2S(".uno:WrapIdeal"), sal_False ) );
     115             : 
     116           0 :     mpRBNoWrap->SetModeRadioImage( aWrapIL.GetImage(IMG_NONE) );
     117           0 :     if ( Application::GetSettings().GetLayoutRTL() )
     118             :     {
     119           0 :         mpRBWrapLeft->SetModeRadioImage( aWrapIL.GetImage(IMG_RIGHT) );
     120           0 :         mpRBWrapRight->SetModeRadioImage( aWrapIL.GetImage(IMG_LEFT) );
     121             :     }
     122             :     else
     123             :     {
     124           0 :         mpRBWrapLeft->SetModeRadioImage( aWrapIL.GetImage(IMG_LEFT) );
     125           0 :         mpRBWrapRight->SetModeRadioImage( aWrapIL.GetImage(IMG_RIGHT) );
     126             :     }
     127           0 :     mpRBWrapParallel->SetModeRadioImage( aWrapIL.GetImage(IMG_PARALLEL) );
     128           0 :     mpRBWrapThrough->SetModeRadioImage( aWrapIL.GetImage(IMG_THROUGH) );
     129           0 :     mpRBIdealWrap->SetModeRadioImage( aWrapIL.GetImage(IMG_IDEAL) );
     130             : 
     131           0 :     mpRBNoWrap->SetAccessibleName(mpRBNoWrap->GetQuickHelpText());
     132           0 :     mpRBWrapLeft->SetAccessibleName(mpRBWrapLeft->GetQuickHelpText());
     133           0 :     mpRBWrapRight->SetAccessibleName(mpRBWrapRight->GetQuickHelpText());
     134           0 :     mpRBWrapParallel->SetAccessibleName(mpRBWrapParallel->GetQuickHelpText());
     135           0 :     mpRBWrapThrough->SetAccessibleName(mpRBWrapThrough->GetQuickHelpText());
     136           0 :     mpRBIdealWrap->SetAccessibleName(mpRBIdealWrap->GetQuickHelpText());
     137             : 
     138           0 :     mpBindings->Update( FN_FRAME_NOWRAP );
     139           0 :     mpBindings->Update( FN_FRAME_WRAP );
     140           0 :     mpBindings->Update( FN_FRAME_WRAP_RIGHT );
     141           0 :     mpBindings->Update( FN_FRAME_WRAP_LEFT );
     142           0 :     mpBindings->Update( FN_FRAME_WRAPTHRU );
     143           0 :     mpBindings->Update( FN_FRAME_WRAP_IDEAL );
     144           0 : }
     145             : 
     146             : 
     147           0 : IMPL_LINK(WrapPropertyPanel, WrapTypeHdl, void *, EMPTYARG)
     148             : {
     149           0 :     sal_uInt16 nSlot = 0;
     150           0 :     if ( mpRBWrapLeft->IsChecked() )
     151             :     {
     152           0 :         nSlot = FN_FRAME_WRAP_LEFT;
     153             :     }
     154           0 :     else if( mpRBWrapRight->IsChecked() )
     155             :     {
     156           0 :         nSlot = FN_FRAME_WRAP_RIGHT;
     157             :     }
     158           0 :     else if ( mpRBWrapParallel->IsChecked() )
     159             :     {
     160           0 :         nSlot = FN_FRAME_WRAP;
     161             :     }
     162           0 :     else if( mpRBWrapThrough->IsChecked() )
     163             :     {
     164           0 :         nSlot = FN_FRAME_WRAPTHRU;
     165             :     }
     166           0 :     else if( mpRBIdealWrap->IsChecked() )
     167             :     {
     168           0 :         nSlot = FN_FRAME_WRAP_IDEAL;
     169             :     }
     170             :     else
     171             :     {
     172           0 :         nSlot = FN_FRAME_NOWRAP;
     173             :     }
     174           0 :     SfxBoolItem bStateItem( nSlot, sal_True );
     175           0 :     mpBindings->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_RECORD, &bStateItem, 0L );
     176             : 
     177           0 :     return 0;
     178             : }
     179             : 
     180             : 
     181           0 : void WrapPropertyPanel::NotifyItemUpdate(
     182             :     const sal_uInt16 nSId,
     183             :     const SfxItemState eState,
     184             :     const SfxPoolItem* pState,
     185             :     const bool bIsEnabled)
     186             : {
     187             :     (void)bIsEnabled;
     188             : 
     189           0 :     if ( eState == SFX_ITEM_AVAILABLE &&
     190           0 :         pState->ISA(SfxBoolItem) )
     191             :     {
     192             :         //Set Radio Button enable
     193           0 :         mpRBNoWrap->Enable(true);
     194           0 :         mpRBWrapLeft->Enable(true);
     195           0 :         mpRBWrapRight->Enable(true);
     196           0 :         mpRBWrapParallel->Enable(true);
     197           0 :         mpRBWrapThrough->Enable(true);
     198           0 :         mpRBIdealWrap->Enable(true);
     199             : 
     200           0 :         const SfxBoolItem* pBoolItem = static_cast< const SfxBoolItem* >( pState );
     201           0 :         switch( nSId )
     202             :         {
     203             :         case FN_FRAME_WRAP_RIGHT:
     204           0 :             mpRBWrapRight->Check( pBoolItem->GetValue() );
     205           0 :             break;
     206             :         case FN_FRAME_WRAP_LEFT:
     207           0 :             mpRBWrapLeft->Check( pBoolItem->GetValue() );
     208           0 :             break;
     209             :         case FN_FRAME_WRAPTHRU:
     210           0 :             mpRBWrapThrough->Check( pBoolItem->GetValue() );
     211           0 :             break;
     212             :         case FN_FRAME_WRAP_IDEAL:
     213           0 :             mpRBIdealWrap->Check( pBoolItem->GetValue() );
     214           0 :             break;
     215             :         case FN_FRAME_WRAP:
     216           0 :             mpRBWrapParallel->Check( pBoolItem->GetValue() );
     217           0 :             break;
     218             :         case FN_FRAME_NOWRAP:
     219             :         default:
     220           0 :             mpRBNoWrap->Check( pBoolItem->GetValue() );
     221           0 :             break;
     222             :         }
     223             :     }
     224             :     else
     225             :     {
     226           0 :         mpRBNoWrap->Enable(false);
     227           0 :         mpRBWrapLeft->Enable(false);
     228           0 :         mpRBWrapRight->Enable(false);
     229           0 :         mpRBWrapParallel->Enable(false);
     230           0 :         mpRBWrapThrough->Enable(false);
     231           0 :         mpRBIdealWrap->Enable(false);
     232             : 
     233           0 :         mpRBNoWrap->Check( sal_False );
     234           0 :         mpRBWrapLeft->Check( sal_False );
     235           0 :         mpRBWrapRight->Check( sal_False );
     236           0 :         mpRBWrapParallel->Check( sal_False );
     237           0 :         mpRBWrapThrough->Check( sal_False );
     238           0 :         mpRBIdealWrap->Check( sal_False );
     239             :     }
     240           0 : }
     241             : 
     242          99 : } } // end of namespace ::sw::sidebar

Generated by: LCOV version 1.10