Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <sfx2/app.hxx>
31 : : #include <sfx2/objface.hxx>
32 : : #include <sfx2/request.hxx>
33 : : #include <avmedia/mediaitem.hxx>
34 : : #include <svl/whiter.hxx>
35 : : #include <svx/svdomedia.hxx>
36 : : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
37 : :
38 : : #include "mediash.hxx"
39 : : #include "sc.hrc"
40 : : #include "viewdata.hxx"
41 : : #include "drawview.hxx"
42 : : #include "scresid.hxx"
43 : :
44 : : #define ScMediaShell
45 : : #include "scslots.hxx"
46 : :
47 : : #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
48 : :
49 : :
50 [ + + ][ + - ]: 204 : SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
[ + - ][ + - ]
51 : : {
52 [ + - ][ + - ]: 51 : SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, ScResId(RID_MEDIA_OBJECTBAR) );
53 [ + - ][ + - ]: 51 : SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_MEDIA) );
54 : 51 : }
55 : :
56 [ # # ][ # # ]: 0 : TYPEINIT1( ScMediaShell, ScDrawShell );
57 : :
58 : 0 : ScMediaShell::ScMediaShell(ScViewData* pData) :
59 : 0 : ScDrawShell(pData)
60 : : {
61 [ # # ]: 0 : SetHelpId(HID_SCSHELL_MEDIA);
62 [ # # ][ # # ]: 0 : SetName( String( ScResId( SCSTR_MEDIASHELL ) ) );
[ # # ][ # # ]
63 : 0 : }
64 : :
65 : 0 : ScMediaShell::~ScMediaShell()
66 : : {
67 [ # # ]: 0 : }
68 : :
69 : 0 : void ScMediaShell::GetMediaState( SfxItemSet& rSet )
70 : : {
71 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
72 : :
73 [ # # ]: 0 : if( pView )
74 : : {
75 [ # # ]: 0 : SfxWhichIter aIter( rSet );
76 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
77 : :
78 [ # # ]: 0 : while( nWhich )
79 : : {
80 [ # # ]: 0 : if( SID_AVMEDIA_TOOLBOX == nWhich )
81 : : {
82 [ # # ][ # # ]: 0 : SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
83 : 0 : bool bDisable = true;
84 : :
85 [ # # ]: 0 : if( 1 == pMarkList->GetMarkCount() )
86 : : {
87 [ # # ][ # # ]: 0 : SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
88 : :
89 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrMediaObj ) )
[ # # ][ # # ]
[ # # ]
90 : : {
91 [ # # ]: 0 : ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
92 : :
93 [ # # ][ # # ]: 0 : static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
94 [ # # ]: 0 : rSet.Put( aItem );
95 [ # # ]: 0 : bDisable = false;
96 : : }
97 : : }
98 : :
99 [ # # ]: 0 : if( bDisable )
100 [ # # ]: 0 : rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
101 : :
102 [ # # ][ # # ]: 0 : delete pMarkList;
103 : : }
104 : :
105 [ # # ]: 0 : nWhich = aIter.NextWhich();
106 [ # # ]: 0 : }
107 : : }
108 : 0 : }
109 : :
110 : 0 : void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
111 : : {
112 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
113 : :
114 [ # # ][ # # ]: 0 : if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
[ # # ]
115 : : {
116 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
117 : : const SfxPoolItem* pItem;
118 : :
119 [ # # ][ # # ]: 0 : if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
[ # # ][ # # ]
120 : 0 : pItem = NULL;
121 : :
122 [ # # ]: 0 : if( pItem )
123 : : {
124 [ # # ][ # # ]: 0 : SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
125 : :
126 [ # # ]: 0 : if( 1 == pMarkList->GetMarkCount() )
127 : : {
128 [ # # ][ # # ]: 0 : SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
129 : :
130 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrMediaObj ) )
[ # # ][ # # ]
[ # # ]
131 : : {
132 [ # # ]: 0 : static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
133 [ # # ]: 0 : static_cast< const ::avmedia::MediaItem& >( *pItem ) );
134 : : }
135 : :
136 [ # # ][ # # ]: 0 : delete pMarkList;
137 : : }
138 : : }
139 : : }
140 : :
141 : 0 : Invalidate();
142 : 0 : }
143 : :
144 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|