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