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