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: mediatoolbox.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 #include <avmedia/mediatoolbox.hxx>
32 #include <avmedia/mediaitem.hxx>
33 #include "mediacontrol.hxx"
35 #include <sfx2/app.hxx>
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/sfxsids.hrc>
40 using namespace ::com::sun::star
;
45 // -----------------------
46 // - MediaToolboxControl -
47 // -----------------------
49 class MediaToolBoxControl_Impl
: public MediaControl
53 MediaToolBoxControl_Impl( Window
& rParent
, MediaToolBoxControl
& rControl
);
54 ~MediaToolBoxControl_Impl();
57 void execute( const MediaItem
& rItem
);
61 MediaToolBoxControl
* mpToolBoxControl
;
64 // ---------------------------------------------------------------------
66 MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( Window
& rParent
, MediaToolBoxControl
& rControl
) :
67 MediaControl( &rParent
, MEDIACONTROLSTYLE_SINGLELINE
),
68 mpToolBoxControl( &rControl
)
70 SetSizePixel( getMinSizePixel() );
73 // ---------------------------------------------------------------------
75 MediaToolBoxControl_Impl::~MediaToolBoxControl_Impl()
79 // ---------------------------------------------------------------------
81 void MediaToolBoxControl_Impl::update()
83 mpToolBoxControl
->implUpdateMediaControl();
86 // ---------------------------------------------------------------------
88 void MediaToolBoxControl_Impl::execute( const MediaItem
& rItem
)
90 mpToolBoxControl
->implExecuteMediaControl( rItem
);
93 // -----------------------
94 // - MediaToolBoxControl -
95 // -----------------------
97 SFX_IMPL_TOOLBOX_CONTROL( ::avmedia::MediaToolBoxControl
, ::avmedia::MediaItem
);
99 // -----------------------------------------------------------------------------
101 MediaToolBoxControl::MediaToolBoxControl( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
) :
102 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
107 // -----------------------------------------------------------------------------
109 MediaToolBoxControl::~MediaToolBoxControl()
113 // -----------------------------------------------------------------------------
115 void MediaToolBoxControl::StateChanged( USHORT
/* nSID */, SfxItemState eState
, const SfxPoolItem
* pState
)
118 MediaToolBoxControl_Impl
* pCtrl
= static_cast< MediaToolBoxControl_Impl
* >( GetToolBox().GetItemWindow( GetId() ) );
120 DBG_ASSERT( pCtrl
, "MediaToolBoxControl::StateChanged: media control not found" );
122 if( eState
== SFX_ITEM_DISABLED
)
124 pCtrl
->Enable( false, false );
125 pCtrl
->SetText( String() );
127 const MediaItem
aEmptyMediaItem( 0, AVMEDIA_SETMASK_ALL
);
128 pCtrl
->setState( aEmptyMediaItem
);
132 pCtrl
->Enable( true, false );
134 const MediaItem
* pMediaItem
= PTR_CAST( MediaItem
, pState
);
136 if( pMediaItem
&& ( SFX_ITEM_AVAILABLE
== eState
) )
137 pCtrl
->setState( *pMediaItem
);
141 // -----------------------------------------------------------------------------
143 Window
* MediaToolBoxControl::CreateItemWindow( Window
*pParent
)
145 return( pParent
? new MediaToolBoxControl_Impl( *pParent
, *this ) : NULL
);
148 // -----------------------------------------------------------------------------
150 void MediaToolBoxControl::implUpdateMediaControl()
152 updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AVMediaToolBox" ) ) );
155 // -----------------------------------------------------------------------------
157 void MediaToolBoxControl::implExecuteMediaControl( const MediaItem
& rItem
)
159 MediaItem
aExecItem( SID_AVMEDIA_TOOLBOX
);
160 uno::Sequence
< beans::PropertyValue
> aArgs( 1 );
163 aExecItem
.merge( rItem
);
164 aExecItem
.QueryValue( aAny
);
165 aArgs
[ 0 ].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AVMediaToolBox" ) );
166 aArgs
[ 0 ].Value
= aAny
;
168 Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AVMediaToolBox" ) ), aArgs
);