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 "DrawViewShell.hxx"
21 : #include "ViewShellImplementation.hxx"
22 : #include <vcl/waitobj.hxx>
23 :
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"
39 :
40 : #include <sfx2/viewfrm.hxx>
41 :
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 : namespace sd {
53 :
54 : /**
55 : * Returns the global/main ID, i.e. the ID, which is used to execute the toolbox
56 : */
57 0 : sal_uInt16 DrawViewShell::GetIdBySubId( sal_uInt16 nSId )
58 : {
59 0 : sal_uInt16 nMappedSId = 0;
60 0 : switch( nSId )
61 : {
62 : case SID_OBJECT_ROTATE:
63 : case SID_OBJECT_MIRROR:
64 : case SID_OBJECT_TRANSPARENCE:
65 : case SID_OBJECT_GRADIENT:
66 : case SID_OBJECT_SHEAR:
67 : case SID_OBJECT_CROOK_ROTATE:
68 : case SID_OBJECT_CROOK_SLANT:
69 : case SID_OBJECT_CROOK_STRETCH:
70 : case SID_CONVERT_TO_3D_LATHE:
71 : {
72 0 : nMappedSId = SID_OBJECT_CHOOSE_MODE;
73 : }
74 0 : break;
75 :
76 : case SID_OBJECT_ALIGN_LEFT:
77 : case SID_OBJECT_ALIGN_CENTER:
78 : case SID_OBJECT_ALIGN_RIGHT:
79 : case SID_OBJECT_ALIGN_UP:
80 : case SID_OBJECT_ALIGN_MIDDLE:
81 : case SID_OBJECT_ALIGN_DOWN:
82 : {
83 0 : nMappedSId = SID_OBJECT_ALIGN;
84 : }
85 0 : break;
86 :
87 : case SID_FRAME_TO_TOP:
88 : case SID_MOREFRONT:
89 : case SID_MOREBACK:
90 : case SID_FRAME_TO_BOTTOM:
91 : case SID_BEFORE_OBJ:
92 : case SID_BEHIND_OBJ:
93 : case SID_REVERSE_ORDER:
94 : {
95 0 : nMappedSId = SID_POSITION;
96 : }
97 0 : break;
98 :
99 : case SID_ZOOM_OUT:
100 : case SID_ZOOM_IN:
101 : case SID_SIZE_REAL:
102 : case SID_ZOOM_PANNING:
103 : case SID_SIZE_PAGE:
104 : case SID_SIZE_PAGE_WIDTH:
105 : case SID_SIZE_ALL:
106 : case SID_SIZE_OPTIMAL:
107 : case SID_ZOOM_NEXT:
108 : case SID_ZOOM_PREV:
109 : {
110 0 : nMappedSId = SID_ZOOM_TOOLBOX;
111 : }
112 0 : break;
113 :
114 : case SID_ATTR_CHAR:
115 : case SID_TEXT_FITTOSIZE:
116 : case SID_DRAW_CAPTION:
117 : case SID_DRAW_FONTWORK:
118 : case SID_DRAW_FONTWORK_VERTICAL:
119 : {
120 0 : nMappedSId = SID_DRAWTBX_TEXT;
121 : }
122 0 : break;
123 :
124 : case SID_DRAW_RECT:
125 : case SID_DRAW_SQUARE:
126 : case SID_DRAW_RECT_ROUND:
127 : case SID_DRAW_SQUARE_ROUND:
128 : case SID_DRAW_RECT_NOFILL:
129 : case SID_DRAW_SQUARE_NOFILL:
130 : case SID_DRAW_RECT_ROUND_NOFILL:
131 : case SID_DRAW_SQUARE_ROUND_NOFILL:
132 : {
133 0 : nMappedSId = SID_DRAWTBX_RECTANGLES;
134 : }
135 0 : break;
136 :
137 : case SID_DRAW_ELLIPSE:
138 : case SID_DRAW_CIRCLE:
139 : case SID_DRAW_PIE:
140 : case SID_DRAW_CIRCLEPIE:
141 : case SID_DRAW_ELLIPSECUT:
142 : case SID_DRAW_CIRCLECUT:
143 : case SID_DRAW_ARC:
144 : case SID_DRAW_CIRCLEARC:
145 : case SID_DRAW_ELLIPSE_NOFILL:
146 : case SID_DRAW_CIRCLE_NOFILL:
147 : case SID_DRAW_PIE_NOFILL:
148 : case SID_DRAW_CIRCLEPIE_NOFILL:
149 : case SID_DRAW_ELLIPSECUT_NOFILL:
150 : case SID_DRAW_CIRCLECUT_NOFILL:
151 : {
152 0 : nMappedSId = SID_DRAWTBX_ELLIPSES;
153 : }
154 0 : break;
155 :
156 : case SID_DRAW_BEZIER_NOFILL:
157 : case SID_DRAW_POLYGON_NOFILL:
158 : case SID_DRAW_XPOLYGON_NOFILL:
159 : case SID_DRAW_FREELINE_NOFILL:
160 : case SID_DRAW_BEZIER_FILL:
161 : case SID_DRAW_POLYGON:
162 : case SID_DRAW_XPOLYGON:
163 : case SID_DRAW_FREELINE:
164 : {
165 0 : nMappedSId = SID_DRAWTBX_LINES;
166 : }
167 0 : break;
168 :
169 : case SID_DRAW_LINE:
170 : case SID_DRAW_XLINE:
171 : case SID_DRAW_MEASURELINE:
172 : case SID_LINE_ARROW_START:
173 : case SID_LINE_ARROW_END:
174 : case SID_LINE_ARROWS:
175 : case SID_LINE_ARROW_CIRCLE:
176 : case SID_LINE_CIRCLE_ARROW:
177 : case SID_LINE_ARROW_SQUARE:
178 : case SID_LINE_SQUARE_ARROW:
179 : {
180 0 : nMappedSId = SID_DRAWTBX_ARROWS;
181 : }
182 0 : break;
183 :
184 : case SID_3D_CUBE:
185 : case SID_3D_TORUS:
186 : case SID_3D_SPHERE:
187 : case SID_3D_SHELL:
188 : case SID_3D_HALF_SPHERE:
189 : case SID_3D_CYLINDER:
190 : case SID_3D_CONE:
191 : case SID_3D_PYRAMID:
192 : {
193 0 : nMappedSId = SID_DRAWTBX_3D_OBJECTS;
194 : }
195 0 : break;
196 :
197 : case SID_INSERT_DIAGRAM:
198 : case SID_ATTR_TABLE:
199 : case SID_INSERTFILE:
200 : case SID_INSERT_GRAPHIC:
201 : case SID_INSERT_AVMEDIA:
202 : case SID_INSERTPAGE:
203 : case SID_INSERT_MATH:
204 : case SID_INSERT_FLOATINGFRAME:
205 : case SID_INSERT_OBJECT:
206 : case SID_INSERT_PLUGIN:
207 : case SID_INSERT_SOUND:
208 : case SID_INSERT_VIDEO:
209 : case SID_INSERT_TABLE:
210 : {
211 0 : nMappedSId = SID_DRAWTBX_INSERT;
212 : }
213 0 : break;
214 :
215 : case SID_TOOL_CONNECTOR:
216 : case SID_CONNECTOR_ARROW_START:
217 : case SID_CONNECTOR_ARROW_END:
218 : case SID_CONNECTOR_ARROWS:
219 : case SID_CONNECTOR_CIRCLE_START:
220 : case SID_CONNECTOR_CIRCLE_END:
221 : case SID_CONNECTOR_CIRCLES:
222 : case SID_CONNECTOR_LINE:
223 : case SID_CONNECTOR_LINE_ARROW_START:
224 : case SID_CONNECTOR_LINE_ARROW_END:
225 : case SID_CONNECTOR_LINE_ARROWS:
226 : case SID_CONNECTOR_LINE_CIRCLE_START:
227 : case SID_CONNECTOR_LINE_CIRCLE_END:
228 : case SID_CONNECTOR_LINE_CIRCLES:
229 : case SID_CONNECTOR_CURVE:
230 : case SID_CONNECTOR_CURVE_ARROW_START:
231 : case SID_CONNECTOR_CURVE_ARROW_END:
232 : case SID_CONNECTOR_CURVE_ARROWS:
233 : case SID_CONNECTOR_CURVE_CIRCLE_START:
234 : case SID_CONNECTOR_CURVE_CIRCLE_END:
235 : case SID_CONNECTOR_CURVE_CIRCLES:
236 : case SID_CONNECTOR_LINES:
237 : case SID_CONNECTOR_LINES_ARROW_START:
238 : case SID_CONNECTOR_LINES_ARROW_END:
239 : case SID_CONNECTOR_LINES_ARROWS:
240 : case SID_CONNECTOR_LINES_CIRCLE_START:
241 : case SID_CONNECTOR_LINES_CIRCLE_END:
242 : case SID_CONNECTOR_LINES_CIRCLES:
243 : {
244 0 : nMappedSId = SID_DRAWTBX_CONNECTORS;
245 : }
246 : }
247 0 : return( nMappedSId );
248 : }
249 :
250 : /**
251 : * Fills the SlotArray in order to get the current mapping of the ToolboxSlots
252 : */
253 0 : void DrawViewShell::MapSlot( sal_uInt16 nSId )
254 : {
255 0 : sal_uInt16 nMappedSId = GetIdBySubId( nSId );
256 :
257 0 : if( nMappedSId > 0 )
258 : {
259 0 : sal_uInt16 nID = GetArrayId( nMappedSId ) + 1;
260 0 : mpSlotArray[ nID ] = nSId;
261 : }
262 0 : }
263 :
264 : /**
265 : * Allows a ImageMapping via SlotArray
266 : */
267 0 : void DrawViewShell::UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent )
268 : {
269 0 : if( !bPermanent )
270 : {
271 0 : sal_uInt16 nId = GetArrayId( SID_ZOOM_TOOLBOX ) + 1;
272 0 : rSet.Put( TbxImageItem( SID_ZOOM_TOOLBOX, mpSlotArray[nId] ) );
273 :
274 0 : nId = GetArrayId( SID_DRAWTBX_INSERT ) + 1;
275 0 : rSet.Put( TbxImageItem( SID_DRAWTBX_INSERT, mpSlotArray[nId] ) );
276 :
277 0 : nId = GetArrayId( SID_POSITION ) + 1;
278 0 : rSet.Put( TbxImageItem( SID_POSITION, mpSlotArray[nId] ) );
279 :
280 0 : nId = GetArrayId( SID_OBJECT_ALIGN ) + 1;
281 0 : rSet.Put( TbxImageItem( SID_OBJECT_ALIGN, mpSlotArray[nId] ) );
282 : }
283 : else
284 : {
285 0 : for( sal_uInt16 nId = 0; nId < SLOTARRAY_COUNT; nId += 2 )
286 : {
287 0 : rSet.Put( TbxImageItem( mpSlotArray[nId], mpSlotArray[nId+1] ) );
288 : }
289 : }
290 0 : }
291 :
292 :
293 0 : sal_uInt16 DrawViewShell::GetMappedSlot( sal_uInt16 nSId )
294 : {
295 0 : sal_uInt16 nSlot = 0;
296 0 : sal_uInt16 nId = GetArrayId( nSId );
297 0 : if( nId != USHRT_MAX )
298 0 : nSlot = mpSlotArray[ nId+1 ];
299 :
300 : /* If the slot is mapped to itself, we have to return 0. Otherwise the slot
301 : would be executed over and over again. The slot is initial available in
302 : the array in order to show the image correct. */
303 0 : if( nSId == nSlot )
304 0 : return( 0 );
305 :
306 0 : return( nSlot );
307 : }
308 :
309 : /**
310 : * @returns number of the main slot in the slot array
311 : */
312 0 : sal_uInt16 DrawViewShell::GetArrayId( sal_uInt16 nSId )
313 : {
314 0 : for( sal_uInt16 i = 0; i < SLOTARRAY_COUNT; i += 2 )
315 : {
316 0 : if( mpSlotArray[ i ] == nSId )
317 0 : return( i );
318 : }
319 : OSL_FAIL( "Slot in array not found!" );
320 0 : return( USHRT_MAX );
321 : }
322 :
323 :
324 :
325 0 : void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
326 : {
327 0 : if( ( pObj->ISA( SdrGrafObj ) || pObj->ISA( SdrOle2Obj ) ) && !mpDrawView->IsTextEdit() &&
328 0 : GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
329 : {
330 0 : Graphic aGraphic;
331 0 : ImageMap* pIMap = NULL;
332 0 : TargetList* pTargetList = NULL;
333 0 : SdIMapInfo* pIMapInfo = GetDoc()->GetIMapInfo( pObj );
334 :
335 : // get graphic from shape
336 0 : SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( pObj );
337 0 : if( pGrafObj )
338 0 : aGraphic = pGrafObj->GetGraphic();
339 :
340 0 : if ( pIMapInfo )
341 : {
342 0 : pIMap = (ImageMap*) &pIMapInfo->GetImageMap();
343 0 : pTargetList = new TargetList;
344 0 : GetViewFrame()->GetTargetList( *pTargetList );
345 : }
346 :
347 0 : SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj );
348 :
349 : // We can delete the target list
350 0 : if ( pTargetList )
351 : {
352 0 : delete pTargetList;
353 0 : }
354 : }
355 0 : }
356 :
357 :
358 :
359 0 : IMPL_LINK( DrawViewShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
360 : {
361 0 : OUString aName;
362 :
363 0 : if( pDialog )
364 0 : pDialog->GetName( aName );
365 :
366 0 : return ( aName.isEmpty() || ( GetDoc() && !GetDoc()->GetObj( aName ) ) ) ? 1 : 0;
367 : }
368 :
369 0 : } // end of namespace sd
370 :
371 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|