LCOV - code coverage report
Current view: top level - sw/source/uibase/sidebar - WrapPropertyPanel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 124 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 0.0 %
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 "WrapPropertyPanel.hxx"
      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             : #include <vcl/settings.hxx>
      33             : 
      34             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      35             : 
      36             : const char UNO_WRAPOFF[] = ".uno:WrapOff";
      37             : const char UNO_WRAPLEFT[] = ".uno:WrapLeft";
      38             : const char UNO_WRAPRIGHT[] = ".uno:WrapRight";
      39             : const char UNO_WRAPON[] = ".uno:WrapOn";
      40             : const char UNO_WRAPTHROUGH[] = ".uno:WrapThrough";
      41             : const char UNO_WRAPIDEAL[] = ".uno:WrapIdeal";
      42             : 
      43             : namespace sw { namespace sidebar {
      44             : 
      45           0 : VclPtr<vcl::Window> WrapPropertyPanel::Create (
      46             :     vcl::Window* pParent,
      47             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
      48             :     SfxBindings* pBindings)
      49             : {
      50           0 :     if (pParent == NULL)
      51           0 :         throw ::com::sun::star::lang::IllegalArgumentException("no parent Window given to WrapPropertyPanel::Create", NULL, 0);
      52           0 :     if ( ! rxFrame.is())
      53           0 :         throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to WrapPropertyPanel::Create", NULL, 1);
      54           0 :     if (pBindings == NULL)
      55           0 :         throw ::com::sun::star::lang::IllegalArgumentException("no SfxBindings given to WrapPropertyPanel::Create", NULL, 2);
      56             : 
      57             :     return VclPtr<WrapPropertyPanel>::Create(
      58             :                         pParent,
      59             :                         rxFrame,
      60           0 :                         pBindings);
      61             : }
      62             : 
      63           0 : WrapPropertyPanel::WrapPropertyPanel(
      64             :     vcl::Window* pParent,
      65             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
      66             :     SfxBindings* pBindings )
      67             :     : PanelLayout(pParent, "WrapPropertyPanel", "modules/swriter/ui/sidebarwrap.ui", rxFrame)
      68             :     , mxFrame( rxFrame )
      69             :     , mpBindings(pBindings)
      70             :     // resources
      71             :     , aWrapIL(6,2)
      72             :     // controller items
      73             :     , maSwNoWrapControl(FN_FRAME_NOWRAP, *pBindings, *this)
      74             :     , maSwWrapLeftControl(FN_FRAME_WRAP, *pBindings, *this)
      75             :     , maSwWrapRightControl(FN_FRAME_WRAP_RIGHT, *pBindings, *this)
      76             :     , maSwWrapParallelControl(FN_FRAME_WRAP_LEFT, *pBindings, *this)
      77             :     , maSwWrapThroughControl(FN_FRAME_WRAPTHRU, *pBindings, *this)
      78           0 :     , maSwWrapIdealControl(FN_FRAME_WRAP_IDEAL, *pBindings, *this)
      79             : {
      80           0 :     get(mpRBNoWrap, "buttonnone");
      81           0 :     get(mpRBWrapLeft, "buttonbefore");
      82           0 :     get(mpRBWrapRight, "buttonafter");
      83           0 :     get(mpRBWrapParallel, "buttonparallel");
      84           0 :     get(mpRBWrapThrough, "buttonthrough");
      85           0 :     get(mpRBIdealWrap, "buttonoptimal");
      86             : 
      87           0 :     Initialize();
      88           0 : }
      89             : 
      90           0 : WrapPropertyPanel::~WrapPropertyPanel()
      91             : {
      92           0 :     disposeOnce();
      93           0 : }
      94             : 
      95           0 : void WrapPropertyPanel::dispose()
      96             : {
      97           0 :     mpRBNoWrap.clear();
      98           0 :     mpRBWrapLeft.clear();
      99           0 :     mpRBWrapRight.clear();
     100           0 :     mpRBWrapParallel.clear();
     101           0 :     mpRBWrapThrough.clear();
     102           0 :     mpRBIdealWrap.clear();
     103             : 
     104           0 :     maSwNoWrapControl.dispose();
     105           0 :     maSwWrapLeftControl.dispose();
     106           0 :     maSwWrapRightControl.dispose();
     107           0 :     maSwWrapParallelControl.dispose();
     108           0 :     maSwWrapThroughControl.dispose();
     109           0 :     maSwWrapIdealControl.dispose();
     110             : 
     111           0 :     PanelLayout::dispose();
     112           0 : }
     113             : 
     114           0 : void WrapPropertyPanel::Initialize()
     115             : {
     116           0 :     Link<> aLink = LINK(this, WrapPropertyPanel, WrapTypeHdl);
     117           0 :     mpRBNoWrap->SetClickHdl(aLink);
     118           0 :     mpRBWrapLeft->SetClickHdl(aLink);
     119           0 :     mpRBWrapRight->SetClickHdl(aLink);
     120           0 :     mpRBWrapParallel->SetClickHdl(aLink);
     121           0 :     mpRBWrapThrough->SetClickHdl(aLink);
     122           0 :     mpRBIdealWrap->SetClickHdl(aLink);
     123             : 
     124             :     aWrapIL.AddImage( UNO_WRAPOFF,
     125           0 :                       ::GetImage( mxFrame, UNO_WRAPOFF, false ) );
     126             :     aWrapIL.AddImage( UNO_WRAPLEFT,
     127           0 :                       ::GetImage( mxFrame, UNO_WRAPLEFT, false ) );
     128             :     aWrapIL.AddImage( UNO_WRAPRIGHT,
     129           0 :                       ::GetImage( mxFrame, UNO_WRAPRIGHT, false ) );
     130             :     aWrapIL.AddImage( UNO_WRAPON,
     131           0 :                       ::GetImage( mxFrame, UNO_WRAPON, false ) );
     132             :     aWrapIL.AddImage( UNO_WRAPTHROUGH,
     133           0 :                       ::GetImage( mxFrame, UNO_WRAPTHROUGH, false ) );
     134             :     aWrapIL.AddImage( UNO_WRAPIDEAL,
     135           0 :                       ::GetImage( mxFrame, UNO_WRAPIDEAL, false ) );
     136             : 
     137           0 :     mpRBNoWrap->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPOFF) );
     138           0 :     if ( AllSettings::GetLayoutRTL() )
     139             :     {
     140           0 :         mpRBWrapLeft->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPRIGHT) );
     141           0 :         mpRBWrapRight->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPLEFT) );
     142             :     }
     143             :     else
     144             :     {
     145           0 :         mpRBWrapLeft->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPLEFT) );
     146           0 :         mpRBWrapRight->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPRIGHT) );
     147             :     }
     148           0 :     mpRBWrapParallel->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPON) );
     149           0 :     mpRBWrapThrough->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPTHROUGH) );
     150           0 :     mpRBIdealWrap->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPIDEAL) );
     151             : 
     152           0 :     mpRBNoWrap->SetAccessibleName(mpRBNoWrap->GetQuickHelpText());
     153           0 :     mpRBWrapLeft->SetAccessibleName(mpRBWrapLeft->GetQuickHelpText());
     154           0 :     mpRBWrapRight->SetAccessibleName(mpRBWrapRight->GetQuickHelpText());
     155           0 :     mpRBWrapParallel->SetAccessibleName(mpRBWrapParallel->GetQuickHelpText());
     156           0 :     mpRBWrapThrough->SetAccessibleName(mpRBWrapThrough->GetQuickHelpText());
     157           0 :     mpRBIdealWrap->SetAccessibleName(mpRBIdealWrap->GetQuickHelpText());
     158             : 
     159           0 :     mpBindings->Update( FN_FRAME_NOWRAP );
     160           0 :     mpBindings->Update( FN_FRAME_WRAP );
     161           0 :     mpBindings->Update( FN_FRAME_WRAP_RIGHT );
     162           0 :     mpBindings->Update( FN_FRAME_WRAP_LEFT );
     163           0 :     mpBindings->Update( FN_FRAME_WRAPTHRU );
     164           0 :     mpBindings->Update( FN_FRAME_WRAP_IDEAL );
     165           0 : }
     166             : 
     167           0 : IMPL_LINK_NOARG(WrapPropertyPanel, WrapTypeHdl)
     168             : {
     169           0 :     sal_uInt16 nSlot = 0;
     170           0 :     if ( mpRBWrapLeft->IsChecked() )
     171             :     {
     172           0 :         nSlot = FN_FRAME_WRAP_LEFT;
     173             :     }
     174           0 :     else if( mpRBWrapRight->IsChecked() )
     175             :     {
     176           0 :         nSlot = FN_FRAME_WRAP_RIGHT;
     177             :     }
     178           0 :     else if ( mpRBWrapParallel->IsChecked() )
     179             :     {
     180           0 :         nSlot = FN_FRAME_WRAP;
     181             :     }
     182           0 :     else if( mpRBWrapThrough->IsChecked() )
     183             :     {
     184           0 :         nSlot = FN_FRAME_WRAPTHRU;
     185             :     }
     186           0 :     else if( mpRBIdealWrap->IsChecked() )
     187             :     {
     188           0 :         nSlot = FN_FRAME_WRAP_IDEAL;
     189             :     }
     190             :     else
     191             :     {
     192           0 :         nSlot = FN_FRAME_NOWRAP;
     193             :     }
     194           0 :     SfxBoolItem bStateItem( nSlot, true );
     195           0 :     mpBindings->GetDispatcher()->Execute( nSlot, SfxCallMode::RECORD, &bStateItem, 0L );
     196             : 
     197           0 :     return 0;
     198             : }
     199             : 
     200           0 : void WrapPropertyPanel::NotifyItemUpdate(
     201             :     const sal_uInt16 nSId,
     202             :     const SfxItemState eState,
     203             :     const SfxPoolItem* pState,
     204             :     const bool bIsEnabled)
     205             : {
     206             :     (void)bIsEnabled;
     207             : 
     208           0 :     if ( eState == SfxItemState::DEFAULT &&
     209           0 :         pState->ISA(SfxBoolItem) )
     210             :     {
     211             :         //Set Radio Button enable
     212           0 :         mpRBNoWrap->Enable(true);
     213           0 :         mpRBWrapLeft->Enable(true);
     214           0 :         mpRBWrapRight->Enable(true);
     215           0 :         mpRBWrapParallel->Enable(true);
     216           0 :         mpRBWrapThrough->Enable(true);
     217           0 :         mpRBIdealWrap->Enable(true);
     218             : 
     219           0 :         const SfxBoolItem* pBoolItem = static_cast< const SfxBoolItem* >( pState );
     220           0 :         switch( nSId )
     221             :         {
     222             :         case FN_FRAME_WRAP_RIGHT:
     223           0 :             mpRBWrapRight->Check( pBoolItem->GetValue() );
     224           0 :             break;
     225             :         case FN_FRAME_WRAP_LEFT:
     226           0 :             mpRBWrapLeft->Check( pBoolItem->GetValue() );
     227           0 :             break;
     228             :         case FN_FRAME_WRAPTHRU:
     229           0 :             mpRBWrapThrough->Check( pBoolItem->GetValue() );
     230           0 :             break;
     231             :         case FN_FRAME_WRAP_IDEAL:
     232           0 :             mpRBIdealWrap->Check( pBoolItem->GetValue() );
     233           0 :             break;
     234             :         case FN_FRAME_WRAP:
     235           0 :             mpRBWrapParallel->Check( pBoolItem->GetValue() );
     236           0 :             break;
     237             :         case FN_FRAME_NOWRAP:
     238             :         default:
     239           0 :             mpRBNoWrap->Check( pBoolItem->GetValue() );
     240           0 :             break;
     241             :         }
     242             :     }
     243             :     else
     244             :     {
     245           0 :         mpRBNoWrap->Enable(false);
     246           0 :         mpRBWrapLeft->Enable(false);
     247           0 :         mpRBWrapRight->Enable(false);
     248           0 :         mpRBWrapParallel->Enable(false);
     249           0 :         mpRBWrapThrough->Enable(false);
     250           0 :         mpRBIdealWrap->Enable(false);
     251             : 
     252           0 :         mpRBNoWrap->Check( false );
     253           0 :         mpRBWrapLeft->Check( false );
     254           0 :         mpRBWrapRight->Check( false );
     255           0 :         mpRBWrapParallel->Check( false );
     256           0 :         mpRBWrapThrough->Check( false );
     257           0 :         mpRBIdealWrap->Check( false );
     258             :     }
     259           0 : }
     260             : 
     261             : } } // end of namespace ::sw::sidebar
     262             : 
     263             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11