LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - diactrl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 57 3.5 %
Date: 2015-06-13 12:38:46 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             : #include "diactrl.hxx"
      28             : 
      29             : #include "sdresid.hxx"
      30             : #include "app.hrc"
      31             : #include "res_bmp.hrc"
      32             : #include <sfx2/dispatch.hxx>
      33             : #include <sfx2/viewfrm.hxx>
      34             : #include <sfx2/app.hxx>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : 
      38          21 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages,  SfxUInt16Item )
      39             : 
      40             : // SdPagesField
      41           0 : SdPagesField::SdPagesField( vcl::Window* pParent,
      42             :                             const uno::Reference< frame::XFrame >& rFrame,
      43             :                             WinBits nBits ) :
      44             :     SvxMetricField  ( pParent, rFrame, nBits ),
      45           0 :     m_xFrame        ( rFrame )
      46             : {
      47           0 :     OUString aStr( SD_RESSTR( STR_SLIDE_PLURAL ) );
      48           0 :     SetCustomUnitText( aStr );
      49             : 
      50             :     // set size
      51           0 :     aStr += "XXX";
      52           0 :     Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 );
      53             : 
      54           0 :     SetSizePixel( aSize );
      55             : 
      56             :     // set parameter of MetricFields
      57           0 :     SetUnit( FUNIT_CUSTOM );
      58           0 :     SetMin( 1 );
      59           0 :     SetFirst( 1 );
      60           0 :     SetMax( 15 );
      61           0 :     SetLast( 15 );
      62           0 :     SetSpinSize( 1 );
      63           0 :     SetDecimalDigits( 0 );
      64           0 :     Show();
      65           0 : }
      66             : 
      67           0 : SdPagesField::~SdPagesField()
      68             : {
      69           0 : }
      70             : 
      71           0 : void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
      72             : {
      73           0 :     if( pItem )
      74             :     {
      75           0 :         long nValue = (long) pItem->GetValue();
      76           0 :         SetValue( nValue );
      77           0 :         if( nValue == 1 )
      78           0 :             SetCustomUnitText( SD_RESSTR( STR_SLIDE_SINGULAR ) );
      79             :         else
      80           0 :             SetCustomUnitText( SD_RESSTR( STR_SLIDE_PLURAL ) );
      81             :     }
      82             :     else
      83           0 :         SetText( OUString() );
      84           0 : }
      85             : 
      86           0 : void SdPagesField::Modify()
      87             : {
      88           0 :     SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() );
      89             : 
      90           0 :     ::uno::Any a;
      91           0 :     ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
      92           0 :     aArgs[0].Name   = "PagesPerRow";
      93           0 :     aItem.QueryValue( a );
      94           0 :     aArgs[0].Value  = a;
      95           0 :     SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
      96             :                                  ".uno:PagesPerRow",
      97           0 :                                  aArgs );
      98           0 : }
      99             : 
     100           0 : SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     101           0 :     SfxToolBoxControl( nSlotId, nId, rTbx )
     102             : {
     103           0 : }
     104             : 
     105           0 : SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
     106             : {
     107           0 : }
     108             : 
     109           0 : void SdTbxCtlDiaPages::StateChanged( sal_uInt16,
     110             :                 SfxItemState eState, const SfxPoolItem* pState )
     111             : {
     112           0 :     SdPagesField* pFld = static_cast<SdPagesField*>( GetToolBox().GetItemWindow( GetId() ) );
     113             :     DBG_ASSERT( pFld, "Window not found" );
     114             : 
     115           0 :     if ( eState == SfxItemState::DISABLED )
     116             :     {
     117           0 :         pFld->Disable();
     118           0 :         pFld->SetText( OUString() );
     119             :     }
     120             :     else
     121             :     {
     122           0 :         pFld->Enable();
     123             : 
     124           0 :         const SfxUInt16Item* pItem = 0;
     125           0 :         if ( eState == SfxItemState::DEFAULT )
     126             :         {
     127           0 :             pItem = dynamic_cast< const SfxUInt16Item* >( pState );
     128             :             DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
     129             :         }
     130             : 
     131           0 :         pFld->UpdatePagesField( pItem );
     132             :     }
     133           0 : }
     134             : 
     135           0 : VclPtr<vcl::Window> SdTbxCtlDiaPages::CreateItemWindow( vcl::Window* pParent )
     136             : {
     137           0 :     return VclPtrInstance<SdPagesField>( pParent, m_xFrame ).get();
     138          66 : }
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11