fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / tabvwsh9.cxx
blob05c25855b56d16579a19df209300662318b7a351
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/imapdlg.hxx>
21 #include <svx/svdmark.hxx>
22 #include <svx/svdview.hxx>
23 #include <svx/gallery.hxx>
24 #include <svx/hlnkitem.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/request.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <sfx2/sidebar/Sidebar.hxx>
30 #include <svl/whiter.hxx>
32 #include "imapwrap.hxx"
33 #include "tabvwsh.hxx"
34 #include "viewdata.hxx"
35 #include "tabview.hxx"
36 #include "drwlayer.hxx"
37 #include "userdat.hxx"
38 #include "docsh.hxx"
40 #include <svx/galleryitem.hxx>
41 #include <com/sun/star/gallery/GalleryItemType.hpp>
43 class SvxIMapDlg;
45 void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
47 sal_uInt16 nSlot = rReq.GetSlot();
48 switch(nSlot)
50 case SID_GALLERY:
52 // First make sure that the sidebar is visible
53 GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
55 ::sfx2::sidebar::Sidebar::ShowPanel(
56 "GalleryPanel",
57 GetViewFrame()->GetFrame().GetFrameInterface());
59 break;
63 void ScTabViewShell::ExecGallery( SfxRequest& rReq )
65 const SfxItemSet* pArgs = rReq.GetArgs();
67 SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, false );
68 if ( !pGalleryItem )
69 return;
71 sal_Int8 nType( pGalleryItem->GetType() );
72 if ( nType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
74 MakeDrawLayer();
76 Graphic aGraphic( pGalleryItem->GetGraphic() );
77 Point aPos = GetInsertPos();
79 OUString aPath, aFilter;
80 PasteGraphic( aPos, aGraphic, aPath, aFilter );
82 else if ( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
84 // for sounds (linked or not), insert a hyperlink button,
85 // like in Impress and Writer
86 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
87 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON, &aMediaURLItem, 0L );
91 void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
93 sal_uInt16 nSlot = rReq.GetSlot();
94 switch(nSlot)
96 case SID_IMAP:
98 SfxViewFrame* pThisFrame = GetViewFrame();
99 sal_uInt16 nId = ScIMapChildWindowId();
100 pThisFrame->ToggleChildWindow( nId );
101 GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
103 if ( pThisFrame->HasChildWindow( nId ) )
105 SvxIMapDlg* pDlg = GetIMapDlg();
106 if ( pDlg )
108 SdrView* pDrView = GetSdrView();
109 if ( pDrView )
111 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
112 if ( rMarkList.GetMarkCount() == 1 )
113 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
118 rReq.Ignore();
120 break;
122 case SID_IMAP_EXEC:
124 SdrView* pDrView = GetSdrView();
125 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
127 if ( pMark )
129 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
130 SvxIMapDlg* pDlg = GetIMapDlg();
132 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
134 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
135 ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
137 if ( !pIMapInfo )
138 pSdrObj->AppendUserData( new ScIMapInfo( rImageMap ) );
139 else
140 pIMapInfo->SetImageMap( rImageMap );
142 GetViewData().GetDocShell()->SetDrawModified();
146 break;
150 void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
152 SfxWhichIter aIter(rSet);
153 sal_uInt16 nWhich = aIter.FirstWhich();
154 while ( nWhich )
156 switch ( nWhich )
158 case SID_IMAP:
160 // Disabled wird nicht mehr...
162 bool bThere = false;
163 SfxViewFrame* pThisFrame = GetViewFrame();
164 sal_uInt16 nId = ScIMapChildWindowId();
165 if ( pThisFrame->KnowsChildWindow(nId) )
166 if ( pThisFrame->HasChildWindow(nId) )
167 bThere = true;
169 ObjectSelectionType eType=GetCurObjectSelectionType();
170 bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
171 if(!bThere && !bEnable)
173 rSet.DisableItem( nWhich );
175 else
177 rSet.Put( SfxBoolItem( nWhich, bThere ) );
180 break;
182 case SID_IMAP_EXEC:
184 bool bDisable = true;
186 SdrView* pDrView = GetSdrView();
187 if ( pDrView )
189 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
190 if ( rMarkList.GetMarkCount() == 1 )
191 if ( ScIMapDlgGetObj(GetIMapDlg()) ==
192 (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
193 bDisable = false;
196 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
198 break;
201 nWhich = aIter.NextWhich();
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */