merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / sd / source / ui / dlg / diactrl.cxx
blob43452672cbd387ad7498fe20dc8fa86e3961175d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
31 #include <com/sun/star/presentation/FadeEffect.hpp>
33 #include <svx/dialogs.hrc>
35 #include "sdattr.hxx"
36 #include "strings.hrc"
38 #define _SD_DIACTRL_CXX
39 #include "diactrl.hxx"
41 #include "sdresid.hxx"
42 #include "app.hrc"
43 #include "res_bmp.hrc"
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <sfx2/app.hxx>
48 using namespace ::com::sun::star;
50 SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages, SfxUInt16Item )
53 //========================================================================
54 // SdPagesField
55 //========================================================================
57 SdPagesField::SdPagesField( Window* pParent,
58 const uno::Reference< frame::XFrame >& rFrame,
59 WinBits nBits ) :
60 SvxMetricField ( pParent, rFrame, nBits ),
61 m_xFrame ( rFrame )
63 String aStr( SdResId( STR_SLIDE_PLURAL ) );
64 SetCustomUnitText( aStr );
66 // Groesse setzen
67 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
68 Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 );
71 SetSizePixel( aSize );
73 // Parameter des MetricFields setzen
74 SetUnit( FUNIT_CUSTOM );
75 SetMin( 1 );
76 SetFirst( 1 );
77 SetMax( 15 );
78 SetLast( 15 );
79 SetSpinSize( 1 );
80 SetDecimalDigits( 0 );
81 Show();
84 // -----------------------------------------------------------------------
86 SdPagesField::~SdPagesField()
90 // -----------------------------------------------------------------------
92 void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
94 if( pItem )
96 long nValue = (long) pItem->GetValue();
97 SetValue( nValue );
98 if( nValue == 1 )
99 SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) );
100 else
101 SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) );
103 else
104 SetText( String() );
107 // -----------------------------------------------------------------------
109 void SdPagesField::Modify()
111 SfxUInt16Item aItem( SID_PAGES_PER_ROW, (UINT16) GetValue() );
113 ::uno::Any a;
114 ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
115 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagesPerRow" ));
116 aItem.QueryValue( a );
117 aArgs[0].Value = a;
118 SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
119 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PagesPerRow" )),
120 aArgs );
122 rBindings.GetDispatcher()->Execute(
123 SID_PAGES_PER_ROW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L, 0L );
127 /*************************************************************************
129 |* SdTbxCtlDiaPages
131 \************************************************************************/
133 SdTbxCtlDiaPages::SdTbxCtlDiaPages( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
134 SfxToolBoxControl( nSlotId, nId, rTbx )
138 //========================================================================
140 SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
144 //========================================================================
146 void SdTbxCtlDiaPages::StateChanged( USHORT,
147 SfxItemState eState, const SfxPoolItem* pState )
149 SdPagesField* pFld = (SdPagesField*) GetToolBox().GetItemWindow( GetId() );
150 DBG_ASSERT( pFld, "Window not found" );
152 if ( eState == SFX_ITEM_DISABLED )
154 pFld->Disable();
155 pFld->SetText( String() );
157 else
159 pFld->Enable();
161 const SfxUInt16Item* pItem = 0;
162 if ( eState == SFX_ITEM_AVAILABLE )
164 pItem = dynamic_cast< const SfxUInt16Item* >( pState );
165 DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
168 pFld->UpdatePagesField( pItem );
172 //========================================================================
174 Window* SdTbxCtlDiaPages::CreateItemWindow( Window* pParent )
176 return new SdPagesField( pParent, m_xFrame );
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */