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 "MediaObjectBar.hxx"
31 : : #include <avmedia/mediaitem.hxx>
32 : : #include <sfx2/msg.hxx>
33 : : #include <sfx2/app.hxx>
34 : : #include <sfx2/sfxsids.hrc>
35 : : #include <sfx2/request.hxx>
36 : : #include <sfx2/objface.hxx>
37 : : #include <svl/whiter.hxx>
38 : : #include <svl/itempool.hxx>
39 : : #include <svx/svdomedia.hxx>
40 : : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
41 : :
42 : : #include "app.hrc"
43 : : #include "res_bmp.hrc"
44 : : #include "glob.hrc"
45 : : #include "strings.hrc"
46 : : #include "DrawDocShell.hxx"
47 : : #include "ViewShell.hxx"
48 : : #include "Window.hxx"
49 : : #include "drawview.hxx"
50 : : #include "sdresid.hxx"
51 : : #include "drawdoc.hxx"
52 : :
53 : : using namespace sd;
54 : :
55 : : #define MediaObjectBar
56 : : #include "sdslots.hxx"
57 : :
58 : : namespace sd {
59 : :
60 : : // ------------------
61 : : // - MediaObjectBar -
62 : : // ------------------
63 : :
64 [ # # ][ # # ]: 0 : TYPEINIT1( MediaObjectBar, SfxShell );
65 : :
66 : : // -----------------------------------------------------------------------------
67 : :
68 [ + - ][ + - ]: 50 : SFX_IMPL_INTERFACE( MediaObjectBar, SfxShell, SdResId( STR_MEDIAOBJECTBARSHELL ) )
[ + - ]
69 : : {
70 : 25 : }
71 : :
72 : : // -----------------------------------------------------------------------------
73 : :
74 : 0 : MediaObjectBar::MediaObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView ) :
75 : : SfxShell( pSdViewShell->GetViewShell() ),
76 : : mpView( pSdView ),
77 : 0 : mpViewSh( pSdViewShell )
78 : : {
79 [ # # ]: 0 : DrawDocShell* pDocShell = mpViewSh->GetDocSh();
80 : :
81 : 0 : SetPool( &pDocShell->GetPool() );
82 [ # # ][ # # ]: 0 : SetUndoManager( pDocShell->GetUndoManager() );
83 [ # # ][ # # ]: 0 : SetRepeatTarget( mpView );
84 [ # # ]: 0 : SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR );
85 [ # # ][ # # ]: 0 : SetName( String( SdResId( RID_DRAW_MEDIA_TOOLBOX ) ) );
[ # # ][ # # ]
86 : 0 : }
87 : :
88 : : // -----------------------------------------------------------------------------
89 : :
90 : 0 : MediaObjectBar::~MediaObjectBar()
91 : : {
92 [ # # ]: 0 : SetRepeatTarget( NULL );
93 [ # # ]: 0 : }
94 : :
95 : : // -----------------------------------------------------------------------------
96 : :
97 : 0 : void MediaObjectBar::GetState( SfxItemSet& rSet )
98 : : {
99 [ # # ]: 0 : SfxWhichIter aIter( rSet );
100 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
101 : :
102 [ # # ]: 0 : while( nWhich )
103 : : {
104 [ # # ]: 0 : if( SID_AVMEDIA_TOOLBOX == nWhich )
105 : : {
106 [ # # ][ # # ]: 0 : SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() );
107 : 0 : bool bDisable = true;
108 : :
109 [ # # ]: 0 : if( 1 == pMarkList->GetMarkCount() )
110 : : {
111 [ # # ][ # # ]: 0 : SdrObject* pObj =pMarkList->GetMark( 0 )->GetMarkedSdrObj();
112 : :
113 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrMediaObj ) )
[ # # ][ # # ]
[ # # ]
114 : : {
115 [ # # ]: 0 : ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
116 : :
117 [ # # ][ # # ]: 0 : static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
118 [ # # ]: 0 : rSet.Put( aItem );
119 [ # # ]: 0 : bDisable = false;
120 : : }
121 : : }
122 : :
123 [ # # ]: 0 : if( bDisable )
124 [ # # ]: 0 : rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
125 : :
126 [ # # ][ # # ]: 0 : delete pMarkList;
127 : : }
128 : :
129 [ # # ]: 0 : nWhich = aIter.NextWhich();
130 [ # # ]: 0 : }
131 : 0 : }
132 : :
133 : : // -----------------------------------------------------------------------------
134 : :
135 : 0 : void MediaObjectBar::Execute( SfxRequest& rReq )
136 : : {
137 [ # # ]: 0 : if( SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
138 : : {
139 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
140 : : const SfxPoolItem* pItem;
141 : :
142 [ # # ][ # # ]: 0 : if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
[ # # ][ # # ]
143 : 0 : pItem = NULL;
144 : :
145 [ # # ]: 0 : if( pItem )
146 : : {
147 [ # # ][ # # ]: 0 : SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() );
148 : :
149 [ # # ]: 0 : if( 1 == pMarkList->GetMarkCount() )
150 : : {
151 [ # # ][ # # ]: 0 : SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
152 : :
153 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrMediaObj ) )
[ # # ][ # # ]
[ # # ]
154 : : {
155 [ # # ]: 0 : static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
156 [ # # ]: 0 : static_cast< const ::avmedia::MediaItem& >( *pItem ) );
157 : :
158 : : //fdo #32598: after changing playback opts, set document's modified flag
159 : 0 : SdDrawDocument& rDoc = mpView->GetDoc();
160 [ # # ]: 0 : rDoc.SetChanged(sal_True);
161 : : }
162 : : }
163 : :
164 [ # # ][ # # ]: 0 : delete pMarkList;
165 : : }
166 : : }
167 : 0 : }
168 : :
169 : : } // end of namespace sd
170 : :
171 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|