1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/presentation/FadeEffect.hpp>
22 #include <svx/dialogs.hrc>
25 #include "strings.hrc"
27 #include "diactrl.hxx"
29 #include "sdresid.hxx"
31 #include "res_bmp.hrc"
32 #include <sfx2/dispatch.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #include <sfx2/app.hxx>
36 using namespace ::com::sun::star
;
38 SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages
, SfxUInt16Item
)
41 //========================================================================
43 //========================================================================
45 SdPagesField::SdPagesField( Window
* pParent
,
46 const uno::Reference
< frame::XFrame
>& rFrame
,
48 SvxMetricField ( pParent
, rFrame
, nBits
),
51 String
aStr( SdResId( STR_SLIDE_PLURAL
) );
52 SetCustomUnitText( aStr
);
55 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
56 Size
aSize( GetTextWidth( aStr
)+20, GetTextHeight()+6 );
59 SetSizePixel( aSize
);
61 // set parameter of MetricFields
62 SetUnit( FUNIT_CUSTOM
);
68 SetDecimalDigits( 0 );
72 // -----------------------------------------------------------------------
74 SdPagesField::~SdPagesField()
78 // -----------------------------------------------------------------------
80 void SdPagesField::UpdatePagesField( const SfxUInt16Item
* pItem
)
84 long nValue
= (long) pItem
->GetValue();
87 SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR
) ) );
89 SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL
) ) );
95 // -----------------------------------------------------------------------
97 void SdPagesField::Modify()
99 SfxUInt16Item
aItem( SID_PAGES_PER_ROW
, (sal_uInt16
) GetValue() );
102 ::uno::Sequence
< ::beans::PropertyValue
> aArgs( 1 );
103 aArgs
[0].Name
= "PagesPerRow";
104 aItem
.QueryValue( a
);
106 SfxToolBoxControl::Dispatch( ::uno::Reference
< ::frame::XDispatchProvider
>( m_xFrame
->getController(), ::uno::UNO_QUERY
),
111 SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
112 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
116 //========================================================================
118 SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
122 //========================================================================
124 void SdTbxCtlDiaPages::StateChanged( sal_uInt16
,
125 SfxItemState eState
, const SfxPoolItem
* pState
)
127 SdPagesField
* pFld
= (SdPagesField
*) GetToolBox().GetItemWindow( GetId() );
128 DBG_ASSERT( pFld
, "Window not found" );
130 if ( eState
== SFX_ITEM_DISABLED
)
133 pFld
->SetText( String() );
139 const SfxUInt16Item
* pItem
= 0;
140 if ( eState
== SFX_ITEM_AVAILABLE
)
142 pItem
= dynamic_cast< const SfxUInt16Item
* >( pState
);
143 DBG_ASSERT( pItem
, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
146 pFld
->UpdatePagesField( pItem
);
150 //========================================================================
152 Window
* SdTbxCtlDiaPages::CreateItemWindow( Window
* pParent
)
154 return new SdPagesField( pParent
, m_xFrame
);
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */