LibreOffice Module avmedia (master) 1
mediatoolbox.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <avmedia/mediaitem.hxx>
22#include <mediacontrol.hxx>
23
24#include <tools/debug.hxx>
25#include <sfx2/sfxsids.hrc>
26#include <vcl/toolbox.hxx>
27
29
30using namespace ::com::sun::star;
31
32namespace avmedia
33{
34
36{
37public:
38
40
41 void update() override;
42 void execute( const MediaItem& rItem ) override;
43
44private:
45
47};
48
51 mpToolBoxControl( &rControl )
52{
53 SetSizePixel(m_xContainer->get_preferred_size());
54}
55
57{
59}
60
61
63{
65}
66
67
69
70
72 SfxToolBoxControl( nSlotId, nId, rTbx )
73{
74 rTbx.Invalidate();
75}
76
77
79{
80}
81
82
84{
86
87 DBG_ASSERT( pCtrl, "MediaToolBoxControl::StateChanged: media control not found" );
88
89 if( eState == SfxItemState::DISABLED )
90 {
91 pCtrl->Enable( false, false );
92 pCtrl->SetText( OUString() );
93
94 const MediaItem aEmptyMediaItem( 0, AVMediaSetMask::ALL );
95 pCtrl->setState( aEmptyMediaItem );
96 }
97 else
98 {
99 pCtrl->Enable( true, false );
100
101 const MediaItem* pMediaItem = dynamic_cast<const MediaItem*>( pState );
102
103 if( pMediaItem && ( eState == SfxItemState::DEFAULT ) )
104 pCtrl->setState( *pMediaItem );
105 }
106}
107
109{
110 return ( pParent ? VclPtr<MediaToolBoxControl_Impl>::Create( *pParent, *this ) : nullptr );
111}
112
114{
115 updateStatus( ".uno:AVMediaToolBox" );
116}
117
119{
120 MediaItem aExecItem( SID_AVMEDIA_TOOLBOX );
121 uno::Any aAny;
122
123 aExecItem.merge( rItem );
124 aExecItem.QueryValue( aAny );
125 auto aArgs(::comphelper::InitPropertySequence({
126 { "AVMediaToolBox", aAny }
127 }));
128
129 Dispatch( ".uno:AVMediaToolBox" , aArgs );
130}
131
132} // namespace avmedia
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SetText(const OUString &rStr) override
std::unique_ptr< weld::Container > m_xContainer
void Dispatch(const OUString &aCommand, css::uno::Sequence< css::beans::PropertyValue > const &aArgs)
ToolBoxItemId GetId() const
ToolBox & GetToolBox() const
vcl::Window * GetItemWindow(ToolBoxItemId nItemId) const
void setState(const MediaItem &rItem)
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: mediaitem.cxx:138
bool merge(const MediaItem &rMediaItem)
Definition: mediaitem.cxx:185
void execute(const MediaItem &rItem) override
MediaToolBoxControl * mpToolBoxControl
MediaToolBoxControl_Impl(vcl::Window &rParent, MediaToolBoxControl &rControl)
MediaToolBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbX)
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
AVMEDIA_DLLPRIVATE void implExecuteMediaControl(const MediaItem &rItem)
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
AVMEDIA_DLLPRIVATE void implUpdateMediaControl()
virtual ~MediaToolBoxControl() override
virtual void SetSizePixel(const Size &rNewSize)
void Enable(bool bEnable=true, bool bChild=true)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
#define DBG_ASSERT(sCon, aError)
SFX_IMPL_TOOLBOX_CONTROL(MediaToolBoxControl, ::avmedia::MediaItem)
sal_Int16 nId
SfxItemState