xref: /aoo42x/main/sd/source/ui/view/drviewse.cxx (revision 79aad27f)
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 <com/sun/star/presentation/XPresentation2.hpp>
28 #include <com/sun/star/form/FormButtonType.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/i18n/TransliterationModules.hpp>
31 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
32 
33 #include <comphelper/processfactory.hxx>
34 
35 #include "undo/undomanager.hxx"
36 #include <vcl/waitobj.hxx>
37 #include <svl/aeitem.hxx>
38 #include <editeng/editstat.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <svl/urlbmk.hxx>
41 #include <svx/svdpagv.hxx>
42 #include <svx/fmshell.hxx>
43 #include <vcl/scrbar.hxx>
44 #include <svx/svdopath.hxx>
45 #include <svx/svdundo.hxx>
46 #include <svx/svdorect.hxx>
47 #include <svx/svdograf.hxx>
48 #include <svl/eitem.hxx>
49 #include <editeng/eeitem.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/viewfrm.hxx>
52 #include <sfx2/request.hxx>
53 #include <svx/svxids.hrc>
54 #include <editeng/flditem.hxx>
55 #include <svx/ruler.hxx>
56 #include <svx/obj3d.hxx>
57 #include <svx/fmglob.hxx>
58 #include <svx/svdouno.hxx>
59 #include <svx/dataaccessdescriptor.hxx>
60 #include <tools/urlobj.hxx>
61 #include <svl/slstitm.hxx>
62 #include <sfx2/ipclient.hxx>
63 #include <toolkit/helper/vclunohelper.hxx>
64 #include <avmedia/mediawindow.hxx>
65 #include <svl/urihelper.hxx>
66 #include <sfx2/docfile.hxx>
67 
68 #include "DrawViewShell.hxx"
69 #include "slideshow.hxx"
70 #include "ViewShellImplementation.hxx"
71 #include "ViewShellHint.hxx"
72 #include "framework/FrameworkHelper.hxx"
73 #include "app.hrc"
74 #include "glob.hrc"
75 #include "strings.hrc"
76 #include "res_bmp.hrc"
77 #include "drawdoc.hxx"
78 #include "fusel.hxx"
79 #include "futext.hxx"
80 #include "fuconrec.hxx"
81 #include "fuconcs.hxx"
82 #include "fuconuno.hxx"
83 #include "fuconbez.hxx"
84 #include "fuediglu.hxx"
85 #include "fuconarc.hxx"
86 #include "fucon3d.hxx"
87 #include "sdresid.hxx"
88 #include "slideshow.hxx"
89 #include "Outliner.hxx"
90 #include "PresentationViewShell.hxx"
91 #include "sdpage.hxx"
92 #include "FrameView.hxx"
93 #include "zoomlist.hxx"
94 #include "drawview.hxx"
95 #include "DrawDocShell.hxx"
96 #include "sdattr.hxx"
97 #include "ViewShellBase.hxx"
98 #include "ToolBarManager.hxx"
99 #include "anminfo.hxx"
100 #include "optsitem.hxx"
101 #include "Window.hxx"
102 #include "fuformatpaintbrush.hxx"
103 
104 using ::rtl::OUString;
105 using namespace ::com::sun::star;
106 using namespace ::com::sun::star::uno;
107 using namespace ::com::sun::star::presentation;
108 
109 namespace sd {
110 
111 #ifdef _MSC_VER
112 #pragma optimize ( "", off )
113 #endif
114 
115 /*************************************************************************
116 |*
117 |* Permanente Funktionen
118 |*
119 \************************************************************************/
120 
121 void ImpAddPrintableCharactersToTextEdit(SfxRequest& rReq, ::sd::View* pView)
122 {
123 	// #98198# evtl. feed characters to activated textedit
124 	const SfxItemSet* pSet = rReq.GetArgs();
125 
126 	if(pSet)
127 	{
128 		String aInputString;
129 
130 		if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_CHAR))
131 			aInputString = ((SfxStringItem&)pSet->Get(SID_ATTR_CHAR)).GetValue();
132 
133 		if(aInputString.Len())
134 		{
135 			OutlinerView* pOLV = pView->GetTextEditOutlinerView();
136 
137 			if(pOLV)
138 			{
139 				for(sal_uInt16 a(0); a < aInputString.Len(); a++)
140 				{
141 					sal_Char aChar = (sal_Char)aInputString.GetChar(a);
142 					KeyCode aKeyCode;
143 					KeyEvent aKeyEvent(aChar, aKeyCode);
144 
145 					// add actual character
146 					pOLV->PostKeyEvent(aKeyEvent);
147 				}
148 			}
149 		}
150 	}
151 }
152 
153 void DrawViewShell::FuPermanent(SfxRequest& rReq)
154 {
155 	// Waehrend einer Native-Diashow wird nichts ausgefuehrt!
156 
157 	if (SlideShow::IsRunning(GetViewShellBase()))
158 		return;
159 
160 	sal_uInt16 nSId = rReq.GetSlot();
161 
162 	if( HasCurrentFunction() &&
163 		( nSId == SID_TEXTEDIT || nSId == SID_ATTR_CHAR || nSId == SID_TEXT_FITTOSIZE ||
164 		  nSId == SID_ATTR_CHAR_VERTICAL || nSId == SID_TEXT_FITTOSIZE_VERTICAL ) )
165 	{
166 		FunctionReference xFunc( GetCurrentFunction() );
167 
168 		FuText* pFuText = dynamic_cast< FuText* >( xFunc.get() );
169 
170 		if( pFuText )
171 		{
172 			pFuText->SetPermanent(sal_True);
173 			xFunc->ReceiveRequest( rReq );
174 
175 			MapSlot( nSId );
176 
177 			Invalidate();
178 
179 			Invalidate();
180 
181 			// #98198# evtl. feed characters to activated textedit
182 			if(SID_ATTR_CHAR == nSId && GetView() && GetView()->IsTextEdit())
183 				ImpAddPrintableCharactersToTextEdit(rReq, GetView());
184 
185 			rReq.Done();
186 			return;
187 		}
188 	}
189 
190 	CheckLineTo (rReq);
191     sal_uInt16 nOldSId = 0;
192     sal_Bool bPermanent = sal_False;
193 
194 	if( !mpDrawView )
195 		return;
196 
197 	if(HasCurrentFunction())
198 	{
199 		if( (nSId == SID_FORMATPAINTBRUSH) && (GetCurrentFunction()->GetSlotID() == SID_TEXTEDIT) )
200 		{
201 			// save text edit mode for format paintbrush!
202 			SetOldFunction( GetCurrentFunction() );
203 		}
204 		else
205 		{
206 			if(GetOldFunction() == GetCurrentFunction())
207 			{
208 				SetOldFunction(0);
209 			}
210 		}
211 
212 		if ( nSId != SID_TEXTEDIT && nSId != SID_ATTR_CHAR && nSId != SID_TEXT_FITTOSIZE &&
213 			 nSId != SID_ATTR_CHAR_VERTICAL && nSId != SID_TEXT_FITTOSIZE_VERTICAL &&
214 			 nSId != SID_FORMATPAINTBRUSH &&
215 			 mpDrawView->IsTextEdit() )
216 		{
217 			mpDrawView->SdrEndTextEdit();
218 		}
219 
220 		if( HasCurrentFunction() )
221 		{
222 			nOldSId = GetCurrentFunction()->GetSlotID();
223 
224 			if (nOldSId == nSId ||
225 				((nOldSId == SID_TEXTEDIT || nOldSId == SID_ATTR_CHAR || nOldSId == SID_TEXT_FITTOSIZE ||
226 				nOldSId == SID_ATTR_CHAR_VERTICAL || nOldSId == SID_TEXT_FITTOSIZE_VERTICAL) &&
227 				(nSId == SID_TEXTEDIT || nSId == SID_ATTR_CHAR || nSId == SID_TEXT_FITTOSIZE ||
228 				nSId == SID_ATTR_CHAR_VERTICAL || nSId == SID_TEXT_FITTOSIZE_VERTICAL )))
229 			{
230 				bPermanent = sal_True;
231 			}
232 
233 			GetCurrentFunction()->Deactivate();
234 		}
235 
236 		SetCurrentFunction(0);
237 
238 		SfxBindings& rBind = GetViewFrame()->GetBindings();
239         rBind.Invalidate(nOldSId);
240         rBind.Update(nOldSId);
241 	}
242 
243 	// Slot wird gemapped (ToolboxImages/-Slots)
244 	MapSlot( nSId );
245 
246     switch ( nSId )
247 	{
248 		case SID_TEXTEDIT:	// BASIC ???
249 		case SID_ATTR_CHAR:
250 		case SID_ATTR_CHAR_VERTICAL:
251 		case SID_TEXT_FITTOSIZE:
252 		case SID_TEXT_FITTOSIZE_VERTICAL:
253 		{
254 			SetCurrentFunction( FuText::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
255 			GetCurrentFunction()->DoExecute(rReq);
256 
257 			SfxBindings& rBindings = GetViewFrame()->GetBindings();
258 			rBindings.Invalidate( SID_ATTR_CHAR );
259 			rBindings.Invalidate( SID_ATTR_CHAR_VERTICAL );
260 			rBindings.Invalidate( SID_TEXT_FITTOSIZE );
261 			rBindings.Invalidate( SID_TEXT_FITTOSIZE_VERTICAL );
262 
263 			// #98198# evtl. feed characters to activated textedit
264 			if(SID_ATTR_CHAR == nSId && GetView() && GetView()->IsTextEdit())
265 				ImpAddPrintableCharactersToTextEdit(rReq, GetView());
266 
267 			rReq.Done();
268 		}
269 		break;
270 
271 		case SID_FM_CREATE_CONTROL:
272 		{
273 			SetCurrentFunction( FuConstructUnoControl::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
274 			rReq.Done();
275 		}
276 		break;
277 
278 		// #98721#
279 		case SID_FM_CREATE_FIELDCONTROL:
280 		{
281 			SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
282 			DBG_ASSERT( pDescriptorItem, "DrawViewShell::FuPermanent(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
283 
284 			if(pDescriptorItem)
285 			{
286 				// get the form view
287 				FmFormView* pFormView = PTR_CAST(FmFormView, mpDrawView);
288 				SdrPageView* pPageView = pFormView ? pFormView->GetSdrPageView() : NULL;
289 
290 				if(pPageView)
291 				{
292 					::svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
293 					SdrObject* pNewDBField = pFormView->CreateFieldControl(aDescriptor);
294 
295 					if(pNewDBField)
296 					{
297 						Rectangle aVisArea = GetActiveWindow()->PixelToLogic(Rectangle(Point(0,0), GetActiveWindow()->GetOutputSizePixel()));
298 						Point aObjPos(aVisArea.Center());
299 						Size aObjSize(pNewDBField->GetLogicRect().GetSize());
300 						aObjPos.X() -= aObjSize.Width() / 2;
301 						aObjPos.Y() -= aObjSize.Height() / 2;
302 						Rectangle aNewObjectRectangle(aObjPos, aObjSize);
303 
304 						pNewDBField->SetLogicRect(aNewObjectRectangle);
305 
306 						GetView()->InsertObjectAtView(pNewDBField, *pPageView);
307 					}
308 				}
309 			}
310 			rReq.Done();
311 		}
312 		break;
313 
314 		case SID_OBJECT_SELECT:
315 		case SID_OBJECT_ROTATE:
316 		case SID_OBJECT_MIRROR:
317 		case SID_OBJECT_CROP:
318 		case SID_OBJECT_TRANSPARENCE:
319 		case SID_OBJECT_GRADIENT:
320 		case SID_OBJECT_SHEAR:
321 		case SID_OBJECT_CROOK_ROTATE:
322 		case SID_OBJECT_CROOK_SLANT:
323 		case SID_OBJECT_CROOK_STRETCH:
324         case SID_CONVERT_TO_3D_LATHE:
325 		{
326 			short nSlotId = rReq.GetSlot();
327 
328 			if( nSlotId == SID_OBJECT_ROTATE )
329 			{
330 				// togle rotation
331 				if( nOldSId == nSlotId )
332 				{
333 					nSlotId = SID_OBJECT_SELECT;
334 					rReq.SetSlot( nSlotId );
335 				}
336 			}
337 
338 			if (nSlotId == SID_OBJECT_CROOK_ROTATE ||
339 				nSlotId == SID_OBJECT_CROOK_SLANT ||
340 				nSlotId == SID_OBJECT_CROOK_STRETCH)
341 			{
342 				if ( mpDrawView->GetMarkedObjectList().GetMarkCount() > 0 &&
343 				    !mpDrawView->IsCrookAllowed( mpDrawView->IsCrookNoContortion() ) )
344 				{
345 					if ( mpDrawView->IsPresObjSelected() )
346 					{
347                         ::sd::Window* pWindow = GetActiveWindow();
348                         InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
349 					}
350 					else if ( QueryBox(GetActiveWindow(), WB_YES_NO,
351                                       String(SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER) )
352 									  ).Execute() == RET_YES )
353 					{
354 						// Implizite Wandlung in Bezier
355                         WaitObject aWait( (Window*)GetActiveWindow() );
356 						mpDrawView->ConvertMarkedToPathObj(sal_False);
357 					}
358 				}
359 			}
360 			else if (nSlotId == SID_OBJECT_SHEAR)
361 			{
362                 sal_uLong i = 0;
363                 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
364                 sal_uLong nMarkCnt = rMarkList.GetMarkCount();
365                 sal_Bool b3DObjMarked = sal_False;
366 
367                 while (i < nMarkCnt && !b3DObjMarked)
368                 {
369                     if (rMarkList.GetMark(i)->GetMarkedSdrObj()->ISA(E3dObject))
370                     {
371                         b3DObjMarked = sal_True;
372                     }
373                     else
374                     {
375                         i++;
376                     }
377                 }
378 
379                 if ( nMarkCnt > 0 && !b3DObjMarked &&
380                      (!mpDrawView->IsShearAllowed() || !mpDrawView->IsDistortAllowed()) )
381 				{
382 					if ( mpDrawView->IsPresObjSelected() )
383 					{
384                         ::sd::Window* pWindow = GetActiveWindow();
385                         InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
386 					}
387 					else if ( QueryBox(GetActiveWindow(), WB_YES_NO,
388                                       String(SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER) )
389 									  ).Execute() == RET_YES )
390 					{
391 						// Implizite Wandlung in Bezier
392                         WaitObject aWait( (Window*)GetActiveWindow() );
393 						mpDrawView->ConvertMarkedToPathObj(sal_False);
394 					}
395 				}
396 			}
397 
398 			SetCurrentFunction( FuSelection::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
399 			rReq.Done();
400 			Invalidate( SID_OBJECT_SELECT );
401 		}
402 		break;
403 
404 		case SID_DRAW_LINE:
405 		case SID_DRAW_XLINE:
406         case SID_DRAW_MEASURELINE:
407 		case SID_LINE_ARROW_START:
408 		case SID_LINE_ARROW_END:
409 		case SID_LINE_ARROWS:
410 		case SID_LINE_ARROW_CIRCLE:
411 		case SID_LINE_CIRCLE_ARROW:
412 		case SID_LINE_ARROW_SQUARE:
413 		case SID_LINE_SQUARE_ARROW:
414 
415 		case SID_DRAW_RECT:
416 		case SID_DRAW_RECT_NOFILL:
417 		case SID_DRAW_RECT_ROUND:
418 		case SID_DRAW_RECT_ROUND_NOFILL:
419 		case SID_DRAW_SQUARE:
420 		case SID_DRAW_SQUARE_NOFILL:
421 		case SID_DRAW_SQUARE_ROUND:
422 		case SID_DRAW_SQUARE_ROUND_NOFILL:
423 		case SID_DRAW_ELLIPSE:
424 		case SID_DRAW_ELLIPSE_NOFILL:
425 		case SID_DRAW_CIRCLE:
426 		case SID_DRAW_CIRCLE_NOFILL:
427 		case SID_DRAW_CAPTION:
428 		case SID_DRAW_CAPTION_VERTICAL:
429 		case SID_TOOL_CONNECTOR:
430         case SID_CONNECTOR_ARROW_START:
431         case SID_CONNECTOR_ARROW_END:
432         case SID_CONNECTOR_ARROWS:
433         case SID_CONNECTOR_CIRCLE_START:
434         case SID_CONNECTOR_CIRCLE_END:
435         case SID_CONNECTOR_CIRCLES:
436         case SID_CONNECTOR_LINE:
437         case SID_CONNECTOR_LINE_ARROW_START:
438         case SID_CONNECTOR_LINE_ARROW_END:
439         case SID_CONNECTOR_LINE_ARROWS:
440         case SID_CONNECTOR_LINE_CIRCLE_START:
441         case SID_CONNECTOR_LINE_CIRCLE_END:
442         case SID_CONNECTOR_LINE_CIRCLES:
443         case SID_CONNECTOR_CURVE:
444         case SID_CONNECTOR_CURVE_ARROW_START:
445         case SID_CONNECTOR_CURVE_ARROW_END:
446         case SID_CONNECTOR_CURVE_ARROWS:
447         case SID_CONNECTOR_CURVE_CIRCLE_START:
448         case SID_CONNECTOR_CURVE_CIRCLE_END:
449         case SID_CONNECTOR_CURVE_CIRCLES:
450         case SID_CONNECTOR_LINES:
451         case SID_CONNECTOR_LINES_ARROW_START:
452         case SID_CONNECTOR_LINES_ARROW_END:
453         case SID_CONNECTOR_LINES_ARROWS:
454         case SID_CONNECTOR_LINES_CIRCLE_START:
455         case SID_CONNECTOR_LINES_CIRCLE_END:
456         case SID_CONNECTOR_LINES_CIRCLES:
457         {
458 			SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
459             rReq.Done();
460 		}
461 		break;
462 		case SID_DRAW_POLYGON:
463 		case SID_DRAW_POLYGON_NOFILL:
464 		case SID_DRAW_XPOLYGON:
465 		case SID_DRAW_XPOLYGON_NOFILL:
466         case SID_DRAW_FREELINE:
467         case SID_DRAW_FREELINE_NOFILL:
468         case SID_DRAW_BEZIER_FILL:          // BASIC
469         case SID_DRAW_BEZIER_NOFILL:        // BASIC
470 		{
471 			SetCurrentFunction( FuConstructBezierPolygon::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent) );
472             rReq.Done();
473 		}
474 		break;
475 
476         case SID_GLUE_EDITMODE:
477 		{
478             if (nOldSId != SID_GLUE_EDITMODE)
479             {
480 				SetCurrentFunction( FuEditGluePoints::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
481             }
482             else
483             {
484 				GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
485             }
486 
487 			rReq.Done();
488 		}
489 		break;
490 
491 		case SID_DRAW_ARC:
492 		case SID_DRAW_CIRCLEARC:
493 		case SID_DRAW_PIE:
494 		case SID_DRAW_PIE_NOFILL:
495 		case SID_DRAW_CIRCLEPIE:
496 		case SID_DRAW_CIRCLEPIE_NOFILL:
497 		case SID_DRAW_ELLIPSECUT:
498 		case SID_DRAW_ELLIPSECUT_NOFILL:
499 		case SID_DRAW_CIRCLECUT:
500 		case SID_DRAW_CIRCLECUT_NOFILL:
501 		{
502 			SetCurrentFunction( FuConstructArc::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent) );
503             rReq.Done();
504 		}
505 		break;
506 
507 		case SID_3D_CUBE:
508 		case SID_3D_SHELL:
509 		case SID_3D_SPHERE:
510 		case SID_3D_TORUS:
511 		case SID_3D_HALF_SPHERE:
512 		case SID_3D_CYLINDER:
513 		case SID_3D_CONE:
514 		case SID_3D_PYRAMID:
515 		{
516 			SetCurrentFunction( FuConstruct3dObject::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
517             rReq.Done();
518 		}
519 		break;
520 
521 		case SID_DRAWTBX_CS_BASIC :
522 		case SID_DRAWTBX_CS_SYMBOL :
523 		case SID_DRAWTBX_CS_ARROW :
524 		case SID_DRAWTBX_CS_FLOWCHART :
525 		case SID_DRAWTBX_CS_CALLOUT :
526 		case SID_DRAWTBX_CS_STAR :
527 		case SID_DRAW_CS_ID :
528 		{
529 			SetCurrentFunction( FuConstructCustomShape::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
530             rReq.Done();
531 
532             if ( nSId != SID_DRAW_CS_ID )
533             {
534                 SfxBindings& rBind = GetViewFrame()->GetBindings();
535                 rBind.Invalidate( nSId );
536                 rBind.Update( nSId );
537             }
538 		}
539 		break;
540 
541         case SID_FORMATPAINTBRUSH:
542         {
543     		SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
544     		rReq.Done();
545             SfxBindings& rBind = GetViewFrame()->GetBindings();
546             rBind.Invalidate( nSId );
547             rBind.Update( nSId );
548             break;
549         }
550 
551         default:
552    		break;
553 	}
554 
555 	if(HasOldFunction())
556 	{
557 		sal_uInt16 nSlotId = GetOldFunction()->GetSlotID();
558 
559 		GetOldFunction()->Deactivate();
560 		SetOldFunction(0);
561 
562 		SfxBindings& rBind = GetViewFrame()->GetBindings();
563 		rBind.Invalidate( nSlotId );
564 		rBind.Update( nSlotId );
565 	}
566 
567 	if(HasCurrentFunction())
568 	{
569 		GetCurrentFunction()->Activate();
570 		SetOldFunction( GetCurrentFunction() );
571 
572 		SetHelpId( GetCurrentFunction()->GetSlotID() );
573 	}
574 
575 	// Shell wird invalidiert, schneller als einzeln (laut MI)
576 	// Jetzt explizit der letzte Slot incl. Update()
577 	Invalidate();
578 
579 	// #97016# III CTRL-SID_OBJECT_SELECT -> select first draw object if none is selected yet
580 	if(SID_OBJECT_SELECT == nSId && HasCurrentFunction() && (rReq.GetModifier() & KEY_MOD1))
581 	{
582 		if(!GetView()->AreObjectsMarked())
583 		{
584 			// select first object
585 			GetView()->UnmarkAllObj();
586 			GetView()->MarkNextObj(sal_True);
587 
588 			// ...and make it visible
589 			if(GetView()->AreObjectsMarked())
590 				GetView()->MakeVisible(GetView()->GetAllMarkedRect(), *GetActiveWindow());
591 		}
592 	}
593 
594 	// #97016# with qualifier construct directly
595 	if(HasCurrentFunction() && (rReq.GetModifier() & KEY_MOD1))
596 	{
597 		// get SdOptions
598 		SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
599 		sal_uInt32 nDefaultObjectSizeWidth(pOptions->GetDefaultObjectSizeWidth());
600 		sal_uInt32 nDefaultObjectSizeHeight(pOptions->GetDefaultObjectSizeHeight());
601 
602 		// calc position and size
603 		Rectangle aVisArea = GetActiveWindow()->PixelToLogic(Rectangle(Point(0,0), GetActiveWindow()->GetOutputSizePixel()));
604 		Point aPagePos = aVisArea.Center();
605 		aPagePos.X() -= nDefaultObjectSizeWidth / 2;
606 		aPagePos.Y() -= nDefaultObjectSizeHeight / 2;
607 		Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
608 		SdrPageView* pPageView = mpDrawView->GetSdrPageView();
609 
610 		if(pPageView)
611 		{
612 			// create the default object
613 			SdrObject* pObj = GetCurrentFunction()->CreateDefaultObject(nSId, aNewObjectRectangle);
614 
615 			if(pObj)
616 			{
617 				// insert into page
618 				GetView()->InsertObjectAtView(pObj, *pPageView);
619 
620                 // Now that pFuActual has done what it was created for we
621                 // can switch on the edit mode for callout objects.
622                 switch (nSId)
623                 {
624                     case SID_DRAW_CAPTION:
625                     case SID_DRAW_CAPTION_VERTICAL:
626                     {
627                         // Make FuText the current function.
628                         SfxUInt16Item aItem (SID_TEXTEDIT, 1);
629                         GetViewFrame()->GetDispatcher()->
630                             Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON |
631                                 SFX_CALLMODE_RECORD, &aItem, 0L);
632                         // Put text object into edit mode.
633                         GetView()->SdrBeginTextEdit(static_cast<SdrTextObj*>(pObj), pPageView);
634                         break;
635                     }
636                 }
637 			}
638 		}
639 	}
640 }
641 
642 //////////////////////////////////////////////////////////////////////////////
643 // service routine for Undo/Redo implementation
644 extern SfxUndoManager* ImpGetUndoManagerFromViewShell(DrawViewShell& rDViewShell);
645 
646 /*************************************************************************
647 |*
648 |* SfxRequests fuer Support-Funktionen
649 |*
650 \************************************************************************/
651 
652 void DrawViewShell::FuSupport(SfxRequest& rReq)
653 {
654 	if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
655 		GetDocSh()->SetStyleFamily(((SfxUInt16Item&)rReq.GetArgs()->Get( SID_STYLE_FAMILY )).GetValue());
656 
657 	// Waehrend einer Native-Diashow wird nichts ausgefuehrt!
658 	if(SlideShow::IsRunning(GetViewShellBase()) &&
659 		(rReq.GetSlot() != SID_PRESENTATION_END &&
660          rReq.GetSlot() != SID_SIZE_PAGE))
661 		return;
662 
663 	CheckLineTo (rReq);
664 
665 	if( !mpDrawView )
666 		return;
667 
668 	sal_uInt16 nSId = rReq.GetSlot();
669 
670 	// Slot wird evtl. gemapped (ToolboxImages/-Slots)
671 	MapSlot( nSId );
672 
673 	switch ( nSId )
674 	{
675 		case SID_CLEAR_UNDO_STACK:
676 		{
677 			GetDocSh()->ClearUndoBuffer();
678             rReq.Ignore ();
679 		}
680 		break;
681 
682         // Slots der ToolboxController gemapped ausfuehren
683         case SID_OBJECT_CHOOSE_MODE:
684         case SID_POSITION:
685         case SID_OBJECT_ALIGN:
686         case SID_ZOOM_TOOLBOX:
687         case SID_DRAWTBX_TEXT:
688         case SID_DRAWTBX_RECTANGLES:
689         case SID_DRAWTBX_ELLIPSES:
690         case SID_DRAWTBX_LINES:
691         case SID_DRAWTBX_ARROWS:
692         case SID_DRAWTBX_3D_OBJECTS:
693         case SID_DRAWTBX_CONNECTORS:
694         case SID_DRAWTBX_INSERT:
695         {
696             sal_uInt16 nMappedSlot = GetMappedSlot( nSId );
697             if( nMappedSlot > 0 )
698             {
699                 SfxRequest aReq( nMappedSlot, 0, GetDoc()->GetItemPool() );
700                 ExecuteSlot( aReq );
701             }
702         }
703         break;
704 
705 		case SID_PRESENTATION:
706 		case SID_REHEARSE_TIMINGS:
707 		{
708 			Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
709 			if( xPresentation.is() )
710 			{
711 				if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) )
712 					xPresentation->start();
713 				else
714 					xPresentation->rehearseTimings();
715 			}
716 			rReq.Ignore ();
717         }
718 		break;
719 
720 		case SID_PRESENTATION_END:
721 		{
722             StopSlideShow(true);
723 
724             rReq.Ignore ();
725 		}
726 		break;
727 
728 		case SID_BEZIER_EDIT:
729 		{
730             mpDrawView->SetFrameDragSingles(!mpDrawView->IsFrameDragSingles());
731 
732             /******************************************************************
733             * ObjectBar einschalten
734             ******************************************************************/
735             if( dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) || dynamic_cast< FuConstructBezierPolygon* >( GetCurrentFunction().get() ) )
736             {
737                 // Tell the tool bar manager about the context change.
738 				GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
739             }
740 
741             Invalidate(SID_BEZIER_EDIT);
742             rReq.Ignore();
743         }
744         break;
745 
746 		case SID_OBJECT_CLOSE:
747 		{
748 			const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
749 			if ( rMarkList.GetMark(0) && !mpDrawView->IsAction() )
750 			{
751 				SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
752 				const bool bUndo = mpDrawView->IsUndoEnabled();
753 				if( bUndo )
754 					mpDrawView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
755 
756 				mpDrawView->UnmarkAllPoints();
757 
758 				if( bUndo )
759 					mpDrawView->AddUndo(new SdrUndoGeoObj(*pPathObj));
760 
761 				pPathObj->ToggleClosed();
762 
763 				if( bUndo )
764 					mpDrawView->EndUndo();
765 			}
766 			rReq.Done();
767 		}
768 		break;
769 
770 		case SID_CUT:
771 		{
772 			if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
773 			{
774                 ::sd::Window* pWindow = GetActiveWindow();
775                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
776 			}
777 			else
778 			{
779 				if(HasCurrentFunction())
780 				{
781 					GetCurrentFunction()->DoCut();
782 				}
783 				else if(mpDrawView)
784 				{
785 					mpDrawView->DoCut();
786 				}
787 			}
788 			rReq.Ignore ();
789 		}
790 		break;
791 
792 		case SID_COPY:
793 		{
794 			if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
795 			{
796                 ::sd::Window* pWindow = GetActiveWindow();
797                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
798 			}
799 			else
800 			{
801 				if(HasCurrentFunction())
802 				{
803 					GetCurrentFunction()->DoCopy();
804 				}
805 				else if( mpDrawView )
806 				{
807 					mpDrawView->DoCopy();
808 				}
809 			}
810 			rReq.Ignore ();
811 		}
812 		break;
813 
814 		case SID_PASTE:
815 		{
816 			WaitObject aWait( (Window*)GetActiveWindow() );
817 
818 			if(HasCurrentFunction())
819 			{
820 				GetCurrentFunction()->DoPaste();
821 			}
822 			else if(mpDrawView)
823 			{
824 				mpDrawView->DoPaste();
825 			}
826 
827 			rReq.Ignore ();
828 		}
829 		break;
830 
831         case SID_CLIPBOARD_FORMAT_ITEMS:
832         {
833 			WaitObject              aWait( (Window*)GetActiveWindow() );
834 	        TransferableDataHelper  aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
835             const SfxItemSet*       pReqArgs = rReq.GetArgs();
836             sal_uInt32                  nFormat = 0;
837 
838             if( pReqArgs )
839             {
840                 SFX_REQUEST_ARG( rReq, pIsActive, SfxUInt32Item, SID_CLIPBOARD_FORMAT_ITEMS, sal_False );
841                 nFormat = pIsActive->GetValue();
842             }
843 
844 
845 	        if( nFormat && aDataHelper.GetTransferable().is() )
846 	        {
847 		        sal_Int8 nAction = DND_ACTION_COPY;
848 
849                 if( !mpDrawView->InsertData( aDataHelper,
850 						                  GetActiveWindow()->PixelToLogic( Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
851 						                  nAction, sal_False, nFormat ) )
852                 {
853 			        INetBookmark    aINetBookmark( aEmptyStr, aEmptyStr );
854 
855 			        if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
856 				          aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
857 				        ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
858 				          aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
859 				        ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
860 				          aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
861 			        {
862 				        InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
863 			        }
864                 }
865 	        }
866         }
867         break;
868 
869 		case SID_DELETE:
870 		{
871 			if ( mpDrawView->IsTextEdit() )
872 			{
873 				OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
874 
875 				if (pOLV)
876 				{
877 					KeyCode aKCode(KEY_DELETE);
878 					KeyEvent aKEvt( 0, aKCode);
879 					pOLV->PostKeyEvent(aKEvt);
880 				}
881 			}
882 			else if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
883 			{
884                 ::sd::Window* pWindow = GetActiveWindow();
885                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
886 			}
887 			else
888 			{
889 				KeyCode aKCode(KEY_DELETE);
890 				KeyEvent aKEvt( 0, aKCode);
891 
892 				bool bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
893 
894 				if( !bConsumed && HasCurrentFunction() )
895 					bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
896 
897 				if( !bConsumed && mpDrawView )
898 					mpDrawView->DeleteMarked();
899 			}
900 			rReq.Ignore ();
901 		}
902 		break;
903 
904         case SID_NOTESMODE:
905 		case SID_HANDOUTMODE:
906 			// AutoLayouts have to be ready.
907 			GetDoc()->StopWorkStartupDelay();
908             // Fall through to following case statements.
909 
910         case SID_DRAWINGMODE:
911 		case SID_DIAMODE:
912         case SID_OUTLINEMODE:
913             // Let the sub-shell manager handle the slot handling.
914             framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
915                 nSId,
916                 rReq);
917 			rReq.Ignore ();
918             break;
919 
920         case SID_MASTERPAGE:          // BASIC
921         case SID_SLIDE_MASTERPAGE:    // BASIC
922         case SID_TITLE_MASTERPAGE:    // BASIC
923         case SID_NOTES_MASTERPAGE:    // BASIC
924         case SID_HANDOUT_MASTERPAGE:  // BASIC
925 		{
926 			// AutoLayouts muessen fertig sein
927 			GetDoc()->StopWorkStartupDelay();
928 
929 			const SfxItemSet* pReqArgs = rReq.GetArgs();
930 
931 			if ( pReqArgs )
932 			{
933 				SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, SID_MASTERPAGE, sal_False);
934 				mbIsLayerModeActive = pIsActive->GetValue ();
935 			}
936 
937             Broadcast (
938                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
939 
940             if (nSId == SID_MASTERPAGE                                       ||
941                 (nSId == SID_SLIDE_MASTERPAGE   && mePageKind == PK_STANDARD) ||
942                 (nSId == SID_TITLE_MASTERPAGE   && mePageKind == PK_STANDARD) ||
943                 (nSId == SID_NOTES_MASTERPAGE   && mePageKind == PK_NOTES)    ||
944                 (nSId == SID_HANDOUT_MASTERPAGE && mePageKind == PK_HANDOUT))
945             {
946                 if (nSId == SID_TITLE_MASTERPAGE ||
947 					nSId == SID_SLIDE_MASTERPAGE)
948                 {
949                     // Gibt es eine Seite mit dem AutoLayout "Titel"?
950                     sal_Bool bFound = sal_False;
951                     sal_uInt16 i = 0;
952                     sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
953 
954                     while (i < nCount && !bFound)
955                     {
956                         SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
957 
958                         if (nSId == SID_TITLE_MASTERPAGE && pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
959                         {
960                             bFound = sal_True;
961                             SwitchPage((pPage->GetPageNum() - 1) / 2);
962                         }
963                         else if (nSId == SID_SLIDE_MASTERPAGE && pPage->GetAutoLayout() != AUTOLAYOUT_TITLE)
964                         {
965                             bFound = sal_True;
966                             SwitchPage((pPage->GetPageNum() - 1) / 2);
967                         }
968 
969                         i++;
970                     }
971                 }
972 
973                 // Default-Layer der MasterPage einschalten
974                 mpDrawView->SetActiveLayer( String( SdResId(STR_LAYER_BCKGRNDOBJ) ) );
975 
976                 ChangeEditMode(EM_MASTERPAGE, mbIsLayerModeActive);
977 
978                 if(HasCurrentFunction(SID_BEZIER_EDIT))
979 					GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
980             }
981             else
982             {
983                 // Switch to requested ViewShell.
984                 ::OUString sRequestedView;
985                 PageKind ePageKind;
986                 switch (nSId)
987                 {
988                     case SID_SLIDE_MASTERPAGE:
989                     case SID_TITLE_MASTERPAGE:
990                     default:
991                         sRequestedView = framework::FrameworkHelper::msImpressViewURL;
992                         ePageKind = PK_STANDARD;
993                         break;
994 
995                     case SID_NOTES_MASTERPAGE:
996                         sRequestedView = framework::FrameworkHelper::msNotesViewURL;
997                         ePageKind = PK_NOTES;
998                         break;
999 
1000                     case SID_HANDOUT_MASTERPAGE:
1001                         sRequestedView = framework::FrameworkHelper::msHandoutViewURL;
1002                         ePageKind = PK_HANDOUT;
1003                         break;
1004                 }
1005 
1006                 mpFrameView->SetViewShEditMode(EM_MASTERPAGE, ePageKind);
1007                 mpFrameView->SetLayerMode(mbIsLayerModeActive);
1008                 framework::FrameworkHelper::Instance(GetViewShellBase())->RequestView(
1009                     sRequestedView,
1010                     framework::FrameworkHelper::msCenterPaneURL);
1011             }
1012             Broadcast (
1013                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
1014 
1015 			InvalidateWindows();
1016 			Invalidate();
1017 
1018 			rReq.Done();
1019 		}
1020 		break;
1021 
1022 
1023         case SID_CLOSE_MASTER_VIEW:
1024         {
1025             Broadcast (
1026                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
1027 
1028             // Switch page back to the first one.  Not doing so leads to a
1029             // crash.  This seems to be some bug in the edit mode switching
1030             // and page switching methods.
1031 			SwitchPage (0);
1032             ChangeEditMode(EM_PAGE, IsLayerModeActive());
1033             Broadcast (
1034                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
1035 
1036             if(HasCurrentFunction(SID_BEZIER_EDIT))
1037             {
1038                 GetViewFrame()->GetDispatcher()->Execute(
1039                     SID_OBJECT_SELECT,
1040                     SFX_CALLMODE_ASYNCHRON);
1041             }
1042 
1043 
1044 			rReq.Done();
1045         }
1046         break;
1047 
1048 
1049 		case SID_RULER:
1050         {
1051 			const SfxItemSet* pReqArgs = rReq.GetArgs();
1052 
1053 			// #97516# Remember old ruler state
1054 			sal_Bool bOldHasRuler(HasRuler());
1055 
1056 			if ( pReqArgs )
1057 			{
1058 				SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, SID_RULER, sal_False);
1059 				SetRuler (pIsActive->GetValue ());
1060 			}
1061 			else SetRuler (!HasRuler());
1062 
1063 			// #97516# Did ruler state change? Tell that to SdOptions, too.
1064 			sal_Bool bHasRuler(HasRuler());
1065 
1066 			if(bOldHasRuler != bHasRuler)
1067 			{
1068 				SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
1069 
1070 				if(pOptions && pOptions->IsRulerVisible() != bHasRuler)
1071 				{
1072 					pOptions->SetRulerVisible(bHasRuler);
1073 				}
1074 			}
1075 
1076             Invalidate (SID_RULER);
1077             Resize();
1078             rReq.Done ();
1079         }
1080         break;
1081 
1082 		case SID_SIZE_PAGE:
1083 		case SID_SIZE_PAGE_WIDTH:  // BASIC
1084 		{
1085 			mbZoomOnPage = ( rReq.GetSlot() == SID_SIZE_PAGE );
1086 
1087 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1088 
1089 			if ( pPageView )
1090 			{
1091 				Point aPagePos(0, 0); // = pPageView->GetOffset();
1092 				Size aPageSize = pPageView->GetPage()->GetSize();
1093 
1094 				aPagePos.X() += aPageSize.Width()  / 2;
1095                 aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
1096 
1097                 if( rReq.GetSlot() == SID_SIZE_PAGE )
1098 				{
1099 					aPagePos.Y() += aPageSize.Height() / 2;
1100                     aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
1101 					aPagePos.Y() -= aPageSize.Height() / 2;
1102 				}
1103 				else
1104 				{
1105 					Point aPt = GetActiveWindow()->PixelToLogic( Point( 0, GetActiveWindow()->GetSizePixel().Height() / 2 ) );
1106 					aPagePos.Y() += aPt.Y();
1107 					aPageSize.Height() = 2;
1108 				}
1109 
1110 				aPagePos.X() -= aPageSize.Width()  / 2;
1111 
1112 				SetZoomRect( Rectangle( aPagePos, aPageSize ) );
1113 
1114 				Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1115 											  GetActiveWindow()->GetOutputSizePixel()) );
1116 				mpZoomList->InsertZoomRect(aVisAreaWin);
1117 			}
1118 			Invalidate( SID_ZOOM_IN );
1119 			Invalidate( SID_ZOOM_OUT );
1120 			Invalidate( SID_ZOOM_PANNING );
1121 			Invalidate( SID_ZOOM_TOOLBOX );
1122 			rReq.Done ();
1123 		}
1124 		break;
1125 
1126 		case SID_SIZE_REAL:  // BASIC
1127 		{
1128 			mbZoomOnPage = sal_False;
1129 			SetZoom( 100 );
1130 			Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1131 											  GetActiveWindow()->GetOutputSizePixel()) );
1132 			mpZoomList->InsertZoomRect(aVisAreaWin);
1133 			Invalidate( SID_ZOOM_IN );
1134 			Invalidate( SID_ZOOM_OUT );
1135 			Invalidate( SID_ZOOM_PANNING );
1136 			Invalidate( SID_ZOOM_TOOLBOX );
1137 			rReq.Done ();
1138 		}
1139 		break;
1140 
1141 		case SID_ZOOM_IN:  // BASIC
1142 		{
1143 			mbZoomOnPage = sal_False;
1144 			SetZoom( Max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
1145 			Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1146 											  GetActiveWindow()->GetOutputSizePixel()) );
1147 			mpZoomList->InsertZoomRect(aVisAreaWin);
1148 			Invalidate( SID_ZOOM_IN );
1149 			Invalidate( SID_ZOOM_OUT );
1150 			Invalidate( SID_ZOOM_PANNING );
1151 			Invalidate( SID_ZOOM_TOOLBOX );
1152 			rReq.Done ();
1153 		}
1154 		break;
1155 
1156 		case SID_SIZE_VISAREA:
1157 		{
1158 			Rectangle aVisArea = mpFrameView->GetVisArea();
1159 			Size aVisAreaSize = aVisArea.GetSize();
1160 
1161 			if (aVisAreaSize.Height()!=0 && aVisAreaSize.Width()!=0)
1162 			{
1163 				mbZoomOnPage = sal_False;
1164 				SetZoomRect(aVisArea);
1165 				Invalidate( SID_ZOOM_IN );
1166 				Invalidate( SID_ZOOM_OUT );
1167 				Invalidate( SID_ZOOM_PANNING );
1168 				Invalidate( SID_ZOOM_TOOLBOX );
1169 			}
1170 			rReq.Done ();
1171 		}
1172 		break;
1173 
1174 		// Namensverwirrung: SID_SIZE_OPTIMAL -> Zoom auf selektierte Objekte
1175 		// --> Wird als Objektzoom im Programm angeboten
1176 		case SID_SIZE_OPTIMAL:	// BASIC
1177 		{
1178 			mbZoomOnPage = sal_False;
1179 			if ( mpDrawView->AreObjectsMarked() )
1180 			{
1181                 maMarkRect = mpDrawView->GetAllMarkedRect();
1182                 long nW = (long) (maMarkRect.GetWidth()  * 1.03);
1183                 long nH = (long) (maMarkRect.GetHeight() * 1.03);
1184 				Point aPos = maMarkRect.Center();
1185 				aPos.X() -= nW / 2;
1186 				aPos.Y() -= nH / 2;
1187 				if ( nW && nH )
1188 				{
1189 					SetZoomRect(Rectangle(aPos, Size(nW, nH)));
1190 
1191 					Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1192 											  GetActiveWindow()->GetOutputSizePixel()) );
1193 					mpZoomList->InsertZoomRect(aVisAreaWin);
1194 				}
1195 			}
1196 			Invalidate( SID_ZOOM_IN );
1197 			Invalidate( SID_ZOOM_OUT );
1198 			Invalidate( SID_ZOOM_PANNING );
1199 			Invalidate( SID_ZOOM_TOOLBOX );
1200 			rReq.Done ();
1201 		}
1202 		break;
1203 
1204 		// Namensverwirrung: SID_SIZE_ALL -> Zoom auf alle Objekte
1205 		// --> Wird als Optimal im Programm angeboten
1206 		case SID_SIZE_ALL:	// BASIC
1207 		{
1208 			mbZoomOnPage = sal_False;
1209 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1210 
1211 			if( pPageView )
1212 			{
1213 				Rectangle aBoundRect( pPageView->GetObjList()->GetAllObjBoundRect() );
1214 
1215                 long nW = (long) (aBoundRect.GetWidth() * 1.03);
1216                 long nH = (long) (aBoundRect.GetHeight() * 1.03);
1217 				Point aPos = aBoundRect.Center();
1218 				aPos.X() -= nW / 2;
1219 				aPos.Y() -= nH / 2;
1220 				if ( nW && nH )
1221 				{
1222 					SetZoomRect( Rectangle( aPos, Size( nW, nH ) ) );
1223 
1224 					Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1225 											  GetActiveWindow()->GetOutputSizePixel()) );
1226 					mpZoomList->InsertZoomRect(aVisAreaWin);
1227 				}
1228 
1229 				Invalidate( SID_ZOOM_IN );
1230 				Invalidate( SID_ZOOM_OUT );
1231 				Invalidate( SID_ZOOM_PANNING );
1232 				Invalidate( SID_ZOOM_TOOLBOX );
1233 			}
1234 			rReq.Done ();
1235 		}
1236 		break;
1237 
1238 		case SID_ZOOM_PREV:
1239 		{
1240 			if (mpDrawView->IsTextEdit())
1241 			{
1242 				mpDrawView->SdrEndTextEdit();
1243 			}
1244 
1245 			if (mpZoomList->IsPreviousPossible())
1246 			{
1247 				// Vorheriges ZoomRect einstellen
1248 				SetZoomRect(mpZoomList->GetPreviousZoomRect());
1249 			}
1250 			rReq.Done ();
1251 			Invalidate( SID_ZOOM_TOOLBOX );
1252 		}
1253 		break;
1254 
1255 		case SID_ZOOM_NEXT:
1256 		{
1257 			if (mpDrawView->IsTextEdit())
1258 			{
1259 				mpDrawView->SdrEndTextEdit();
1260 			}
1261 
1262 			if (mpZoomList->IsNextPossible())
1263 			{
1264 				// Naechstes ZoomRect einstellen
1265 				SetZoomRect(mpZoomList->GetNextZoomRect());
1266 			}
1267 			rReq.Done ();
1268 			Invalidate( SID_ZOOM_TOOLBOX );
1269 		}
1270 		break;
1271 
1272 		case SID_GLUE_INSERT_POINT:
1273 		case SID_GLUE_PERCENT:
1274 		case SID_GLUE_ESCDIR:
1275 		case SID_GLUE_ESCDIR_LEFT:
1276 		case SID_GLUE_ESCDIR_RIGHT:
1277 		case SID_GLUE_ESCDIR_TOP:
1278 		case SID_GLUE_ESCDIR_BOTTOM:
1279 		case SID_GLUE_HORZALIGN_CENTER:
1280 		case SID_GLUE_HORZALIGN_LEFT:
1281 		case SID_GLUE_HORZALIGN_RIGHT:
1282 		case SID_GLUE_VERTALIGN_CENTER:
1283 		case SID_GLUE_VERTALIGN_TOP:
1284 		case SID_GLUE_VERTALIGN_BOTTOM:
1285 		{
1286 			FunctionReference xFunc( GetCurrentFunction() );
1287 			FuEditGluePoints* pFunc = dynamic_cast< FuEditGluePoints* >( xFunc.get() );
1288 
1289 			if(pFunc)
1290 				pFunc->ReceiveRequest(rReq);
1291 
1292 			rReq.Done();
1293 		}
1294 		break;
1295 
1296 #ifdef DBG_UTIL
1297 		case SID_SHOW_ITEMBROWSER:
1298 		{
1299 			mpDrawView->ShowItemBrowser( !mpDrawView->IsItemBrowserVisible() );
1300 			rReq.Done ();
1301 		}
1302 		break;
1303 #endif
1304 
1305         case SID_AUTOSPELL_CHECK:
1306 		{
1307             sal_Bool bOnlineSpell = !GetDoc()->GetOnlineSpell();
1308             GetDoc()->SetOnlineSpell(bOnlineSpell);
1309 
1310             ::Outliner* pOL = mpDrawView->GetTextEditOutliner();
1311 
1312             if (pOL)
1313             {
1314                 sal_uLong nCntrl = pOL->GetControlWord();
1315 
1316                 if (bOnlineSpell)
1317                     nCntrl |= EE_CNTRL_ONLINESPELLING;
1318                 else
1319                     nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1320 
1321                 pOL->SetControlWord(nCntrl);
1322             }
1323 
1324             GetActiveWindow()->Invalidate();
1325 			rReq.Done ();
1326 		}
1327 		break;
1328 
1329         case SID_CONVERT_TO_1BIT_THRESHOLD:
1330         case SID_CONVERT_TO_1BIT_MATRIX:
1331         case SID_CONVERT_TO_4BIT_GRAYS:
1332         case SID_CONVERT_TO_4BIT_COLORS:
1333         case SID_CONVERT_TO_8BIT_GRAYS:
1334         case SID_CONVERT_TO_8BIT_COLORS:
1335         case SID_CONVERT_TO_24BIT:
1336         {
1337             BmpConversion eBmpConvert = BMP_CONVERSION_NONE;
1338 
1339             switch( nSId )
1340             {
1341                 case SID_CONVERT_TO_1BIT_THRESHOLD:
1342                     eBmpConvert = BMP_CONVERSION_1BIT_THRESHOLD;
1343                     break;
1344 
1345                 case SID_CONVERT_TO_1BIT_MATRIX:
1346                     eBmpConvert = BMP_CONVERSION_1BIT_MATRIX;
1347                     break;
1348 
1349                 case SID_CONVERT_TO_4BIT_GRAYS:
1350                     eBmpConvert = BMP_CONVERSION_4BIT_GREYS;
1351                     break;
1352 
1353                 case SID_CONVERT_TO_4BIT_COLORS:
1354                     eBmpConvert = BMP_CONVERSION_4BIT_COLORS;
1355                     break;
1356 
1357                 case SID_CONVERT_TO_8BIT_GRAYS:
1358                     eBmpConvert = BMP_CONVERSION_8BIT_GREYS;
1359                     break;
1360 
1361                 case SID_CONVERT_TO_8BIT_COLORS:
1362                     eBmpConvert = BMP_CONVERSION_8BIT_COLORS;
1363                     break;
1364 
1365                 case SID_CONVERT_TO_24BIT:
1366                     eBmpConvert = BMP_CONVERSION_24BIT;
1367                     break;
1368             }
1369 
1370             mpDrawView->BegUndo(String(SdResId(STR_UNDO_COLORRESOLUTION)));
1371             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1372 
1373             for (sal_uLong i=0; i<rMarkList.GetMarkCount(); i++)
1374             {
1375                 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1376 
1377                 if (pObj->GetObjInventor() == SdrInventor)
1378                 {
1379                     if (pObj->GetObjIdentifier() == OBJ_GRAF && !((SdrGrafObj*) pObj)->IsLinkedGraphic())
1380                     {
1381                         const Graphic& rGraphic = ((SdrGrafObj*) pObj)->GetGraphic();
1382 
1383                         if( rGraphic.GetType() == GRAPHIC_BITMAP )
1384                         {
1385                             SdrGrafObj*	pNewObj = (SdrGrafObj*) pObj->Clone();
1386 
1387 							if( rGraphic.IsAnimated() )
1388 							{
1389 								Animation aAnim( rGraphic.GetAnimation() );
1390 								aAnim.Convert( eBmpConvert );
1391 	                            pNewObj->SetGraphic( aAnim );
1392 							}
1393 							else
1394 							{
1395 								BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
1396 								aBmpEx.Convert( eBmpConvert );
1397 	                            pNewObj->SetGraphic( aBmpEx );
1398 							}
1399 
1400                             mpDrawView->ReplaceObjectAtView( pObj, *mpDrawView->GetSdrPageView(), pNewObj );
1401                         }
1402                     }
1403                 }
1404             }
1405 
1406             mpDrawView->EndUndo();
1407 			rReq.Done ();
1408 		}
1409 		break;
1410 
1411         case SID_TRANSLITERATE_SENTENCE_CASE:
1412         case SID_TRANSLITERATE_TITLE_CASE:
1413         case SID_TRANSLITERATE_TOGGLE_CASE:
1414 		case SID_TRANSLITERATE_UPPER:
1415 		case SID_TRANSLITERATE_LOWER:
1416 		case SID_TRANSLITERATE_HALFWIDTH:
1417 		case SID_TRANSLITERATE_FULLWIDTH:
1418 		case SID_TRANSLITERATE_HIRAGANA:
1419 		case SID_TRANSLITERATE_KATAGANA:
1420 		{
1421 			OutlinerView* pOLV = GetView()->GetTextEditOutlinerView();
1422 			if( pOLV )
1423 			{
1424 				using namespace ::com::sun::star::i18n;
1425 				sal_Int32 nType = 0;
1426 
1427 				switch( nSId )
1428 				{
1429                     case SID_TRANSLITERATE_SENTENCE_CASE:
1430                         nType = TransliterationModulesExtra::SENTENCE_CASE;
1431                         break;
1432                     case SID_TRANSLITERATE_TITLE_CASE:
1433                         nType = TransliterationModulesExtra::TITLE_CASE;
1434                         break;
1435                     case SID_TRANSLITERATE_TOGGLE_CASE:
1436                         nType = TransliterationModulesExtra::TOGGLE_CASE;
1437                         break;
1438 					case SID_TRANSLITERATE_UPPER:
1439 						nType = TransliterationModules_LOWERCASE_UPPERCASE;
1440 						break;
1441 					case SID_TRANSLITERATE_LOWER:
1442 						nType = TransliterationModules_UPPERCASE_LOWERCASE;
1443 						break;
1444 					case SID_TRANSLITERATE_HALFWIDTH:
1445 						nType = TransliterationModules_FULLWIDTH_HALFWIDTH;
1446 						break;
1447 					case SID_TRANSLITERATE_FULLWIDTH:
1448 						nType = TransliterationModules_HALFWIDTH_FULLWIDTH;
1449 						break;
1450 					case SID_TRANSLITERATE_HIRAGANA:
1451 						nType = TransliterationModules_KATAKANA_HIRAGANA;
1452 						break;
1453 					case SID_TRANSLITERATE_KATAGANA:
1454 						nType = TransliterationModules_HIRAGANA_KATAKANA;
1455 						break;
1456 				}
1457 
1458 				pOLV->TransliterateText( nType );
1459 			}
1460 
1461 			rReq.Done();
1462 		}
1463 		break;
1464 
1465 		// #UndoRedo#
1466 		case SID_UNDO :
1467 		{
1468 			// #96090# moved implementation to BaseClass
1469 			ImpSidUndo(sal_True, rReq);
1470 		}
1471 		break;
1472 		case SID_REDO :
1473 		{
1474 			// #96090# moved implementation to BaseClass
1475 			ImpSidRedo(sal_True, rReq);
1476 		}
1477 		break;
1478 
1479         default:
1480 		break;
1481 	}
1482 }
1483 
1484 /*************************************************************************
1485 |*
1486 |* URL-Feld einfuegen
1487 |*
1488 \************************************************************************/
1489 
1490 void DrawViewShell::InsertURLField(const String& rURL, const String& rText,
1491 									 const String& rTarget, const Point* pPos)
1492 {
1493     OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
1494 
1495     if (pOLV)
1496 	{
1497         ESelection aSel( pOLV->GetSelection() );
1498         SvxFieldItem aURLItem( SvxURLField( rURL, rText, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
1499         pOLV->InsertField( aURLItem );
1500         if ( aSel.nStartPos <= aSel.nEndPos )
1501 		    aSel.nEndPos = aSel.nStartPos + 1;
1502         else
1503             aSel.nStartPos = aSel.nEndPos + 1;
1504         pOLV->SetSelection( aSel );
1505 	}
1506 	else
1507 	{
1508 		Outliner* pOutl = GetDoc()->GetInternalOutliner();
1509 		pOutl->Init( OUTLINERMODE_TEXTOBJECT );
1510 		sal_uInt16 nOutlMode = pOutl->GetMode();
1511 
1512 		SvxURLField aURLField(rURL, rText, SVXURLFORMAT_REPR);
1513 		aURLField.SetTargetFrame(rTarget);
1514         SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
1515 		pOutl->QuickInsertField( aURLItem, ESelection() );
1516 		OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
1517 
1518 		SdrRectObj* pRectObj = new SdrRectObj(OBJ_TEXT);
1519 
1520 		pOutl->UpdateFields();
1521 		pOutl->SetUpdateMode( sal_True );
1522 		Size aSize(pOutl->CalcTextSize());
1523 		pOutl->SetUpdateMode( sal_False );
1524 
1525 		Point aPos;
1526 
1527 		if (pPos)
1528 		{
1529 			aPos = *pPos;
1530 		}
1531 		else
1532 		{
1533 			Rectangle aRect(aPos, GetActiveWindow()->GetOutputSizePixel() );
1534 			aPos = aRect.Center();
1535 			aPos = GetActiveWindow()->PixelToLogic(aPos);
1536 			aPos.X() -= aSize.Width() / 2;
1537 			aPos.Y() -= aSize.Height() / 2;
1538 		}
1539 
1540 		Rectangle aLogicRect(aPos, aSize);
1541 		pRectObj->SetLogicRect(aLogicRect);
1542 		pRectObj->SetOutlinerParaObject( pOutlParaObject );
1543 		mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
1544 		pOutl->Init( nOutlMode );
1545 	}
1546 }
1547 
1548 /*************************************************************************
1549 |*
1550 |* URL-Button einfuegen
1551 |*
1552 \************************************************************************/
1553 
1554 void DrawViewShell::InsertURLButton(const String& rURL, const String& rText,
1555 									  const String& rTarget, const Point* pPos)
1556 {
1557     sal_Bool bNewObj = sal_True;
1558 
1559     const OUString sTargetURL( ::URIHelper::SmartRel2Abs( INetURLObject( GetDocSh()->GetMedium()->GetBaseURL() ), rURL, URIHelper::GetMaybeFileHdl(), true, false,
1560 																INetURLObject::WAS_ENCODED,
1561 																INetURLObject::DECODE_UNAMBIGUOUS ) );
1562     if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
1563     {
1564         SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1565         if( pMarkedObj ) try
1566         {
1567             // change first marked object
1568             if( (FmFormInventor == pMarkedObj->GetObjInventor() && pMarkedObj->GetObjIdentifier() == OBJ_FM_BUTTON) )
1569             {
1570                 bNewObj = sal_False;
1571 
1572 	            SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pMarkedObj );
1573 
1574                 Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), UNO_QUERY_THROW );
1575 			    Reference< beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY_THROW );
1576 
1577                 xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), Any( OUString( rText ) ) );
1578                 xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )), Any( sTargetURL ) );
1579 
1580 			    if( rTarget.Len() )
1581                     xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )), Any( OUString( rTarget ) ) );
1582 
1583                 xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )), Any( form::FormButtonType_URL ) );
1584 			    if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
1585 			    {
1586 				    // #105638# OJ
1587                     xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), Any( sal_True ) );
1588 			    }
1589             }
1590             else
1591             {
1592                 // add url as interaction for first selected shape
1593                 bNewObj = sal_False;
1594 
1595                 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj, true);
1596                 pInfo->meClickAction = presentation::ClickAction_DOCUMENT;
1597                 pInfo->SetBookmark( sTargetURL );
1598             }
1599         }
1600         catch( uno::Exception& )
1601         {
1602         }
1603     }
1604 
1605     if (bNewObj) try
1606     {
1607         SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( SdrObjFactory::MakeNewObject(FmFormInventor, OBJ_FM_BUTTON,
1608                                 mpDrawView->GetSdrPageView()->GetPage(), GetDoc()) );
1609 
1610         Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
1611 		Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
1612 
1613         xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), Any( OUString( rText ) ) );
1614 		xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )), Any( sTargetURL ) );
1615 
1616 		if( rTarget.Len() )
1617 			xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )), Any( OUString( rTarget ) ) );
1618 
1619 		xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )), Any(  form::FormButtonType_URL ) );
1620 		// #105638# OJ
1621 		if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
1622 			xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), Any( sal_True ) );
1623 
1624         Point aPos;
1625 
1626         if (pPos)
1627         {
1628             aPos = *pPos;
1629         }
1630         else
1631         {
1632             aPos = Rectangle(aPos, GetActiveWindow()->GetOutputSizePixel()).Center();
1633             aPos = GetActiveWindow()->PixelToLogic(aPos);
1634         }
1635 
1636         Size aSize(4000, 1000);
1637         aPos.X() -= aSize.Width() / 2;
1638         aPos.Y() -= aSize.Height() / 2;
1639         pUnoCtrl->SetLogicRect(Rectangle(aPos, aSize));
1640 
1641         sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
1642 
1643         OSL_ASSERT (GetViewShell()!=NULL);
1644         SfxInPlaceClient* pIpClient = GetViewShell()->GetIPClient();
1645         if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
1646         {
1647             nOptions |= SDRINSERT_DONTMARK;
1648         }
1649 
1650         mpDrawView->InsertObjectAtView(pUnoCtrl, *mpDrawView->GetSdrPageView(), nOptions);
1651     }
1652     catch( Exception& )
1653     {
1654     }
1655 }
1656 
1657 /*************************************************************************
1658 |*
1659 |*
1660 |*
1661 \************************************************************************/
1662 
1663 void DrawViewShell::ShowUIControls (bool bVisible)
1664 {
1665     ViewShell::ShowUIControls (bVisible);
1666 
1667     //AF: The LayerDialogChildWindow is not used anymore (I hope).
1668     //    GetViewFrame()->SetChildWindow(
1669     //        LayerDialogChildWindow::GetChildWindowId(),
1670     //        IsLayerModeActive() && bVisible);
1671     maTabControl.Show (bVisible);
1672 }
1673 
1674 void DrawViewShell::StopSlideShow (bool /*bCloseFrame*/)
1675 {
1676 	Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
1677     if(xPresentation.is() && xPresentation->isRunning())
1678     {
1679         if( mpDrawView->IsTextEdit() )
1680             mpDrawView->SdrEndTextEdit();
1681 
1682 		xPresentation->end();
1683     }
1684 }
1685 
1686 #ifdef _MSC_VER
1687 #pragma optimize ( "", on )
1688 #endif
1689 
1690 } // end of namespace sd
1691