1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26
27
28
29 // INCLUDE ---------------------------------------------------------------
30
31 #include <svx/svdmark.hxx>
32 #include <svx/svdview.hxx>
33 #include <svx/galbrws.hxx>
34 #include <svx/gallery.hxx>
35 #include <svx/hlnkitem.hxx>
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/request.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <svl/whiter.hxx>
41 #include <avmedia/mediaplayer.hxx>
42
43 #include "tabvwsh.hxx"
44 #include "viewdata.hxx"
45 #include "tabview.hxx"
46 #include "drwlayer.hxx"
47 #include "userdat.hxx"
48 #include "docsh.hxx"
49
50 #include <svx/galleryitem.hxx>
51 #include <com/sun/star/gallery/GalleryItemType.hpp>
52
53 // forwards -> imapwrap.cxx (wg. CLOOKs)
54
55 class SvxIMapDlg;
56
57 sal_uInt16 ScIMapChildWindowId();
58 SvxIMapDlg* ScGetIMapDlg();
59 const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg );
60 const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg );
61
62 //------------------------------------------------------------------
63
ExecChildWin(SfxRequest & rReq)64 void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
65 {
66 sal_uInt16 nSlot = rReq.GetSlot();
67 switch(nSlot)
68 {
69 case SID_GALLERY:
70 {
71 SfxViewFrame* pThisFrame = GetViewFrame();
72 pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
73 pThisFrame->GetBindings().Invalidate( SID_GALLERY );
74 rReq.Ignore();
75 }
76 break;
77
78 case SID_AVMEDIA_PLAYER:
79 {
80 SfxViewFrame* pThisFrame = GetViewFrame();
81 pThisFrame->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() );
82 pThisFrame->GetBindings().Invalidate( SID_AVMEDIA_PLAYER );
83 rReq.Ignore();
84 }
85 break;
86 }
87 }
88
GetChildWinState(SfxItemSet & rSet)89 void ScTabViewShell::GetChildWinState( SfxItemSet& rSet )
90 {
91 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
92 {
93 sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
94 rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
95 }
96 else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
97 {
98 sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId();
99 rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
100 }
101 }
102
103 //------------------------------------------------------------------
104
ExecGallery(SfxRequest & rReq)105 void ScTabViewShell::ExecGallery( SfxRequest& rReq )
106 {
107 const SfxItemSet* pArgs = rReq.GetArgs();
108
109 SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
110 if ( !pGalleryItem )
111 return;
112
113 sal_Int8 nType( pGalleryItem->GetType() );
114 if ( nType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
115 {
116 MakeDrawLayer();
117
118 Graphic aGraphic( pGalleryItem->GetGraphic() );
119 Point aPos = GetInsertPos();
120
121 String aPath, aFilter;
122 if ( pGalleryItem->IsLink() ) // als Link einfuegen?
123 {
124 aPath = pGalleryItem->GetURL();
125 aFilter = pGalleryItem->GetFilterName();
126 }
127
128 PasteGraphic( aPos, aGraphic, aPath, aFilter );
129 }
130 else if ( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
131 {
132 // #98115# for sounds (linked or not), insert a hyperlink button,
133 // like in Impress and Writer
134 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
135 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
136 }
137 }
138
GetGalleryState(SfxItemSet &)139 void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ )
140 {
141 }
142
143 //------------------------------------------------------------------
144
GetInputHandler() const145 ScInputHandler* ScTabViewShell::GetInputHandler() const
146 {
147 return pInputHandler;
148 }
149
150 //------------------------------------------------------------------
151
GetDescription() const152 String __EXPORT ScTabViewShell::GetDescription() const
153 {
154 return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** "));
155 }
156
ExecImageMap(SfxRequest & rReq)157 void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
158 {
159 sal_uInt16 nSlot = rReq.GetSlot();
160 switch(nSlot)
161 {
162 case SID_IMAP:
163 {
164 SfxViewFrame* pThisFrame = GetViewFrame();
165 sal_uInt16 nId = ScIMapChildWindowId();
166 pThisFrame->ToggleChildWindow( nId );
167 GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
168
169 if ( pThisFrame->HasChildWindow( nId ) )
170 {
171 SvxIMapDlg* pDlg = ScGetIMapDlg();
172 if ( pDlg )
173 {
174 SdrView* pDrView = GetSdrView();
175 if ( pDrView )
176 {
177 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
178 if ( rMarkList.GetMarkCount() == 1 )
179 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
180 }
181 }
182 }
183
184 rReq.Ignore();
185 }
186 break;
187
188 case SID_IMAP_EXEC:
189 {
190 SdrView* pDrView = GetSdrView();
191 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
192
193 if ( pMark )
194 {
195 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
196 SvxIMapDlg* pDlg = ScGetIMapDlg();
197
198 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
199 {
200 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
201 ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
202
203 if ( !pIMapInfo )
204 pSdrObj->InsertUserData( new ScIMapInfo( rImageMap ) );
205 else
206 pIMapInfo->SetImageMap( rImageMap );
207
208 GetViewData()->GetDocShell()->SetDrawModified();
209 }
210 }
211 }
212 break;
213 }
214 }
215
GetImageMapState(SfxItemSet & rSet)216 void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
217 {
218 SfxWhichIter aIter(rSet);
219 sal_uInt16 nWhich = aIter.FirstWhich();
220 while ( nWhich )
221 {
222 switch ( nWhich )
223 {
224 case SID_IMAP:
225 {
226 // Disabled wird nicht mehr...
227
228 sal_Bool bThere = sal_False;
229 SfxViewFrame* pThisFrame = GetViewFrame();
230 sal_uInt16 nId = ScIMapChildWindowId();
231 if ( pThisFrame->KnowsChildWindow(nId) )
232 if ( pThisFrame->HasChildWindow(nId) )
233 bThere = sal_True;
234
235 ObjectSelectionType eType=GetCurObjectSelectionType();
236 sal_Bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
237 if(!bThere && !bEnable)
238 {
239 rSet.DisableItem( nWhich );
240 }
241 else
242 {
243 rSet.Put( SfxBoolItem( nWhich, bThere ) );
244 }
245 }
246 break;
247
248 case SID_IMAP_EXEC:
249 {
250 sal_Bool bDisable = sal_True;
251
252 SdrView* pDrView = GetSdrView();
253 if ( pDrView )
254 {
255 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
256 if ( rMarkList.GetMarkCount() == 1 )
257 if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
258 (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
259 bDisable = sal_False;
260 }
261
262 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
263 }
264 break;
265 }
266
267 nWhich = aIter.NextWhich();
268 }
269 }
270
271
272
273
274