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 <avmedia/mediatoolbox.hxx>
21 #include <avmedia/mediaitem.hxx>
22 #include <mediacontrol.hxx>
24 #include <tools/debug.hxx>
25 #include <sfx2/sfxsids.hrc>
26 #include <vcl/toolbox.hxx>
28 #include <comphelper/propertysequence.hxx>
30 using namespace ::com::sun::star
;
35 class MediaToolBoxControl_Impl
: public MediaControl
39 MediaToolBoxControl_Impl( vcl::Window
& rParent
, MediaToolBoxControl
& rControl
);
41 void update() override
;
42 void execute( const MediaItem
& rItem
) override
;
46 MediaToolBoxControl
* mpToolBoxControl
;
49 MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( vcl::Window
& rParent
, MediaToolBoxControl
& rControl
) :
50 MediaControl( &rParent
, MediaControlStyle::SingleLine
),
51 mpToolBoxControl( &rControl
)
53 SetSizePixel(m_xContainer
->get_preferred_size());
56 void MediaToolBoxControl_Impl::update()
58 mpToolBoxControl
->implUpdateMediaControl();
62 void MediaToolBoxControl_Impl::execute( const MediaItem
& rItem
)
64 mpToolBoxControl
->implExecuteMediaControl( rItem
);
68 SFX_IMPL_TOOLBOX_CONTROL( MediaToolBoxControl
, ::avmedia::MediaItem
);
71 MediaToolBoxControl::MediaToolBoxControl( sal_uInt16 nSlotId
, ToolBoxItemId nId
, ToolBox
& rTbx
) :
72 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
78 MediaToolBoxControl::~MediaToolBoxControl()
83 void MediaToolBoxControl::StateChangedAtToolBoxControl( sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
85 MediaToolBoxControl_Impl
* pCtrl
= static_cast< MediaToolBoxControl_Impl
* >( GetToolBox().GetItemWindow( GetId() ) );
87 DBG_ASSERT( pCtrl
, "MediaToolBoxControl::StateChanged: media control not found" );
89 if( eState
== SfxItemState::DISABLED
)
91 pCtrl
->Enable( false, false );
92 pCtrl
->SetText( OUString() );
94 const MediaItem
aEmptyMediaItem( 0, AVMediaSetMask::ALL
);
95 pCtrl
->setState( aEmptyMediaItem
);
99 pCtrl
->Enable( true, false );
101 const MediaItem
* pMediaItem
= dynamic_cast<const MediaItem
*>( pState
);
103 if( pMediaItem
&& ( eState
== SfxItemState::DEFAULT
) )
104 pCtrl
->setState( *pMediaItem
);
108 VclPtr
<InterimItemWindow
> MediaToolBoxControl::CreateItemWindow( vcl::Window
*pParent
)
110 return ( pParent
? VclPtr
<MediaToolBoxControl_Impl
>::Create( *pParent
, *this ) : nullptr );
113 void MediaToolBoxControl::implUpdateMediaControl()
115 updateStatus( u
".uno:AVMediaToolBox"_ustr
);
118 void MediaToolBoxControl::implExecuteMediaControl( const MediaItem
& rItem
)
120 MediaItem
aExecItem( SID_AVMEDIA_TOOLBOX
);
123 aExecItem
.merge( rItem
);
124 aExecItem
.QueryValue( aAny
);
125 auto aArgs(::comphelper::InitPropertySequence({
126 { "AVMediaToolBox", aAny
}
129 Dispatch( u
".uno:AVMediaToolBox"_ustr
, aArgs
);
132 } // namespace avmedia
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */