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