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