1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/presentation/FadeEffect.hpp> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <svx/dialogs.hrc> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "sdattr.hxx" 35*cdf0e10cSrcweir #include "strings.hrc" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #define _SD_DIACTRL_CXX 38*cdf0e10cSrcweir #include "diactrl.hxx" 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include "sdresid.hxx" 41*cdf0e10cSrcweir #include "app.hrc" 42*cdf0e10cSrcweir #include "res_bmp.hrc" 43*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 44*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 45*cdf0e10cSrcweir #include <sfx2/app.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace ::com::sun::star; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages, SfxUInt16Item ) 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //======================================================================== 53*cdf0e10cSrcweir // SdPagesField 54*cdf0e10cSrcweir //======================================================================== 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir SdPagesField::SdPagesField( Window* pParent, 57*cdf0e10cSrcweir const uno::Reference< frame::XFrame >& rFrame, 58*cdf0e10cSrcweir WinBits nBits ) : 59*cdf0e10cSrcweir SvxMetricField ( pParent, rFrame, nBits ), 60*cdf0e10cSrcweir m_xFrame ( rFrame ) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir String aStr( SdResId( STR_SLIDE_PLURAL ) ); 63*cdf0e10cSrcweir SetCustomUnitText( aStr ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // Groesse setzen 66*cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) ); 67*cdf0e10cSrcweir Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 ); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir SetSizePixel( aSize ); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // Parameter des MetricFields setzen 73*cdf0e10cSrcweir SetUnit( FUNIT_CUSTOM ); 74*cdf0e10cSrcweir SetMin( 1 ); 75*cdf0e10cSrcweir SetFirst( 1 ); 76*cdf0e10cSrcweir SetMax( 15 ); 77*cdf0e10cSrcweir SetLast( 15 ); 78*cdf0e10cSrcweir SetSpinSize( 1 ); 79*cdf0e10cSrcweir SetDecimalDigits( 0 ); 80*cdf0e10cSrcweir Show(); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // ----------------------------------------------------------------------- 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir SdPagesField::~SdPagesField() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // ----------------------------------------------------------------------- 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir if( pItem ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir long nValue = (long) pItem->GetValue(); 96*cdf0e10cSrcweir SetValue( nValue ); 97*cdf0e10cSrcweir if( nValue == 1 ) 98*cdf0e10cSrcweir SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) ); 99*cdf0e10cSrcweir else 100*cdf0e10cSrcweir SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir else 103*cdf0e10cSrcweir SetText( String() ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir // ----------------------------------------------------------------------- 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void SdPagesField::Modify() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir ::uno::Any a; 113*cdf0e10cSrcweir ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 ); 114*cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagesPerRow" )); 115*cdf0e10cSrcweir aItem.QueryValue( a ); 116*cdf0e10cSrcweir aArgs[0].Value = a; 117*cdf0e10cSrcweir SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ), 118*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PagesPerRow" )), 119*cdf0e10cSrcweir aArgs ); 120*cdf0e10cSrcweir /* 121*cdf0e10cSrcweir rBindings.GetDispatcher()->Execute( 122*cdf0e10cSrcweir SID_PAGES_PER_ROW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L, 0L ); 123*cdf0e10cSrcweir */ 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir /************************************************************************* 127*cdf0e10cSrcweir |* 128*cdf0e10cSrcweir |* SdTbxCtlDiaPages 129*cdf0e10cSrcweir |* 130*cdf0e10cSrcweir \************************************************************************/ 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 133*cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir //======================================================================== 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir SdTbxCtlDiaPages::~SdTbxCtlDiaPages() 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //======================================================================== 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir void SdTbxCtlDiaPages::StateChanged( sal_uInt16, 146*cdf0e10cSrcweir SfxItemState eState, const SfxPoolItem* pState ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir SdPagesField* pFld = (SdPagesField*) GetToolBox().GetItemWindow( GetId() ); 149*cdf0e10cSrcweir DBG_ASSERT( pFld, "Window not found" ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir if ( eState == SFX_ITEM_DISABLED ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir pFld->Disable(); 154*cdf0e10cSrcweir pFld->SetText( String() ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir else 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir pFld->Enable(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir const SfxUInt16Item* pItem = 0; 161*cdf0e10cSrcweir if ( eState == SFX_ITEM_AVAILABLE ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir pItem = dynamic_cast< const SfxUInt16Item* >( pState ); 164*cdf0e10cSrcweir DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir pFld->UpdatePagesField( pItem ); 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir //======================================================================== 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir Window* SdTbxCtlDiaPages::CreateItemWindow( Window* pParent ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir return new SdPagesField( pParent, m_xFrame ); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180