1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: diactrl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/presentation/FadeEffect.hpp>
35 #include <svx/dialogs.hrc>
38 #include "strings.hrc"
40 #define _SD_DIACTRL_CXX
41 #include "diactrl.hxx"
43 #include "sdresid.hxx"
45 #include "res_bmp.hrc"
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/viewfrm.hxx>
48 #include <sfx2/app.hxx>
50 using namespace ::com::sun::star
;
52 SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages
, SfxUInt16Item
)
55 //========================================================================
57 //========================================================================
59 SdPagesField::SdPagesField( Window
* pParent
,
60 const uno::Reference
< frame::XFrame
>& rFrame
,
62 SvxMetricField ( pParent
, rFrame
, nBits
),
65 String
aStr( SdResId( STR_SLIDE_PLURAL
) );
66 SetCustomUnitText( aStr
);
69 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
70 Size
aSize( GetTextWidth( aStr
)+20, GetTextHeight()+6 );
73 SetSizePixel( aSize
);
75 // Parameter des MetricFields setzen
76 SetUnit( FUNIT_CUSTOM
);
82 SetDecimalDigits( 0 );
86 // -----------------------------------------------------------------------
88 SdPagesField::~SdPagesField()
92 // -----------------------------------------------------------------------
94 void SdPagesField::UpdatePagesField( const SfxUInt16Item
* pItem
)
98 long nValue
= (long) pItem
->GetValue();
101 SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR
) ) );
103 SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL
) ) );
109 // -----------------------------------------------------------------------
111 void SdPagesField::Modify()
113 SfxUInt16Item
aItem( SID_PAGES_PER_ROW
, (UINT16
) GetValue() );
116 ::uno::Sequence
< ::beans::PropertyValue
> aArgs( 1 );
117 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagesPerRow" ));
118 aItem
.QueryValue( a
);
120 SfxToolBoxControl::Dispatch( ::uno::Reference
< ::frame::XDispatchProvider
>( m_xFrame
->getController(), ::uno::UNO_QUERY
),
121 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PagesPerRow" )),
124 rBindings.GetDispatcher()->Execute(
125 SID_PAGES_PER_ROW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L, 0L );
129 /*************************************************************************
133 \************************************************************************/
135 SdTbxCtlDiaPages::SdTbxCtlDiaPages( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
) :
136 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
140 //========================================================================
142 SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
146 //========================================================================
148 void SdTbxCtlDiaPages::StateChanged( USHORT
,
149 SfxItemState eState
, const SfxPoolItem
* pState
)
151 SdPagesField
* pFld
= (SdPagesField
*) GetToolBox().GetItemWindow( GetId() );
152 DBG_ASSERT( pFld
, "Window not found" );
154 if ( eState
== SFX_ITEM_DISABLED
)
157 pFld
->SetText( String() );
163 const SfxUInt16Item
* pItem
= 0;
164 if ( eState
== SFX_ITEM_AVAILABLE
)
166 pItem
= dynamic_cast< const SfxUInt16Item
* >( pState
);
167 DBG_ASSERT( pItem
, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
170 pFld
->UpdatePagesField( pItem
);
174 //========================================================================
176 Window
* SdTbxCtlDiaPages::CreateItemWindow( Window
* pParent
)
178 return new SdPagesField( pParent
, m_xFrame
);