1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include <com/sun/star/presentation/FadeEffect.hpp>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <svx/dialogs.hrc>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include "sdattr.hxx"
31cdf0e10cSrcweir #include "strings.hrc"
32cdf0e10cSrcweir
33cdf0e10cSrcweir #define _SD_DIACTRL_CXX
34cdf0e10cSrcweir #include "diactrl.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include "sdresid.hxx"
37cdf0e10cSrcweir #include "app.hrc"
38cdf0e10cSrcweir #include "res_bmp.hrc"
39cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
40cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
41cdf0e10cSrcweir #include <sfx2/app.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir using namespace ::com::sun::star;
44cdf0e10cSrcweir
SFX_IMPL_TOOLBOX_CONTROL(SdTbxCtlDiaPages,SfxUInt16Item)45cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages, SfxUInt16Item )
46cdf0e10cSrcweir
47cdf0e10cSrcweir
48cdf0e10cSrcweir //========================================================================
49cdf0e10cSrcweir // SdPagesField
50cdf0e10cSrcweir //========================================================================
51cdf0e10cSrcweir
52cdf0e10cSrcweir SdPagesField::SdPagesField( Window* pParent,
53cdf0e10cSrcweir const uno::Reference< frame::XFrame >& rFrame,
54cdf0e10cSrcweir WinBits nBits ) :
55cdf0e10cSrcweir SvxMetricField ( pParent, rFrame, nBits ),
56cdf0e10cSrcweir m_xFrame ( rFrame )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir String aStr( SdResId( STR_SLIDE_PLURAL ) );
59cdf0e10cSrcweir SetCustomUnitText( aStr );
60cdf0e10cSrcweir
61cdf0e10cSrcweir // Groesse setzen
62cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
63cdf0e10cSrcweir Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 );
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir SetSizePixel( aSize );
67cdf0e10cSrcweir
68cdf0e10cSrcweir // Parameter des MetricFields setzen
69cdf0e10cSrcweir SetUnit( FUNIT_CUSTOM );
70cdf0e10cSrcweir SetMin( 1 );
71cdf0e10cSrcweir SetFirst( 1 );
72cdf0e10cSrcweir SetMax( 15 );
73cdf0e10cSrcweir SetLast( 15 );
74cdf0e10cSrcweir SetSpinSize( 1 );
75cdf0e10cSrcweir SetDecimalDigits( 0 );
76cdf0e10cSrcweir Show();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir // -----------------------------------------------------------------------
80cdf0e10cSrcweir
~SdPagesField()81cdf0e10cSrcweir SdPagesField::~SdPagesField()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir // -----------------------------------------------------------------------
86cdf0e10cSrcweir
UpdatePagesField(const SfxUInt16Item * pItem)87cdf0e10cSrcweir void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir if( pItem )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir long nValue = (long) pItem->GetValue();
92cdf0e10cSrcweir SetValue( nValue );
93cdf0e10cSrcweir if( nValue == 1 )
94cdf0e10cSrcweir SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) );
95cdf0e10cSrcweir else
96cdf0e10cSrcweir SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) );
97cdf0e10cSrcweir }
98cdf0e10cSrcweir else
99cdf0e10cSrcweir SetText( String() );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir // -----------------------------------------------------------------------
103cdf0e10cSrcweir
Modify()104cdf0e10cSrcweir void SdPagesField::Modify()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() );
107cdf0e10cSrcweir
108cdf0e10cSrcweir ::uno::Any a;
109cdf0e10cSrcweir ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
110cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagesPerRow" ));
111cdf0e10cSrcweir aItem.QueryValue( a );
112cdf0e10cSrcweir aArgs[0].Value = a;
113cdf0e10cSrcweir SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
114cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PagesPerRow" )),
115cdf0e10cSrcweir aArgs );
116cdf0e10cSrcweir /*
117cdf0e10cSrcweir rBindings.GetDispatcher()->Execute(
118cdf0e10cSrcweir SID_PAGES_PER_ROW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L, 0L );
119cdf0e10cSrcweir */
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir /*************************************************************************
123cdf0e10cSrcweir |*
124cdf0e10cSrcweir |* SdTbxCtlDiaPages
125cdf0e10cSrcweir |*
126cdf0e10cSrcweir \************************************************************************/
127cdf0e10cSrcweir
SdTbxCtlDiaPages(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)128cdf0e10cSrcweir SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
129cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir //========================================================================
134cdf0e10cSrcweir
~SdTbxCtlDiaPages()135cdf0e10cSrcweir SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir }
138cdf0e10cSrcweir
139cdf0e10cSrcweir //========================================================================
140cdf0e10cSrcweir
StateChanged(sal_uInt16,SfxItemState eState,const SfxPoolItem * pState)141cdf0e10cSrcweir void SdTbxCtlDiaPages::StateChanged( sal_uInt16,
142cdf0e10cSrcweir SfxItemState eState, const SfxPoolItem* pState )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir SdPagesField* pFld = (SdPagesField*) GetToolBox().GetItemWindow( GetId() );
145cdf0e10cSrcweir DBG_ASSERT( pFld, "Window not found" );
146cdf0e10cSrcweir
147cdf0e10cSrcweir if ( eState == SFX_ITEM_DISABLED )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir pFld->Disable();
150cdf0e10cSrcweir pFld->SetText( String() );
151cdf0e10cSrcweir }
152cdf0e10cSrcweir else
153cdf0e10cSrcweir {
154cdf0e10cSrcweir pFld->Enable();
155cdf0e10cSrcweir
156cdf0e10cSrcweir const SfxUInt16Item* pItem = 0;
157cdf0e10cSrcweir if ( eState == SFX_ITEM_AVAILABLE )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir pItem = dynamic_cast< const SfxUInt16Item* >( pState );
160cdf0e10cSrcweir DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir pFld->UpdatePagesField( pItem );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir //========================================================================
168cdf0e10cSrcweir
CreateItemWindow(Window * pParent)169cdf0e10cSrcweir Window* SdTbxCtlDiaPages::CreateItemWindow( Window* pParent )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir return new SdPagesField( pParent, m_xFrame );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir
175cdf0e10cSrcweir
176