Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
31 :
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"
39 :
40 : #include <svx/galleryitem.hxx>
41 : #include <com/sun/star/gallery/GalleryItemType.hpp>
42 :
43 : class SvxIMapDlg;
44 :
45 0 : void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
46 : {
47 0 : sal_uInt16 nSlot = rReq.GetSlot();
48 0 : switch(nSlot)
49 : {
50 : case SID_GALLERY:
51 : {
52 : // First make sure that the sidebar is visible
53 0 : GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
54 :
55 : ::sfx2::sidebar::Sidebar::ShowPanel(
56 : "GalleryPanel",
57 0 : GetViewFrame()->GetFrame().GetFrameInterface());
58 : }
59 0 : break;
60 : }
61 0 : }
62 :
63 0 : void ScTabViewShell::ExecGallery( SfxRequest& rReq )
64 : {
65 0 : const SfxItemSet* pArgs = rReq.GetArgs();
66 :
67 0 : SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, false );
68 0 : if ( !pGalleryItem )
69 0 : return;
70 :
71 0 : sal_Int8 nType( pGalleryItem->GetType() );
72 0 : if ( nType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
73 : {
74 0 : MakeDrawLayer();
75 :
76 0 : Graphic aGraphic( pGalleryItem->GetGraphic() );
77 0 : Point aPos = GetInsertPos();
78 :
79 0 : OUString aPath, aFilter;
80 0 : PasteGraphic( aPos, aGraphic, aPath, aFilter );
81 : }
82 0 : else if ( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
83 : {
84 : // for sounds (linked or not), insert a hyperlink button,
85 : // like in Impress and Writer
86 0 : const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
87 0 : GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON, &aMediaURLItem, 0L );
88 : }
89 : }
90 :
91 0 : void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
92 : {
93 0 : sal_uInt16 nSlot = rReq.GetSlot();
94 0 : switch(nSlot)
95 : {
96 : case SID_IMAP:
97 : {
98 0 : SfxViewFrame* pThisFrame = GetViewFrame();
99 0 : sal_uInt16 nId = ScIMapChildWindowId();
100 0 : pThisFrame->ToggleChildWindow( nId );
101 0 : GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
102 :
103 0 : if ( pThisFrame->HasChildWindow( nId ) )
104 : {
105 0 : SvxIMapDlg* pDlg = GetIMapDlg();
106 0 : if ( pDlg )
107 : {
108 0 : SdrView* pDrView = GetSdrView();
109 0 : if ( pDrView )
110 : {
111 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
112 0 : if ( rMarkList.GetMarkCount() == 1 )
113 0 : UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
114 : }
115 : }
116 : }
117 :
118 0 : rReq.Ignore();
119 : }
120 0 : break;
121 :
122 : case SID_IMAP_EXEC:
123 : {
124 0 : SdrView* pDrView = GetSdrView();
125 0 : SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
126 :
127 0 : if ( pMark )
128 : {
129 0 : SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
130 0 : SvxIMapDlg* pDlg = GetIMapDlg();
131 :
132 0 : if ( ScIMapDlgGetObj(pDlg) == static_cast<void*>(pSdrObj) )
133 : {
134 0 : const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
135 0 : ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
136 :
137 0 : if ( !pIMapInfo )
138 0 : pSdrObj->AppendUserData( new ScIMapInfo( rImageMap ) );
139 : else
140 0 : pIMapInfo->SetImageMap( rImageMap );
141 :
142 0 : GetViewData().GetDocShell()->SetDrawModified();
143 : }
144 : }
145 : }
146 0 : break;
147 : }
148 0 : }
149 :
150 0 : void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
151 : {
152 0 : SfxWhichIter aIter(rSet);
153 0 : sal_uInt16 nWhich = aIter.FirstWhich();
154 0 : while ( nWhich )
155 : {
156 0 : switch ( nWhich )
157 : {
158 : case SID_IMAP:
159 : {
160 : // Disabled wird nicht mehr...
161 :
162 0 : bool bThere = false;
163 0 : SfxViewFrame* pThisFrame = GetViewFrame();
164 0 : sal_uInt16 nId = ScIMapChildWindowId();
165 0 : if ( pThisFrame->KnowsChildWindow(nId) )
166 0 : if ( pThisFrame->HasChildWindow(nId) )
167 0 : bThere = true;
168 :
169 0 : ObjectSelectionType eType=GetCurObjectSelectionType();
170 0 : bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
171 0 : if(!bThere && !bEnable)
172 : {
173 0 : rSet.DisableItem( nWhich );
174 : }
175 : else
176 : {
177 0 : rSet.Put( SfxBoolItem( nWhich, bThere ) );
178 : }
179 : }
180 0 : break;
181 :
182 : case SID_IMAP_EXEC:
183 : {
184 0 : bool bDisable = true;
185 :
186 0 : SdrView* pDrView = GetSdrView();
187 0 : if ( pDrView )
188 : {
189 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
190 0 : if ( rMarkList.GetMarkCount() == 1 )
191 0 : if ( ScIMapDlgGetObj(GetIMapDlg()) ==
192 0 : static_cast<void*>(rMarkList.GetMark(0)->GetMarkedSdrObj()) )
193 0 : bDisable = false;
194 : }
195 :
196 0 : rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
197 : }
198 0 : break;
199 : }
200 :
201 0 : nWhich = aIter.NextWhich();
202 0 : }
203 156 : }
204 :
205 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|