LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - diactrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 57 3.5 %
Date: 2012-12-17 Functions: 3 14 21.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             : 
      20             : #include <com/sun/star/presentation/FadeEffect.hpp>
      21             : 
      22             : #include <svx/dialogs.hrc>
      23             : 
      24             : #include "sdattr.hxx"
      25             : #include "strings.hrc"
      26             : 
      27             : #define _SD_DIACTRL_CXX
      28             : #include "diactrl.hxx"
      29             : 
      30             : #include "sdresid.hxx"
      31             : #include "app.hrc"
      32             : #include "res_bmp.hrc"
      33             : #include <sfx2/dispatch.hxx>
      34             : #include <sfx2/viewfrm.hxx>
      35             : #include <sfx2/app.hxx>
      36             : 
      37             : using namespace ::com::sun::star;
      38             : 
      39           6 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages,  SfxUInt16Item )
      40             : 
      41             : 
      42             : //========================================================================
      43             : // SdPagesField
      44             : //========================================================================
      45             : 
      46           0 : SdPagesField::SdPagesField( Window* pParent,
      47             :                             const uno::Reference< frame::XFrame >& rFrame,
      48             :                             WinBits nBits ) :
      49             :     SvxMetricField  ( pParent, rFrame, nBits ),
      50           0 :     m_xFrame        ( rFrame )
      51             : {
      52           0 :     String aStr( SdResId( STR_SLIDE_PLURAL ) );
      53           0 :     SetCustomUnitText( aStr );
      54             : 
      55             :     // Groesse setzen
      56           0 :     aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
      57           0 :     Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 );
      58             : 
      59             : 
      60           0 :     SetSizePixel( aSize );
      61             : 
      62             :     // Parameter des MetricFields setzen
      63           0 :     SetUnit( FUNIT_CUSTOM );
      64           0 :     SetMin( 1 );
      65           0 :     SetFirst( 1 );
      66           0 :     SetMax( 15 );
      67           0 :     SetLast( 15 );
      68           0 :     SetSpinSize( 1 );
      69           0 :     SetDecimalDigits( 0 );
      70           0 :     Show();
      71           0 : }
      72             : 
      73             : // -----------------------------------------------------------------------
      74             : 
      75           0 : SdPagesField::~SdPagesField()
      76             : {
      77           0 : }
      78             : 
      79             : // -----------------------------------------------------------------------
      80             : 
      81           0 : void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
      82             : {
      83           0 :     if( pItem )
      84             :     {
      85           0 :         long nValue = (long) pItem->GetValue();
      86           0 :         SetValue( nValue );
      87           0 :         if( nValue == 1 )
      88           0 :             SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) );
      89             :         else
      90           0 :             SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) );
      91             :     }
      92             :     else
      93           0 :         SetText( String() );
      94           0 : }
      95             : 
      96             : // -----------------------------------------------------------------------
      97             : 
      98           0 : void SdPagesField::Modify()
      99             : {
     100           0 :     SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() );
     101             : 
     102           0 :     ::uno::Any a;
     103           0 :     ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
     104           0 :     aArgs[0].Name   = "PagesPerRow";
     105           0 :     aItem.QueryValue( a );
     106           0 :     aArgs[0].Value  = a;
     107           0 :     SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
     108             :                                  ".uno:PagesPerRow",
     109           0 :                                  aArgs );
     110           0 : }
     111             : 
     112             : /*************************************************************************
     113             : |*
     114             : |* SdTbxCtlDiaPages
     115             : |*
     116             : \************************************************************************/
     117             : 
     118           0 : SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     119           0 :     SfxToolBoxControl( nSlotId, nId, rTbx )
     120             : {
     121           0 : }
     122             : 
     123             : //========================================================================
     124             : 
     125           0 : SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
     126             : {
     127           0 : }
     128             : 
     129             : //========================================================================
     130             : 
     131           0 : void SdTbxCtlDiaPages::StateChanged( sal_uInt16,
     132             :                 SfxItemState eState, const SfxPoolItem* pState )
     133             : {
     134           0 :     SdPagesField* pFld = (SdPagesField*) GetToolBox().GetItemWindow( GetId() );
     135             :     DBG_ASSERT( pFld, "Window not found" );
     136             : 
     137           0 :     if ( eState == SFX_ITEM_DISABLED )
     138             :     {
     139           0 :         pFld->Disable();
     140           0 :         pFld->SetText( String() );
     141             :     }
     142             :     else
     143             :     {
     144           0 :         pFld->Enable();
     145             : 
     146           0 :         const SfxUInt16Item* pItem = 0;
     147           0 :         if ( eState == SFX_ITEM_AVAILABLE )
     148             :         {
     149           0 :             pItem = dynamic_cast< const SfxUInt16Item* >( pState );
     150             :             DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
     151             :         }
     152             : 
     153           0 :         pFld->UpdatePagesField( pItem );
     154             :     }
     155           0 : }
     156             : 
     157             : //========================================================================
     158             : 
     159           0 : Window* SdTbxCtlDiaPages::CreateItemWindow( Window* pParent )
     160             : {
     161           0 :     return new SdPagesField( pParent, m_xFrame );
     162          18 : }
     163             : 
     164             : 
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10