fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / drviewsc.cxx
blobd39a2f220085367a320a7c246b0a76599fd151c3
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 "DrawViewShell.hxx"
21 #include "ViewShellImplementation.hxx"
22 #include <vcl/waitobj.hxx>
24 #include <svx/svxids.hrc>
25 #include <svx/dialogs.hrc>
26 #include <svx/imapdlg.hxx>
27 #include <vcl/msgbox.hxx>
28 #include <sfx2/request.hxx>
29 #include <svx/svdogrp.hxx>
30 #include <svx/svdoole2.hxx>
31 #include <svx/svdograf.hxx>
32 #include <svx/svxdlg.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <svl/style.hxx>
36 #include <svx/svdpagv.hxx>
37 #include <svx/grafctrl.hxx>
38 #include "stlsheet.hxx"
40 #include <sfx2/viewfrm.hxx>
42 #include "app.hrc"
43 #include "strings.hrc"
44 #include "helpids.h"
45 #include "Window.hxx"
46 #include "imapinfo.hxx"
47 #include "sdresid.hxx"
48 #include "drawdoc.hxx"
49 #include "DrawDocShell.hxx"
50 #include "drawview.hxx"
51 #include "sdabstdlg.hxx"
52 #include "brkdlg.hrc"
53 namespace sd {
55 /**
56 * Returns the global/main ID, i.e. the ID, which is used to execute the toolbox
58 sal_uInt16 DrawViewShell::GetIdBySubId( sal_uInt16 nSId )
60 sal_uInt16 nMappedSId = 0;
61 switch( nSId )
63 case SID_OBJECT_ROTATE:
64 case SID_OBJECT_MIRROR:
65 case SID_OBJECT_TRANSPARENCE:
66 case SID_OBJECT_GRADIENT:
67 case SID_OBJECT_SHEAR:
68 case SID_OBJECT_CROOK_ROTATE:
69 case SID_OBJECT_CROOK_SLANT:
70 case SID_OBJECT_CROOK_STRETCH:
71 case SID_CONVERT_TO_3D_LATHE:
73 nMappedSId = SID_OBJECT_CHOOSE_MODE;
75 break;
77 case SID_OBJECT_ALIGN_LEFT:
78 case SID_OBJECT_ALIGN_CENTER:
79 case SID_OBJECT_ALIGN_RIGHT:
80 case SID_OBJECT_ALIGN_UP:
81 case SID_OBJECT_ALIGN_MIDDLE:
82 case SID_OBJECT_ALIGN_DOWN:
84 nMappedSId = SID_OBJECT_ALIGN;
86 break;
88 case SID_FRAME_TO_TOP:
89 case SID_MOREFRONT:
90 case SID_MOREBACK:
91 case SID_FRAME_TO_BOTTOM:
92 case SID_BEFORE_OBJ:
93 case SID_BEHIND_OBJ:
94 case SID_REVERSE_ORDER:
96 nMappedSId = SID_POSITION;
98 break;
100 case SID_ZOOM_OUT:
101 case SID_ZOOM_IN:
102 case SID_SIZE_REAL:
103 case SID_ZOOM_PANNING:
104 case SID_SIZE_PAGE:
105 case SID_SIZE_PAGE_WIDTH:
106 case SID_SIZE_ALL:
107 case SID_SIZE_OPTIMAL:
108 case SID_ZOOM_NEXT:
109 case SID_ZOOM_PREV:
111 nMappedSId = SID_ZOOM_TOOLBOX;
113 break;
115 case SID_ATTR_CHAR:
116 case SID_TEXT_FITTOSIZE:
117 case SID_DRAW_CAPTION:
118 case SID_DRAW_FONTWORK:
119 case SID_DRAW_FONTWORK_VERTICAL:
121 nMappedSId = SID_DRAWTBX_TEXT;
123 break;
125 case SID_DRAW_RECT:
126 case SID_DRAW_SQUARE:
127 case SID_DRAW_RECT_ROUND:
128 case SID_DRAW_SQUARE_ROUND:
129 case SID_DRAW_RECT_NOFILL:
130 case SID_DRAW_SQUARE_NOFILL:
131 case SID_DRAW_RECT_ROUND_NOFILL:
132 case SID_DRAW_SQUARE_ROUND_NOFILL:
134 nMappedSId = SID_DRAWTBX_RECTANGLES;
136 break;
138 case SID_DRAW_ELLIPSE:
139 case SID_DRAW_CIRCLE:
140 case SID_DRAW_PIE:
141 case SID_DRAW_CIRCLEPIE:
142 case SID_DRAW_ELLIPSECUT:
143 case SID_DRAW_CIRCLECUT:
144 case SID_DRAW_ARC:
145 case SID_DRAW_CIRCLEARC:
146 case SID_DRAW_ELLIPSE_NOFILL:
147 case SID_DRAW_CIRCLE_NOFILL:
148 case SID_DRAW_PIE_NOFILL:
149 case SID_DRAW_CIRCLEPIE_NOFILL:
150 case SID_DRAW_ELLIPSECUT_NOFILL:
151 case SID_DRAW_CIRCLECUT_NOFILL:
153 nMappedSId = SID_DRAWTBX_ELLIPSES;
155 break;
157 case SID_DRAW_BEZIER_NOFILL:
158 case SID_DRAW_POLYGON_NOFILL:
159 case SID_DRAW_XPOLYGON_NOFILL:
160 case SID_DRAW_FREELINE_NOFILL:
161 case SID_DRAW_BEZIER_FILL:
162 case SID_DRAW_POLYGON:
163 case SID_DRAW_XPOLYGON:
164 case SID_DRAW_FREELINE:
166 nMappedSId = SID_DRAWTBX_LINES;
168 break;
170 case SID_DRAW_LINE:
171 case SID_DRAW_XLINE:
172 case SID_DRAW_MEASURELINE:
173 case SID_LINE_ARROW_START:
174 case SID_LINE_ARROW_END:
175 case SID_LINE_ARROWS:
176 case SID_LINE_ARROW_CIRCLE:
177 case SID_LINE_CIRCLE_ARROW:
178 case SID_LINE_ARROW_SQUARE:
179 case SID_LINE_SQUARE_ARROW:
181 nMappedSId = SID_DRAWTBX_ARROWS;
183 break;
185 case SID_3D_CUBE:
186 case SID_3D_TORUS:
187 case SID_3D_SPHERE:
188 case SID_3D_SHELL:
189 case SID_3D_HALF_SPHERE:
190 case SID_3D_CYLINDER:
191 case SID_3D_CONE:
192 case SID_3D_PYRAMID:
194 nMappedSId = SID_DRAWTBX_3D_OBJECTS;
196 break;
198 case SID_INSERT_DIAGRAM:
199 case SID_ATTR_TABLE:
200 case SID_INSERTFILE:
201 case SID_INSERT_GRAPHIC:
202 case SID_INSERT_AVMEDIA:
203 case SID_INSERTPAGE:
204 case SID_INSERT_MATH:
205 case SID_INSERT_FLOATINGFRAME:
206 case SID_INSERT_OBJECT:
207 case SID_INSERT_PLUGIN:
208 case SID_INSERT_SOUND:
209 case SID_INSERT_VIDEO:
210 case SID_INSERT_TABLE:
212 nMappedSId = SID_DRAWTBX_INSERT;
214 break;
216 case SID_TOOL_CONNECTOR:
217 case SID_CONNECTOR_ARROW_START:
218 case SID_CONNECTOR_ARROW_END:
219 case SID_CONNECTOR_ARROWS:
220 case SID_CONNECTOR_CIRCLE_START:
221 case SID_CONNECTOR_CIRCLE_END:
222 case SID_CONNECTOR_CIRCLES:
223 case SID_CONNECTOR_LINE:
224 case SID_CONNECTOR_LINE_ARROW_START:
225 case SID_CONNECTOR_LINE_ARROW_END:
226 case SID_CONNECTOR_LINE_ARROWS:
227 case SID_CONNECTOR_LINE_CIRCLE_START:
228 case SID_CONNECTOR_LINE_CIRCLE_END:
229 case SID_CONNECTOR_LINE_CIRCLES:
230 case SID_CONNECTOR_CURVE:
231 case SID_CONNECTOR_CURVE_ARROW_START:
232 case SID_CONNECTOR_CURVE_ARROW_END:
233 case SID_CONNECTOR_CURVE_ARROWS:
234 case SID_CONNECTOR_CURVE_CIRCLE_START:
235 case SID_CONNECTOR_CURVE_CIRCLE_END:
236 case SID_CONNECTOR_CURVE_CIRCLES:
237 case SID_CONNECTOR_LINES:
238 case SID_CONNECTOR_LINES_ARROW_START:
239 case SID_CONNECTOR_LINES_ARROW_END:
240 case SID_CONNECTOR_LINES_ARROWS:
241 case SID_CONNECTOR_LINES_CIRCLE_START:
242 case SID_CONNECTOR_LINES_CIRCLE_END:
243 case SID_CONNECTOR_LINES_CIRCLES:
245 nMappedSId = SID_DRAWTBX_CONNECTORS;
248 return( nMappedSId );
252 * Fills the SlotArray in order to get the current mapping of the ToolboxSlots
254 void DrawViewShell::MapSlot( sal_uInt16 nSId )
256 sal_uInt16 nMappedSId = GetIdBySubId( nSId );
258 if( nMappedSId > 0 )
260 sal_uInt16 nID = GetArrayId( nMappedSId ) + 1;
261 mpSlotArray[ nID ] = nSId;
266 * Allows a ImageMapping via SlotArray
268 void DrawViewShell::UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent )
270 if( !bPermanent )
272 sal_uInt16 nId = GetArrayId( SID_ZOOM_TOOLBOX ) + 1;
273 rSet.Put( TbxImageItem( SID_ZOOM_TOOLBOX, mpSlotArray[nId] ) );
275 nId = GetArrayId( SID_DRAWTBX_INSERT ) + 1;
276 rSet.Put( TbxImageItem( SID_DRAWTBX_INSERT, mpSlotArray[nId] ) );
278 nId = GetArrayId( SID_POSITION ) + 1;
279 rSet.Put( TbxImageItem( SID_POSITION, mpSlotArray[nId] ) );
281 nId = GetArrayId( SID_OBJECT_ALIGN ) + 1;
282 rSet.Put( TbxImageItem( SID_OBJECT_ALIGN, mpSlotArray[nId] ) );
284 else
286 for( sal_uInt16 nId = 0; nId < SLOTARRAY_COUNT; nId += 2 )
288 rSet.Put( TbxImageItem( mpSlotArray[nId], mpSlotArray[nId+1] ) );
294 sal_uInt16 DrawViewShell::GetMappedSlot( sal_uInt16 nSId )
296 sal_uInt16 nSlot = 0;
297 sal_uInt16 nId = GetArrayId( nSId );
298 if( nId != USHRT_MAX )
299 nSlot = mpSlotArray[ nId+1 ];
301 /* If the slot is mapped to itself, we have to return 0. Otherwise the slot
302 would be executed over and over again. The slot is initial available in
303 the array in order to show the image correct. */
304 if( nSId == nSlot )
305 return( 0 );
307 return( nSlot );
311 * @returns number of the main slot in the slot array
313 sal_uInt16 DrawViewShell::GetArrayId( sal_uInt16 nSId )
315 for( sal_uInt16 i = 0; i < SLOTARRAY_COUNT; i += 2 )
317 if( mpSlotArray[ i ] == nSId )
318 return( i );
320 OSL_FAIL( "Slot in array not found!" );
321 return( USHRT_MAX );
326 void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
328 if( ( pObj->ISA( SdrGrafObj ) || pObj->ISA( SdrOle2Obj ) ) && !mpDrawView->IsTextEdit() &&
329 GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
331 Graphic aGraphic;
332 ImageMap* pIMap = NULL;
333 TargetList* pTargetList = NULL;
334 SdIMapInfo* pIMapInfo = GetDoc()->GetIMapInfo( pObj );
336 // get graphic from shape
337 SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( pObj );
338 if( pGrafObj )
339 aGraphic = pGrafObj->GetGraphic();
341 if ( pIMapInfo )
343 pIMap = (ImageMap*) &pIMapInfo->GetImageMap();
344 pTargetList = new TargetList;
345 GetViewFrame()->GetTargetList( *pTargetList );
348 SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj );
350 // We can delete the target list
351 if ( pTargetList )
353 for ( size_t i = 0, n = pTargetList->size(); i < n; ++i )
354 delete pTargetList->at( i );
355 delete pTargetList;
360 // -----------------------------------------------------------------------------
362 IMPL_LINK( DrawViewShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
364 String aName;
366 if( pDialog )
367 pDialog->GetName( aName );
369 return( ( !aName.Len() || ( GetDoc() && !GetDoc()->GetObj( aName ) ) ) ? 1 : 0 );
372 } // end of namespace sd
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */