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