xref: /aoo42x/main/sd/source/ui/view/drviewsc.cxx (revision ee093554)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawViewShell.hxx"
28 #include "ViewShellImplementation.hxx"
29 #include <vcl/waitobj.hxx>
30 
31 #ifndef _SVXIDS_HRC
32 #include <svx/svxids.hrc>
33 #endif
34 #include <svx/dialogs.hrc>
35 #ifndef _IMAPDLG_HXX
36 #include <svx/imapdlg.hxx>
37 #endif
38 #include <vcl/msgbox.hxx>
39 #include <sfx2/request.hxx>
40 #include <svx/svdogrp.hxx>
41 #include <svx/svdoole2.hxx>
42 #include <svx/svdograf.hxx>
43 #include <svx/svxdlg.hxx>
44 #ifndef _BINDING_HXX //autogen
45 #include <sfx2/bindings.hxx>
46 #endif
47 #include <sfx2/dispatch.hxx>
48 #include <svx/svdoole2.hxx>
49 #include <svl/style.hxx>
50 #include <svx/svdpagv.hxx>
51 #include <svx/grafctrl.hxx>
52 #include "stlsheet.hxx"
53 
54 #include <sfx2/viewfrm.hxx>
55 
56 #include "app.hrc"
57 #include "strings.hrc"
58 #include "helpids.h"
59 #include "misc.hxx"
60 #include "Window.hxx"
61 #include "imapinfo.hxx"
62 #include "futempl.hxx"
63 #include "fusel.hxx"
64 #include "sdresid.hxx"
65 #include "drawdoc.hxx"
66 #include "DrawDocShell.hxx"
67 #include "drawview.hxx"
68 #include "sdabstdlg.hxx"
69 #include "brkdlg.hrc"
70 namespace sd {
71 
72 #define	MIN_ACTIONS_FOR_DIALOG	5000	// bei mehr als 1600 Metaobjekten
73 										// wird beim Aufbrechen ein Dialog
74 										// angezeigt.
75 /*************************************************************************
76 |*
77 |* SfxRequests fuer temporaere Funktionen
78 |*
79 \************************************************************************/
80 
FuTemp03(SfxRequest & rReq)81 void DrawViewShell::FuTemp03(SfxRequest& rReq)
82 {
83 	sal_uInt16 nSId = rReq.GetSlot();
84 	switch( nSId )
85 	{
86 		case SID_GROUP:  // BASIC
87 		{
88 			if ( mpDrawView->IsPresObjSelected( sal_True, sal_True, sal_True ) )
89 			{
90                 ::sd::Window* pWindow = GetActiveWindow();
91                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
92 			}
93 			else
94 			{
95 				mpDrawView->GroupMarked();
96 			}
97 			Cancel();
98 			rReq.Done ();
99 		}
100 		break;
101 
102 		case SID_UNGROUP:  // BASIC
103 		{
104 			mpDrawView->UnGroupMarked();
105 			Cancel();
106 			rReq.Done ();
107 		}
108 		break;
109 
110 		case SID_NAME_GROUP:
111 		{
112 			// only allow for single object selection since the name of an object needs
113 			// to be unique
114 			if(1L == mpDrawView->GetMarkedObjectCount())
115 			{
116 				// #i68101#
117 				SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0L);
118 				OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
119 				String aName(pSelected->GetName());
120 
121 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
122 				OSL_ENSURE(pFact, "Dialogdiet fail!");
123 				AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
124 				OSL_ENSURE(pDlg, "Dialogdiet fail!");
125 
126 				pDlg->SetCheckNameHdl(LINK(this, DrawViewShell, NameObjectHdl));
127 
128 				if(RET_OK == pDlg->Execute())
129 				{
130 					pDlg->GetName(aName);
131 					pSelected->SetName(aName);
132 				}
133 
134 				delete pDlg;
135 			}
136 
137 			SfxBindings& rBindings = GetViewFrame()->GetBindings();
138 			rBindings.Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False );
139 			rBindings.Invalidate( SID_CONTEXT );
140 
141 			Cancel();
142 			rReq.Ignore();
143 			break;
144 		}
145 
146 		// #i68101#
147 		case SID_OBJECT_TITLE_DESCRIPTION:
148 		{
149 			if(1L == mpDrawView->GetMarkedObjectCount())
150 			{
151 				SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0L);
152 				OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
153 				String aTitle(pSelected->GetTitle());
154 				String aDescription(pSelected->GetDescription());
155 
156 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
157 				OSL_ENSURE(pFact, "Dialogdiet fail!");
158 				AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
159 				OSL_ENSURE(pDlg, "Dialogdiet fail!");
160 
161 				if(RET_OK == pDlg->Execute())
162 				{
163 					pDlg->GetTitle(aTitle);
164 					pDlg->GetDescription(aDescription);
165 					pSelected->SetTitle(aTitle);
166 					pSelected->SetDescription(aDescription);
167 				}
168 
169 				delete pDlg;
170 			}
171 
172 			SfxBindings& rBindings = GetViewFrame()->GetBindings();
173 			rBindings.Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False );
174 			rBindings.Invalidate( SID_CONTEXT );
175 
176 			Cancel();
177 			rReq.Ignore();
178 			break;
179 		}
180 
181 		case SID_ENTER_GROUP:  // BASIC
182 		{
183 			mpDrawView->EnterMarkedGroup();
184 			Cancel();
185 			rReq.Done ();
186 		}
187 		break;
188 
189 		case SID_LEAVE_GROUP:  // BASIC
190 		{
191 			mpDrawView->LeaveOneGroup();
192 			Cancel();
193 			rReq.Done ();
194 		}
195 		break;
196 
197 		case SID_LEAVE_ALL_GROUPS:  // BASIC
198 		{
199 			mpDrawView->LeaveAllGroup();
200 			Cancel();
201 			rReq.Done ();
202 		}
203 		break;
204 
205 		case SID_COMBINE:  // BASIC
206 		{
207 			// #88224# End text edit to avoid conflicts
208 			if(mpDrawView->IsTextEdit())
209 				mpDrawView->SdrEndTextEdit();
210 
211 			if ( mpDrawView->IsPresObjSelected() )
212 			{
213                 ::sd::Window* pWindow = GetActiveWindow();
214                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
215 			}
216 			else
217 			{
218 				WaitObject aWait( (Window*)GetActiveWindow() );
219 				mpDrawView->CombineMarkedObjects(sal_False);
220 			}
221 			Cancel();
222 			rReq.Done ();
223 		}
224 		break;
225 
226 		case SID_DISTRIBUTE_DLG:
227 		{
228 			if ( mpDrawView->IsPresObjSelected() )
229 			{
230                 ::sd::Window* pWindow = GetActiveWindow();
231                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
232 			}
233 			else
234 			{
235 				mpDrawView->DistributeMarkedObjects();
236 			}
237 			Cancel();
238 			rReq.Done ();
239 		}
240 		break;
241 
242         case SID_POLY_MERGE:
243 		{
244 			// #88224# End text edit to avoid conflicts
245 			if(mpDrawView->IsTextEdit())
246 				mpDrawView->SdrEndTextEdit();
247 
248 			if ( mpDrawView->IsPresObjSelected() )
249 			{
250                 ::sd::Window* pWindow = GetActiveWindow();
251                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
252 			}
253 			else
254 			{
255 				WaitObject aWait( (Window*)GetActiveWindow() );
256 				mpDrawView->MergeMarkedObjects(SDR_MERGE_MERGE);
257 			}
258 			Cancel();
259 			rReq.Done ();
260 		}
261 		break;
262 
263         case SID_POLY_SUBSTRACT:
264 		{
265 			// #88224# End text edit to avoid conflicts
266 			if(mpDrawView->IsTextEdit())
267 				mpDrawView->SdrEndTextEdit();
268 
269 			if ( mpDrawView->IsPresObjSelected() )
270 			{
271                 ::sd::Window* pWindow = GetActiveWindow();
272                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
273 			}
274 			else
275 			{
276 				WaitObject aWait( (Window*)GetActiveWindow() );
277 				mpDrawView->MergeMarkedObjects(SDR_MERGE_SUBSTRACT);
278 			}
279 			Cancel();
280 			rReq.Done ();
281 		}
282 		break;
283 
284         case SID_POLY_INTERSECT:
285 		{
286 			// #88224# End text edit to avoid conflicts
287 			if(mpDrawView->IsTextEdit())
288 				mpDrawView->SdrEndTextEdit();
289 
290 			if ( mpDrawView->IsPresObjSelected() )
291 			{
292                 ::sd::Window* pWindow = GetActiveWindow();
293                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
294 			}
295 			else
296 			{
297 				WaitObject aWait( (Window*)GetActiveWindow() );
298 				mpDrawView->MergeMarkedObjects(SDR_MERGE_INTERSECT);
299 			}
300 			Cancel();
301 			rReq.Done ();
302 		}
303 		break;
304 
305 		case SID_DISMANTLE:  // BASIC
306 		{
307 			if ( mpDrawView->IsDismantlePossible(sal_False) )
308 			{
309 				WaitObject aWait( (Window*)GetActiveWindow() );
310 				mpDrawView->DismantleMarkedObjects(sal_False);
311 			}
312 			Cancel();
313 			rReq.Done ();
314 		}
315 		break;
316 
317 		case SID_CONNECT:  // BASIC
318 		{
319 			if ( mpDrawView->IsPresObjSelected() )
320 			{
321                 ::sd::Window* pWindow = GetActiveWindow();
322                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
323 			}
324 			else
325 			{
326 				WaitObject aWait( (Window*)GetActiveWindow() );
327 				mpDrawView->CombineMarkedObjects(sal_True);
328 			}
329 			Cancel();
330 			rReq.Done ();
331 		}
332 		break;
333 
334 		case SID_BREAK:  // BASIC
335 		{
336 			if ( mpDrawView->IsTextEdit() )
337 			{
338 				mpDrawView->SdrEndTextEdit();
339 			}
340 
341             if ( mpDrawView->IsBreak3DObjPossible() )
342 			{
343 				WaitObject aWait( (Window*)GetActiveWindow() );
344                 mpDrawView->Break3DObj();
345 			}
346             else if ( mpDrawView->IsDismantlePossible(sal_True) )
347 			{
348 				WaitObject aWait( (Window*)GetActiveWindow() );
349 				mpDrawView->DismantleMarkedObjects(sal_True);
350             }
351             else if ( mpDrawView->IsImportMtfPossible() )
352 			{
353 
354 				WaitObject aWait( (Window*)GetActiveWindow() );
355 				const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
356 				sal_uLong nAnz=rMarkList.GetMarkCount();
357 
358 				// Summe der Metaobjekte aller sel. Metafiles erm.
359 				sal_uLong nCount = 0;
360 				for(sal_uLong nm=0; nm<nAnz; nm++)
361 				{
362 					SdrMark*     pM=rMarkList.GetMark(nm);
363 				    SdrObject*   pObj=pM->GetMarkedSdrObj();
364 				    SdrGrafObj*  pGraf=PTR_CAST(SdrGrafObj,pObj);
365 					SdrOle2Obj*  pOle2=PTR_CAST(SdrOle2Obj,pObj);
366 
367                     if(pGraf)
368                     {
369                         if(pGraf->HasGDIMetaFile())
370                         {
371                             nCount += pGraf->GetGraphic().GetGDIMetaFile().GetActionCount();
372                         }
373                         else if(pGraf->isEmbeddedSvg())
374                         {
375                             nCount += pGraf->getMetafileFromEmbeddedSvg().GetActionCount();
376                         }
377                     }
378 
379                     if(pOle2 && pOle2->GetGraphic())
380                     {
381                         nCount += pOle2->GetGraphic()->GetGDIMetaFile().GetActionCount();
382                     }
383 				}
384 
385 				// anhand der erm. Summe entscheiden ob mit
386 				// oder ohne Dialog aufgebrochen wird.
387 				if(nCount < MIN_ACTIONS_FOR_DIALOG)
388 				{
389 					// ohne Dialog aufbrechen
390 					mpDrawView->DoImportMarkedMtf();
391 				}
392 				else
393 				{
394 					SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
395 					if( pFact )
396 					{
397 						VclAbstractDialog* pDlg = pFact->CreateBreakDlg(GetActiveWindow(), mpDrawView, GetDocSh(), nCount, nAnz );
398 						if( pDlg )
399 						{
400 							pDlg->Execute();
401 							delete pDlg;
402 						}
403 					}
404 				}
405 			}
406 
407 			Cancel();
408 			rReq.Done ();
409 		}
410 		break;
411 
412 		case SID_CONVERT_TO_3D:
413 		{
414 			if ( mpDrawView->IsPresObjSelected() )
415 			{
416                 ::sd::Window* pWindow = GetActiveWindow();
417                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
418 			}
419 			else
420 			{
421 				if (mpDrawView->IsConvertTo3DObjPossible())
422 				{
423 					if (mpDrawView->IsTextEdit())
424 					{
425 						mpDrawView->SdrEndTextEdit();
426 					}
427 
428 					WaitObject aWait( (Window*)GetActiveWindow() );
429 					mpDrawView->ConvertMarkedObjTo3D(sal_True);
430 				}
431 			}
432 
433 			Cancel();
434 			rReq.Done();
435 		}
436 		break;
437 
438 		case SID_FRAME_TO_TOP:	// BASIC
439 		{
440 			mpDrawView->PutMarkedToTop();
441 			Cancel();
442 			Invalidate( SID_POSITION );
443 			rReq.Done ();
444 		}
445 		break;
446 
447 		case SID_MOREFRONT:  // BASIC
448 		{
449 			mpDrawView->MovMarkedToTop();
450 			Cancel();
451 			Invalidate( SID_POSITION );
452 			rReq.Done ();
453 		}
454 		break;
455 
456 		case SID_MOREBACK:	// BASIC
457 		{
458 			mpDrawView->MovMarkedToBtm();
459 			Cancel();
460 			Invalidate( SID_POSITION );
461 			rReq.Done ();
462 		}
463 		break;
464 
465 		case SID_FRAME_TO_BOTTOM:	// BASIC
466 		{
467 			mpDrawView->PutMarkedToBtm();
468 			Cancel();
469 			Invalidate( SID_POSITION );
470 			rReq.Done ();
471 		}
472 		break;
473 
474 		case SID_HORIZONTAL:  // BASIC
475         case SID_FLIP_HORIZONTAL:
476 		{
477             mpDrawView->MirrorAllMarkedHorizontal();
478 			Cancel();
479 			rReq.Done ();
480 		}
481 		break;
482 
483 		case SID_VERTICAL:	// BASIC
484         case SID_FLIP_VERTICAL:
485 		{
486 			mpDrawView->MirrorAllMarkedVertical();
487 			Cancel();
488 			rReq.Done ();
489 		}
490 		break;
491 
492 		case SID_OBJECT_ALIGN_LEFT:  // BASIC
493 		{
494 			mpDrawView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
495 			Cancel();
496 			rReq.Done ();
497 		}
498 		break;
499 
500 		case SID_OBJECT_ALIGN_CENTER:  // BASIC
501 		{
502 			mpDrawView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
503 			Cancel();
504 			rReq.Done ();
505 		}
506 		break;
507 
508 		case SID_OBJECT_ALIGN_RIGHT:  // BASIC
509 		{
510 			mpDrawView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
511 			Cancel();
512 			rReq.Done ();
513 		}
514 		break;
515 
516 		case SID_OBJECT_ALIGN_UP:  // BASIC
517 		{
518 			mpDrawView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
519 			Cancel();
520 			rReq.Done ();
521 		}
522 		break;
523 
524 		case SID_OBJECT_ALIGN_MIDDLE:  // BASIC
525 		{
526 			mpDrawView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
527 			Cancel();
528 			rReq.Done ();
529 		}
530 		break;
531 
532 		case SID_OBJECT_ALIGN_DOWN:  // BASIC
533 		{
534 			mpDrawView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
535 			Cancel();
536 			rReq.Done ();
537 		}
538 		break;
539 
540 		case SID_SELECTALL:  // BASIC
541 		{
542             if( (dynamic_cast<FuSelection*>( GetOldFunction().get() ) != 0) &&
543                 !GetView()->IsFrameDragSingles() && GetView()->HasMarkablePoints())
544 			{
545 				if ( !mpDrawView->IsAction() )
546 					mpDrawView->MarkAllPoints();
547 			}
548 			else
549 				mpDrawView->SelectAll();
550 
551 			Cancel();
552 			rReq.Done ();
553 		}
554 		break;
555 
556 		case SID_STYLE_NEW:	// BASIC ???
557 		case SID_STYLE_APPLY:
558 		case SID_STYLE_EDIT:
559 		case SID_STYLE_DELETE:
560 		case SID_STYLE_FAMILY:
561 		case SID_STYLE_WATERCAN:
562 		case SID_STYLE_UPDATE_BY_EXAMPLE:
563 		case SID_STYLE_NEW_BY_EXAMPLE:
564 		{
565 			if( rReq.GetSlot() == SID_STYLE_EDIT && !rReq.GetArgs() )
566 			{
567 				SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
568 				if( pStyleSheet && pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
569 					pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
570 
571 				if( (pStyleSheet == NULL) && GetView()->IsTextEdit() )
572 				{
573 					GetView()->SdrEndTextEdit();
574 
575 					pStyleSheet = mpDrawView->GetStyleSheet();
576 					if(pStyleSheet && pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
577 						pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
578 				}
579 
580 				if( pStyleSheet == NULL )
581 				{
582 					rReq.Ignore();
583 					break;
584 				}
585 
586 				SfxAllItemSet aSet(GetDoc()->GetPool());
587 
588 				SfxStringItem aStyleNameItem( SID_STYLE_EDIT, pStyleSheet->GetName() );
589 				aSet.Put(aStyleNameItem);
590 
591 				SfxUInt16Item aStyleFamilyItem( SID_STYLE_FAMILY, (sal_uInt16)pStyleSheet->GetFamily() );
592 				aSet.Put(aStyleFamilyItem);
593 
594 				rReq.SetArgs(aSet);
595 			}
596 
597 			if( rReq.GetArgs() )
598 			{
599 				SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
600 				if( rReq.GetSlot() == SID_STYLE_APPLY )
601 					GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
602 				Cancel();
603 			}
604 			else if( rReq.GetSlot() == SID_STYLE_APPLY )
605 				GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON );
606 			rReq.Ignore ();
607 		}
608 		break;
609 
610 		case SID_IMAP:
611 		{
612 			SvxIMapDlg* pDlg;
613 			sal_uInt16		nId = SvxIMapDlgChildWindow::GetChildWindowId();
614 
615 			GetViewFrame()->ToggleChildWindow( nId );
616 			GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
617 
618 			if ( GetViewFrame()->HasChildWindow( nId )
619                 && ( ( pDlg = ViewShell::Implementation::GetImageMapDialog() ) != NULL ) )
620 			{
621 				const SdrMarkList&	rMarkList = mpDrawView->GetMarkedObjectList();
622 
623 				if ( rMarkList.GetMarkCount() == 1 )
624 					UpdateIMapDlg( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
625 			}
626 
627 			Cancel();
628 			rReq.Ignore ();
629 		}
630 		break;
631 
632 		case SID_GRID_FRONT:
633 		{
634 			mpDrawView->SetGridFront( !mpDrawView->IsGridFront() );
635 			Cancel();
636 			rReq.Done ();
637 		}
638 		break;
639 
640 		case SID_HELPLINES_FRONT:
641 		{
642 			mpDrawView->SetHlplFront( !mpDrawView->IsHlplFront() );
643 			Cancel();
644 			rReq.Done ();
645 		}
646 		break;
647 
648 		default:
649 			FuTemp04(rReq);
650 		break;
651 	};
652 };
653 
654 /*************************************************************************
655 |*
656 |* Liefert die globale/Haupt-ID zurueck, also die ID, ueber die die
657 |* Toolbox ausgeloest wird
658 |*
659 \************************************************************************/
660 
GetIdBySubId(sal_uInt16 nSId)661 sal_uInt16 DrawViewShell::GetIdBySubId( sal_uInt16 nSId )
662 {
663 	sal_uInt16 nMappedSId = 0;
664 	switch( nSId )
665 	{
666 		case SID_OBJECT_ROTATE:
667 		case SID_OBJECT_MIRROR:
668 		case SID_OBJECT_TRANSPARENCE:
669 		case SID_OBJECT_GRADIENT:
670 		case SID_OBJECT_SHEAR:
671 		case SID_OBJECT_CROOK_ROTATE:
672 		case SID_OBJECT_CROOK_SLANT:
673 		case SID_OBJECT_CROOK_STRETCH:
674         case SID_CONVERT_TO_3D_LATHE:
675 		{
676 			nMappedSId = SID_OBJECT_CHOOSE_MODE;
677 		}
678 		break;
679 
680 		case SID_OBJECT_ALIGN_LEFT:
681 		case SID_OBJECT_ALIGN_CENTER:
682 		case SID_OBJECT_ALIGN_RIGHT:
683 		case SID_OBJECT_ALIGN_UP:
684 		case SID_OBJECT_ALIGN_MIDDLE:
685 		case SID_OBJECT_ALIGN_DOWN:
686 		{
687 			nMappedSId = SID_OBJECT_ALIGN;
688 		}
689 		break;
690 
691 		case SID_FRAME_TO_TOP:
692 		case SID_MOREFRONT:
693 		case SID_MOREBACK:
694 		case SID_FRAME_TO_BOTTOM:
695 		case SID_BEFORE_OBJ:
696 		case SID_BEHIND_OBJ:
697 		case SID_REVERSE_ORDER:
698 		{
699 			nMappedSId = SID_POSITION;
700 		}
701 		break;
702 
703 		case SID_ZOOM_OUT:
704 		case SID_ZOOM_IN:
705 		case SID_SIZE_REAL:
706 		case SID_ZOOM_PANNING:
707 		case SID_SIZE_PAGE:
708 		case SID_SIZE_PAGE_WIDTH:
709 		case SID_SIZE_ALL:
710 		case SID_SIZE_OPTIMAL:
711 		case SID_ZOOM_NEXT:
712 		case SID_ZOOM_PREV:
713 		{
714 			nMappedSId = SID_ZOOM_TOOLBOX;
715 		}
716 		break;
717 
718 		case SID_ATTR_CHAR:
719 		case SID_TEXT_FITTOSIZE:
720 		case SID_DRAW_CAPTION:
721 		case SID_DRAW_FONTWORK:
722 		case SID_DRAW_FONTWORK_VERTICAL:
723 		{
724 			nMappedSId = SID_DRAWTBX_TEXT;
725 		}
726 		break;
727 
728 		case SID_DRAW_RECT:
729 		case SID_DRAW_SQUARE:
730 		case SID_DRAW_RECT_ROUND:
731 		case SID_DRAW_SQUARE_ROUND:
732 		case SID_DRAW_RECT_NOFILL:
733 		case SID_DRAW_SQUARE_NOFILL:
734 		case SID_DRAW_RECT_ROUND_NOFILL:
735 		case SID_DRAW_SQUARE_ROUND_NOFILL:
736 		{
737 			nMappedSId = SID_DRAWTBX_RECTANGLES;
738 		}
739 		break;
740 
741 		case SID_DRAW_ELLIPSE:
742 		case SID_DRAW_CIRCLE:
743 		case SID_DRAW_PIE:
744 		case SID_DRAW_CIRCLEPIE:
745 		case SID_DRAW_ELLIPSECUT:
746 		case SID_DRAW_CIRCLECUT:
747 		case SID_DRAW_ARC:
748 		case SID_DRAW_CIRCLEARC:
749 		case SID_DRAW_ELLIPSE_NOFILL:
750 		case SID_DRAW_CIRCLE_NOFILL:
751 		case SID_DRAW_PIE_NOFILL:
752 		case SID_DRAW_CIRCLEPIE_NOFILL:
753 		case SID_DRAW_ELLIPSECUT_NOFILL:
754 		case SID_DRAW_CIRCLECUT_NOFILL:
755 		{
756 			nMappedSId = SID_DRAWTBX_ELLIPSES;
757 		}
758 		break;
759 
760         case SID_DRAW_BEZIER_NOFILL:
761 		case SID_DRAW_POLYGON_NOFILL:
762 		case SID_DRAW_XPOLYGON_NOFILL:
763         case SID_DRAW_FREELINE_NOFILL:
764         case SID_DRAW_BEZIER_FILL:
765 		case SID_DRAW_POLYGON:
766 		case SID_DRAW_XPOLYGON:
767         case SID_DRAW_FREELINE:
768 		{
769 			nMappedSId = SID_DRAWTBX_LINES;
770 		}
771 		break;
772 
773 		case SID_DRAW_LINE:
774 		case SID_DRAW_XLINE:
775 		case SID_DRAW_MEASURELINE:
776 		case SID_LINE_ARROW_START:
777 		case SID_LINE_ARROW_END:
778 		case SID_LINE_ARROWS:
779 		case SID_LINE_ARROW_CIRCLE:
780 		case SID_LINE_CIRCLE_ARROW:
781 		case SID_LINE_ARROW_SQUARE:
782 		case SID_LINE_SQUARE_ARROW:
783 		{
784 			nMappedSId = SID_DRAWTBX_ARROWS;
785 		}
786 		break;
787 
788 		case SID_3D_CUBE:
789 		case SID_3D_TORUS:
790 		case SID_3D_SPHERE:
791 		case SID_3D_SHELL:
792 		case SID_3D_HALF_SPHERE:
793 		case SID_3D_CYLINDER:
794 		case SID_3D_CONE:
795 		case SID_3D_PYRAMID:
796 		{
797 			nMappedSId = SID_DRAWTBX_3D_OBJECTS;
798 		}
799 		break;
800 
801 		case SID_INSERT_DIAGRAM:
802 		case SID_ATTR_TABLE:
803 		case SID_INSERTFILE:
804 		case SID_INSERT_GRAPHIC:
805 		case SID_INSERT_AVMEDIA:
806 		case SID_INSERTPAGE:
807 	    case SID_INSERT_MATH:
808 	    case SID_INSERT_FLOATINGFRAME:
809 	    case SID_INSERT_OBJECT:
810         case SID_INSERT_PLUGIN:
811 		case SID_INSERT_SOUND:
812 		case SID_INSERT_VIDEO:
813 		case SID_INSERT_TABLE:
814 		{
815 			nMappedSId = SID_DRAWTBX_INSERT;
816 		}
817 		break;
818 
819         case SID_TOOL_CONNECTOR:
820         case SID_CONNECTOR_ARROW_START:
821         case SID_CONNECTOR_ARROW_END:
822         case SID_CONNECTOR_ARROWS:
823         case SID_CONNECTOR_CIRCLE_START:
824         case SID_CONNECTOR_CIRCLE_END:
825         case SID_CONNECTOR_CIRCLES:
826         case SID_CONNECTOR_LINE:
827         case SID_CONNECTOR_LINE_ARROW_START:
828         case SID_CONNECTOR_LINE_ARROW_END:
829         case SID_CONNECTOR_LINE_ARROWS:
830         case SID_CONNECTOR_LINE_CIRCLE_START:
831         case SID_CONNECTOR_LINE_CIRCLE_END:
832         case SID_CONNECTOR_LINE_CIRCLES:
833         case SID_CONNECTOR_CURVE:
834         case SID_CONNECTOR_CURVE_ARROW_START:
835         case SID_CONNECTOR_CURVE_ARROW_END:
836         case SID_CONNECTOR_CURVE_ARROWS:
837         case SID_CONNECTOR_CURVE_CIRCLE_START:
838         case SID_CONNECTOR_CURVE_CIRCLE_END:
839         case SID_CONNECTOR_CURVE_CIRCLES:
840         case SID_CONNECTOR_LINES:
841         case SID_CONNECTOR_LINES_ARROW_START:
842         case SID_CONNECTOR_LINES_ARROW_END:
843         case SID_CONNECTOR_LINES_ARROWS:
844         case SID_CONNECTOR_LINES_CIRCLE_START:
845         case SID_CONNECTOR_LINES_CIRCLE_END:
846         case SID_CONNECTOR_LINES_CIRCLES:
847         {
848             nMappedSId = SID_DRAWTBX_CONNECTORS;
849         }
850 	}
851 	return( nMappedSId );
852 }
853 
854 /*************************************************************************
855 |*
856 |* Fuellt das SlotArray, um das aktuelle Mapping des ToolboxSlots zu
857 |* bekommen
858 |*
859 \************************************************************************/
860 
MapSlot(sal_uInt16 nSId)861 void DrawViewShell::MapSlot( sal_uInt16 nSId )
862 {
863 	sal_uInt16 nMappedSId = GetIdBySubId( nSId );
864 
865 	if( nMappedSId > 0 )
866 	{
867 		sal_uInt16 nID = GetArrayId( nMappedSId ) + 1;
868 		mpSlotArray[ nID ] = nSId;
869 	}
870 }
871 
872 /*************************************************************************
873 |*
874 |* Ermoeglicht ueber das SlotArray ein ImageMapping
875 |*
876 \************************************************************************/
877 
UpdateToolboxImages(SfxItemSet & rSet,sal_Bool bPermanent)878 void DrawViewShell::UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent )
879 {
880 	if( !bPermanent )
881 	{
882 		sal_uInt16 nId = GetArrayId( SID_ZOOM_TOOLBOX ) + 1;
883 		rSet.Put( TbxImageItem( SID_ZOOM_TOOLBOX, mpSlotArray[nId] ) );
884 
885 		nId = GetArrayId( SID_DRAWTBX_INSERT ) + 1;
886 		rSet.Put( TbxImageItem( SID_DRAWTBX_INSERT, mpSlotArray[nId] ) );
887 
888 		nId = GetArrayId( SID_POSITION ) + 1;
889 		rSet.Put( TbxImageItem( SID_POSITION, mpSlotArray[nId] ) );
890 
891 		nId = GetArrayId( SID_OBJECT_ALIGN ) + 1;
892 		rSet.Put( TbxImageItem( SID_OBJECT_ALIGN, mpSlotArray[nId] ) );
893 	}
894 	else
895 	{
896 		for( sal_uInt16 nId = 0; nId < SLOTARRAY_COUNT; nId += 2 )
897 		{
898 			rSet.Put( TbxImageItem( mpSlotArray[nId], mpSlotArray[nId+1] ) );
899 		}
900 	}
901 }
902 
903 /*************************************************************************
904 |*
905 |* Gibt den gemappten Slot zurueck
906 |*
907 \************************************************************************/
908 
GetMappedSlot(sal_uInt16 nSId)909 sal_uInt16 DrawViewShell::GetMappedSlot( sal_uInt16 nSId )
910 {
911 	sal_uInt16 nSlot = 0;
912 	sal_uInt16 nId = GetArrayId( nSId );
913 	if( nId != USHRT_MAX )
914 		nSlot = mpSlotArray[ nId+1 ];
915 
916 	// Wenn der Slot noch auf sich selbst gemapped ist, muss 0 zurueck-
917 	// gegeben werden, da sonst der Slot immer wieder selbst executet
918 	// wird. Im Array ist der Slot selbst initial vorhanden, damit das
919 	// Image richtig angezeigt wird.
920 	if( nSId == nSlot )
921 		return( 0 );
922 
923 	return( nSlot );
924 }
925 
926 /*************************************************************************
927 |*
928 |* Gibt die Nummer des HauptSlots im SlotArray zurueck
929 |*
930 \************************************************************************/
931 
GetArrayId(sal_uInt16 nSId)932 sal_uInt16 DrawViewShell::GetArrayId( sal_uInt16 nSId )
933 {
934 	for( sal_uInt16 i = 0; i < SLOTARRAY_COUNT; i += 2 )
935 	{
936 		if( mpSlotArray[ i ] == nSId )
937 			return( i );
938 	}
939 	DBG_ERROR( "Slot im Array nicht gefunden!" );
940 	return( USHRT_MAX );
941 }
942 
943 
944 /*************************************************************************
945 |*
946 |* IMap-Dlg updaten
947 |*
948 \************************************************************************/
949 
UpdateIMapDlg(SdrObject * pObj)950 void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
951 {
952 	if( ( pObj->ISA( SdrGrafObj ) || pObj->ISA( SdrOle2Obj ) ) && !mpDrawView->IsTextEdit() &&
953 		 GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
954 	{
955 		Graphic 	aGraphic;
956 		ImageMap*	pIMap = NULL;
957 		TargetList*	pTargetList = NULL;
958 		SdIMapInfo* pIMapInfo = GetDoc()->GetIMapInfo( pObj );
959 
960 		// get graphic from shape
961 		SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( pObj );
962 		if( pGrafObj )
963 			aGraphic = pGrafObj->GetGraphic();
964 
965 		if ( pIMapInfo )
966 		{
967 			pIMap = (ImageMap*) &pIMapInfo->GetImageMap();
968 			pTargetList = new TargetList;
969 			GetViewFrame()->GetTargetList( *pTargetList );
970 		}
971 
972 		SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj );
973 
974 		// TargetListe kann von uns wieder geloescht werden
975 		if ( pTargetList )
976 		{
977 			String* pEntry = pTargetList->First();
978 			while( pEntry )
979 			{
980 				delete pEntry;
981 				pEntry = pTargetList->Next();
982 			}
983 
984 			delete pTargetList;
985 		}
986 	}
987 }
988 
989 // -----------------------------------------------------------------------------
990 
IMPL_LINK(DrawViewShell,NameObjectHdl,AbstractSvxNameDialog *,pDialog)991 IMPL_LINK( DrawViewShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
992 {
993     String aName;
994 
995     if( pDialog )
996         pDialog->GetName( aName );
997 
998     return( ( !aName.Len() || ( GetDoc() && !GetDoc()->GetObj( aName ) ) ) ? 1 : 0 );
999 }
1000 
1001 } // end of namespace sd
1002