fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / diactrl.cxx
blob069dd4213b3a68a2f86332d838f637be4a14b64d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
24 #include "sdattr.hxx"
25 #include "strings.hrc"
27 #include "diactrl.hxx"
29 #include "sdresid.hxx"
30 #include "app.hrc"
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 //========================================================================
42 // SdPagesField
43 //========================================================================
45 SdPagesField::SdPagesField( Window* pParent,
46 const uno::Reference< frame::XFrame >& rFrame,
47 WinBits nBits ) :
48 SvxMetricField ( pParent, rFrame, nBits ),
49 m_xFrame ( rFrame )
51 String aStr( SdResId( STR_SLIDE_PLURAL ) );
52 SetCustomUnitText( aStr );
54 // set size
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 );
63 SetMin( 1 );
64 SetFirst( 1 );
65 SetMax( 15 );
66 SetLast( 15 );
67 SetSpinSize( 1 );
68 SetDecimalDigits( 0 );
69 Show();
72 // -----------------------------------------------------------------------
74 SdPagesField::~SdPagesField()
78 // -----------------------------------------------------------------------
80 void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
82 if( pItem )
84 long nValue = (long) pItem->GetValue();
85 SetValue( nValue );
86 if( nValue == 1 )
87 SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) );
88 else
89 SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) );
91 else
92 SetText( String() );
95 // -----------------------------------------------------------------------
97 void SdPagesField::Modify()
99 SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() );
101 ::uno::Any a;
102 ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
103 aArgs[0].Name = "PagesPerRow";
104 aItem.QueryValue( a );
105 aArgs[0].Value = a;
106 SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
107 ".uno:PagesPerRow",
108 aArgs );
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 )
132 pFld->Disable();
133 pFld->SetText( String() );
135 else
137 pFld->Enable();
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: */