/src/libreoffice/avmedia/source/framework/mediatoolbox.cxx
Line | Count | Source |
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 | | |
20 | | #include <avmedia/mediatoolbox.hxx> |
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 | | #include <vcl/weld/Container.hxx> |
28 | | |
29 | | #include <comphelper/propertysequence.hxx> |
30 | | |
31 | | using namespace ::com::sun::star; |
32 | | |
33 | | namespace avmedia |
34 | | { |
35 | | |
36 | | class MediaToolBoxControl_Impl : public MediaControl |
37 | | { |
38 | | public: |
39 | | |
40 | | MediaToolBoxControl_Impl( vcl::Window& rParent, MediaToolBoxControl& rControl ); |
41 | | |
42 | | void update() override; |
43 | | void execute( const MediaItem& rItem ) override; |
44 | | |
45 | | private: |
46 | | |
47 | | MediaToolBoxControl* mpToolBoxControl; |
48 | | }; |
49 | | |
50 | | MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( vcl::Window& rParent, MediaToolBoxControl& rControl ) : |
51 | 0 | MediaControl( &rParent, MediaControlStyle::SingleLine ), |
52 | 0 | mpToolBoxControl( &rControl ) |
53 | 0 | { |
54 | 0 | SetSizePixel(m_xContainer->get_preferred_size()); |
55 | 0 | } Unexecuted instantiation: avmedia::MediaToolBoxControl_Impl::MediaToolBoxControl_Impl(vcl::Window&, avmedia::MediaToolBoxControl&) Unexecuted instantiation: avmedia::MediaToolBoxControl_Impl::MediaToolBoxControl_Impl(vcl::Window&, avmedia::MediaToolBoxControl&) |
56 | | |
57 | | void MediaToolBoxControl_Impl::update() |
58 | 0 | { |
59 | 0 | mpToolBoxControl->implUpdateMediaControl(); |
60 | 0 | } |
61 | | |
62 | | |
63 | | void MediaToolBoxControl_Impl::execute( const MediaItem& rItem ) |
64 | 0 | { |
65 | 0 | mpToolBoxControl->implExecuteMediaControl( rItem ); |
66 | 0 | } |
67 | | |
68 | | |
69 | | SFX_IMPL_TOOLBOX_CONTROL( MediaToolBoxControl, ::avmedia::MediaItem ); |
70 | | |
71 | | |
72 | | MediaToolBoxControl::MediaToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
73 | 0 | SfxToolBoxControl( nSlotId, nId, rTbx ) |
74 | 0 | { |
75 | 0 | rTbx.Invalidate(); |
76 | 0 | } Unexecuted instantiation: avmedia::MediaToolBoxControl::MediaToolBoxControl(unsigned short, o3tl::strong_int<unsigned short, ToolBoxItemIdTag>, ToolBox&) Unexecuted instantiation: avmedia::MediaToolBoxControl::MediaToolBoxControl(unsigned short, o3tl::strong_int<unsigned short, ToolBoxItemIdTag>, ToolBox&) |
77 | | |
78 | | |
79 | | MediaToolBoxControl::~MediaToolBoxControl() |
80 | 0 | { |
81 | 0 | } |
82 | | |
83 | | |
84 | | void MediaToolBoxControl::StateChangedAtToolBoxControl( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) |
85 | 0 | { |
86 | 0 | MediaToolBoxControl_Impl* pCtrl = static_cast< MediaToolBoxControl_Impl* >( GetToolBox().GetItemWindow( GetId() ) ); |
87 | |
|
88 | 0 | DBG_ASSERT( pCtrl, "MediaToolBoxControl::StateChanged: media control not found" ); |
89 | |
|
90 | 0 | if( eState == SfxItemState::DISABLED ) |
91 | 0 | { |
92 | 0 | pCtrl->Enable( false, false ); |
93 | 0 | pCtrl->SetText( OUString() ); |
94 | |
|
95 | 0 | const MediaItem aEmptyMediaItem( 0, AVMediaSetMask::ALL ); |
96 | 0 | pCtrl->setState( aEmptyMediaItem ); |
97 | 0 | } |
98 | 0 | else |
99 | 0 | { |
100 | 0 | pCtrl->Enable( true, false ); |
101 | |
|
102 | 0 | const MediaItem* pMediaItem = dynamic_cast<const MediaItem*>( pState ); |
103 | |
|
104 | 0 | if( pMediaItem && ( eState == SfxItemState::DEFAULT ) ) |
105 | 0 | pCtrl->setState( *pMediaItem ); |
106 | 0 | } |
107 | 0 | } |
108 | | |
109 | | VclPtr<InterimItemWindow> MediaToolBoxControl::CreateItemWindow( vcl::Window *pParent ) |
110 | 0 | { |
111 | 0 | return ( pParent ? VclPtr<MediaToolBoxControl_Impl>::Create( *pParent, *this ) : nullptr ); |
112 | 0 | } |
113 | | |
114 | | void MediaToolBoxControl::implUpdateMediaControl() |
115 | 0 | { |
116 | 0 | updateStatus( u".uno:AVMediaToolBox"_ustr ); |
117 | 0 | } |
118 | | |
119 | | void MediaToolBoxControl::implExecuteMediaControl( const MediaItem& rItem ) |
120 | 0 | { |
121 | 0 | MediaItem aExecItem( SID_AVMEDIA_TOOLBOX ); |
122 | 0 | uno::Any aAny; |
123 | |
|
124 | 0 | aExecItem.merge( rItem ); |
125 | 0 | aExecItem.QueryValue( aAny ); |
126 | 0 | auto aArgs(::comphelper::InitPropertySequence({ |
127 | 0 | { "AVMediaToolBox", aAny } |
128 | 0 | })); |
129 | |
|
130 | 0 | Dispatch( u".uno:AVMediaToolBox"_ustr , aArgs ); |
131 | 0 | } |
132 | | |
133 | | } // namespace avmedia |
134 | | |
135 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |