xref: /aoo41x/main/sd/source/ui/view/drviewse.cxx (revision 69ffbee1)
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 |*
644 |* SfxRequests fuer Support-Funktionen
645 |*
646 \************************************************************************/
647 
648 void DrawViewShell::FuSupport(SfxRequest& rReq)
649 {
650 	if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
651 		GetDocSh()->SetStyleFamily(((SfxUInt16Item&)rReq.GetArgs()->Get( SID_STYLE_FAMILY )).GetValue());
652 
653 	// Waehrend einer Native-Diashow wird nichts ausgefuehrt!
654 	if(SlideShow::IsRunning(GetViewShellBase()) &&
655 		(rReq.GetSlot() != SID_PRESENTATION_END &&
656          rReq.GetSlot() != SID_SIZE_PAGE))
657 		return;
658 
659 	CheckLineTo (rReq);
660 
661 	if( !mpDrawView )
662 		return;
663 
664 	sal_uInt16 nSId = rReq.GetSlot();
665 
666 	// Slot wird evtl. gemapped (ToolboxImages/-Slots)
667 	MapSlot( nSId );
668 
669 	switch ( nSId )
670 	{
671 		case SID_CLEAR_UNDO_STACK:
672 		{
673 			GetDocSh()->ClearUndoBuffer();
674             rReq.Ignore ();
675 		}
676 		break;
677 
678         // Slots der ToolboxController gemapped ausfuehren
679         case SID_OBJECT_CHOOSE_MODE:
680         case SID_POSITION:
681         case SID_OBJECT_ALIGN:
682         case SID_ZOOM_TOOLBOX:
683         case SID_DRAWTBX_TEXT:
684         case SID_DRAWTBX_RECTANGLES:
685         case SID_DRAWTBX_ELLIPSES:
686         case SID_DRAWTBX_LINES:
687         case SID_DRAWTBX_ARROWS:
688         case SID_DRAWTBX_3D_OBJECTS:
689         case SID_DRAWTBX_CONNECTORS:
690         case SID_DRAWTBX_INSERT:
691         {
692             sal_uInt16 nMappedSlot = GetMappedSlot( nSId );
693             if( nMappedSlot > 0 )
694             {
695                 SfxRequest aReq( nMappedSlot, 0, GetDoc()->GetItemPool() );
696                 ExecuteSlot( aReq );
697             }
698         }
699         break;
700 
701 		case SID_PRESENTATION:
702 		case SID_REHEARSE_TIMINGS:
703 		{
704 			Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
705 			if( xPresentation.is() )
706 			{
707 				if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) )
708 					xPresentation->start();
709 				else
710 					xPresentation->rehearseTimings();
711 			}
712 			rReq.Ignore ();
713         }
714 		break;
715 
716 		case SID_PRESENTATION_END:
717 		{
718             StopSlideShow(true);
719 
720             rReq.Ignore ();
721 		}
722 		break;
723 
724 		case SID_BEZIER_EDIT:
725 		{
726             mpDrawView->SetFrameDragSingles(!mpDrawView->IsFrameDragSingles());
727 
728             /******************************************************************
729             * ObjectBar einschalten
730             ******************************************************************/
731             if( dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) || dynamic_cast< FuConstructBezierPolygon* >( GetCurrentFunction().get() ) )
732             {
733                 // Tell the tool bar manager about the context change.
734 				GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
735             }
736 
737             Invalidate(SID_BEZIER_EDIT);
738             rReq.Ignore();
739         }
740         break;
741 
742 		case SID_OBJECT_CLOSE:
743 		{
744 			const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
745 			if ( rMarkList.GetMark(0) && !mpDrawView->IsAction() )
746 			{
747 				SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
748 				const bool bUndo = mpDrawView->IsUndoEnabled();
749 				if( bUndo )
750 					mpDrawView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
751 
752 				mpDrawView->UnmarkAllPoints();
753 
754 				if( bUndo )
755 					mpDrawView->AddUndo(new SdrUndoGeoObj(*pPathObj));
756 
757 				pPathObj->ToggleClosed();
758 
759 				if( bUndo )
760 					mpDrawView->EndUndo();
761 			}
762 			rReq.Done();
763 		}
764 		break;
765 
766 		case SID_CUT:
767 		{
768 			if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
769 			{
770                 ::sd::Window* pWindow = GetActiveWindow();
771                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
772 			}
773 			else
774 			{
775 				if(HasCurrentFunction())
776 				{
777 					GetCurrentFunction()->DoCut();
778 				}
779 				else if(mpDrawView)
780 				{
781 					mpDrawView->DoCut();
782 				}
783 			}
784 			rReq.Ignore ();
785 		}
786 		break;
787 
788 		case SID_COPY:
789 		{
790 			if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
791 			{
792                 ::sd::Window* pWindow = GetActiveWindow();
793                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
794 			}
795 			else
796 			{
797 				if(HasCurrentFunction())
798 				{
799 					GetCurrentFunction()->DoCopy();
800 				}
801 				else if( mpDrawView )
802 				{
803 					mpDrawView->DoCopy();
804 				}
805 			}
806 			rReq.Ignore ();
807 		}
808 		break;
809 
810 		case SID_PASTE:
811 		{
812 			WaitObject aWait( (Window*)GetActiveWindow() );
813 
814 			if(HasCurrentFunction())
815 			{
816 				GetCurrentFunction()->DoPaste();
817 			}
818 			else if(mpDrawView)
819 			{
820 				mpDrawView->DoPaste();
821 			}
822 
823 			rReq.Ignore ();
824 		}
825 		break;
826 
827         case SID_CLIPBOARD_FORMAT_ITEMS:
828         {
829 			WaitObject              aWait( (Window*)GetActiveWindow() );
830 	        TransferableDataHelper  aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
831             const SfxItemSet*       pReqArgs = rReq.GetArgs();
832             sal_uInt32                  nFormat = 0;
833 
834             if( pReqArgs )
835             {
836                 SFX_REQUEST_ARG( rReq, pIsActive, SfxUInt32Item, SID_CLIPBOARD_FORMAT_ITEMS, sal_False );
837                 nFormat = pIsActive->GetValue();
838             }
839 
840 
841 	        if( nFormat && aDataHelper.GetTransferable().is() )
842 	        {
843 		        sal_Int8 nAction = DND_ACTION_COPY;
844 
845                 if( !mpDrawView->InsertData( aDataHelper,
846 						                  GetActiveWindow()->PixelToLogic( Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
847 						                  nAction, sal_False, nFormat ) )
848                 {
849 			        INetBookmark    aINetBookmark( aEmptyStr, aEmptyStr );
850 
851 			        if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
852 				          aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
853 				        ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
854 				          aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
855 				        ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
856 				          aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
857 			        {
858 				        InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
859 			        }
860                 }
861 	        }
862         }
863         break;
864 
865 		case SID_DELETE:
866 		{
867 			if ( mpDrawView->IsTextEdit() )
868 			{
869 				OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
870 
871 				if (pOLV)
872 				{
873 					KeyCode aKCode(KEY_DELETE);
874 					KeyEvent aKEvt( 0, aKCode);
875 					pOLV->PostKeyEvent(aKEvt);
876 				}
877 			}
878 			else if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
879 			{
880                 ::sd::Window* pWindow = GetActiveWindow();
881                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
882 			}
883 			else
884 			{
885 				KeyCode aKCode(KEY_DELETE);
886 				KeyEvent aKEvt( 0, aKCode);
887 
888 				bool bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
889 
890 				if( !bConsumed && HasCurrentFunction() )
891 					bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
892 
893 				if( !bConsumed && mpDrawView )
894 					mpDrawView->DeleteMarked();
895 			}
896 			rReq.Ignore ();
897 		}
898 		break;
899 
900         case SID_NOTESMODE:
901 		case SID_HANDOUTMODE:
902 			// AutoLayouts have to be ready.
903 			GetDoc()->StopWorkStartupDelay();
904             // Fall through to following case statements.
905 
906         case SID_DRAWINGMODE:
907 		case SID_DIAMODE:
908         case SID_OUTLINEMODE:
909             // Let the sub-shell manager handle the slot handling.
910             framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
911                 nSId,
912                 rReq);
913 			rReq.Ignore ();
914             break;
915 
916         case SID_MASTERPAGE:          // BASIC
917         case SID_SLIDE_MASTERPAGE:    // BASIC
918         case SID_TITLE_MASTERPAGE:    // BASIC
919         case SID_NOTES_MASTERPAGE:    // BASIC
920         case SID_HANDOUT_MASTERPAGE:  // BASIC
921 		{
922 			// AutoLayouts muessen fertig sein
923 			GetDoc()->StopWorkStartupDelay();
924 
925 			const SfxItemSet* pReqArgs = rReq.GetArgs();
926 
927 			if ( pReqArgs )
928 			{
929 				SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, SID_MASTERPAGE, sal_False);
930 				mbIsLayerModeActive = pIsActive->GetValue ();
931 			}
932 
933             Broadcast (
934                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
935 
936             if (nSId == SID_MASTERPAGE                                       ||
937                 (nSId == SID_SLIDE_MASTERPAGE   && mePageKind == PK_STANDARD) ||
938                 (nSId == SID_TITLE_MASTERPAGE   && mePageKind == PK_STANDARD) ||
939                 (nSId == SID_NOTES_MASTERPAGE   && mePageKind == PK_NOTES)    ||
940                 (nSId == SID_HANDOUT_MASTERPAGE && mePageKind == PK_HANDOUT))
941             {
942                 if (nSId == SID_TITLE_MASTERPAGE ||
943 					nSId == SID_SLIDE_MASTERPAGE)
944                 {
945                     // Gibt es eine Seite mit dem AutoLayout "Titel"?
946                     sal_Bool bFound = sal_False;
947                     sal_uInt16 i = 0;
948                     sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
949 
950                     while (i < nCount && !bFound)
951                     {
952                         SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
953 
954                         if (nSId == SID_TITLE_MASTERPAGE && pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
955                         {
956                             bFound = sal_True;
957                             SwitchPage((pPage->GetPageNum() - 1) / 2);
958                         }
959                         else if (nSId == SID_SLIDE_MASTERPAGE && pPage->GetAutoLayout() != AUTOLAYOUT_TITLE)
960                         {
961                             bFound = sal_True;
962                             SwitchPage((pPage->GetPageNum() - 1) / 2);
963                         }
964 
965                         i++;
966                     }
967                 }
968 
969                 // Default-Layer der MasterPage einschalten
970                 mpDrawView->SetActiveLayer( String( SdResId(STR_LAYER_BCKGRNDOBJ) ) );
971 
972                 ChangeEditMode(EM_MASTERPAGE, mbIsLayerModeActive);
973 
974                 if(HasCurrentFunction(SID_BEZIER_EDIT))
975 					GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
976             }
977             else
978             {
979                 // Switch to requested ViewShell.
980                 ::OUString sRequestedView;
981                 PageKind ePageKind;
982                 switch (nSId)
983                 {
984                     case SID_SLIDE_MASTERPAGE:
985                     case SID_TITLE_MASTERPAGE:
986                     default:
987                         sRequestedView = framework::FrameworkHelper::msImpressViewURL;
988                         ePageKind = PK_STANDARD;
989                         break;
990 
991                     case SID_NOTES_MASTERPAGE:
992                         sRequestedView = framework::FrameworkHelper::msNotesViewURL;
993                         ePageKind = PK_NOTES;
994                         break;
995 
996                     case SID_HANDOUT_MASTERPAGE:
997                         sRequestedView = framework::FrameworkHelper::msHandoutViewURL;
998                         ePageKind = PK_HANDOUT;
999                         break;
1000                 }
1001 
1002                 mpFrameView->SetViewShEditMode(EM_MASTERPAGE, ePageKind);
1003                 mpFrameView->SetLayerMode(mbIsLayerModeActive);
1004                 framework::FrameworkHelper::Instance(GetViewShellBase())->RequestView(
1005                     sRequestedView,
1006                     framework::FrameworkHelper::msCenterPaneURL);
1007             }
1008             Broadcast (
1009                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
1010 
1011 			InvalidateWindows();
1012 			Invalidate();
1013 
1014 			rReq.Done();
1015 		}
1016 		break;
1017 
1018 
1019         case SID_CLOSE_MASTER_VIEW:
1020         {
1021             Broadcast (
1022                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
1023 
1024             // Switch page back to the first one.  Not doing so leads to a
1025             // crash.  This seems to be some bug in the edit mode switching
1026             // and page switching methods.
1027 			SwitchPage (0);
1028             ChangeEditMode(EM_PAGE, IsLayerModeActive());
1029             Broadcast (
1030                 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
1031 
1032             if(HasCurrentFunction(SID_BEZIER_EDIT))
1033             {
1034                 GetViewFrame()->GetDispatcher()->Execute(
1035                     SID_OBJECT_SELECT,
1036                     SFX_CALLMODE_ASYNCHRON);
1037             }
1038 
1039 
1040 			rReq.Done();
1041         }
1042         break;
1043 
1044 
1045 		case SID_RULER:
1046         {
1047 			const SfxItemSet* pReqArgs = rReq.GetArgs();
1048 
1049 			// #97516# Remember old ruler state
1050 			sal_Bool bOldHasRuler(HasRuler());
1051 
1052 			if ( pReqArgs )
1053 			{
1054 				SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, SID_RULER, sal_False);
1055 				SetRuler (pIsActive->GetValue ());
1056 			}
1057 			else SetRuler (!HasRuler());
1058 
1059 			// #97516# Did ruler state change? Tell that to SdOptions, too.
1060 			sal_Bool bHasRuler(HasRuler());
1061 
1062 			if(bOldHasRuler != bHasRuler)
1063 			{
1064 				SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
1065 
1066 				if(pOptions && pOptions->IsRulerVisible() != bHasRuler)
1067 				{
1068 					pOptions->SetRulerVisible(bHasRuler);
1069 				}
1070 			}
1071 
1072             Invalidate (SID_RULER);
1073             Resize();
1074             rReq.Done ();
1075         }
1076         break;
1077 
1078 		case SID_SIZE_PAGE:
1079 		case SID_SIZE_PAGE_WIDTH:  // BASIC
1080 		{
1081 			mbZoomOnPage = ( rReq.GetSlot() == SID_SIZE_PAGE );
1082 
1083 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1084 
1085 			if ( pPageView )
1086 			{
1087 				Point aPagePos(0, 0); // = pPageView->GetOffset();
1088 				Size aPageSize = pPageView->GetPage()->GetSize();
1089 
1090 				aPagePos.X() += aPageSize.Width()  / 2;
1091                 aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
1092 
1093                 if( rReq.GetSlot() == SID_SIZE_PAGE )
1094 				{
1095 					aPagePos.Y() += aPageSize.Height() / 2;
1096                     aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
1097 					aPagePos.Y() -= aPageSize.Height() / 2;
1098 				}
1099 				else
1100 				{
1101 					Point aPt = GetActiveWindow()->PixelToLogic( Point( 0, GetActiveWindow()->GetSizePixel().Height() / 2 ) );
1102 					aPagePos.Y() += aPt.Y();
1103 					aPageSize.Height() = 2;
1104 				}
1105 
1106 				aPagePos.X() -= aPageSize.Width()  / 2;
1107 
1108 				SetZoomRect( Rectangle( aPagePos, aPageSize ) );
1109 
1110 				Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1111 											  GetActiveWindow()->GetOutputSizePixel()) );
1112 				mpZoomList->InsertZoomRect(aVisAreaWin);
1113 			}
1114 			Invalidate( SID_ZOOM_IN );
1115 			Invalidate( SID_ZOOM_OUT );
1116 			Invalidate( SID_ZOOM_PANNING );
1117 			Invalidate( SID_ZOOM_TOOLBOX );
1118 			rReq.Done ();
1119 		}
1120 		break;
1121 
1122 		case SID_SIZE_REAL:  // BASIC
1123 		{
1124 			mbZoomOnPage = sal_False;
1125 			SetZoom( 100 );
1126 			Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1127 											  GetActiveWindow()->GetOutputSizePixel()) );
1128 			mpZoomList->InsertZoomRect(aVisAreaWin);
1129 			Invalidate( SID_ZOOM_IN );
1130 			Invalidate( SID_ZOOM_OUT );
1131 			Invalidate( SID_ZOOM_PANNING );
1132 			Invalidate( SID_ZOOM_TOOLBOX );
1133 			rReq.Done ();
1134 		}
1135 		break;
1136 
1137 		case SID_ZOOM_IN:  // BASIC
1138 		{
1139 			mbZoomOnPage = sal_False;
1140 			SetZoom( Max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
1141 			Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1142 											  GetActiveWindow()->GetOutputSizePixel()) );
1143 			mpZoomList->InsertZoomRect(aVisAreaWin);
1144 			Invalidate( SID_ZOOM_IN );
1145 			Invalidate( SID_ZOOM_OUT );
1146 			Invalidate( SID_ZOOM_PANNING );
1147 			Invalidate( SID_ZOOM_TOOLBOX );
1148 			rReq.Done ();
1149 		}
1150 		break;
1151 
1152 		case SID_SIZE_VISAREA:
1153 		{
1154 			Rectangle aVisArea = mpFrameView->GetVisArea();
1155 			Size aVisAreaSize = aVisArea.GetSize();
1156 
1157 			if (aVisAreaSize.Height()!=0 && aVisAreaSize.Width()!=0)
1158 			{
1159 				mbZoomOnPage = sal_False;
1160 				SetZoomRect(aVisArea);
1161 				Invalidate( SID_ZOOM_IN );
1162 				Invalidate( SID_ZOOM_OUT );
1163 				Invalidate( SID_ZOOM_PANNING );
1164 				Invalidate( SID_ZOOM_TOOLBOX );
1165 			}
1166 			rReq.Done ();
1167 		}
1168 		break;
1169 
1170 		// Namensverwirrung: SID_SIZE_OPTIMAL -> Zoom auf selektierte Objekte
1171 		// --> Wird als Objektzoom im Programm angeboten
1172 		case SID_SIZE_OPTIMAL:	// BASIC
1173 		{
1174 			mbZoomOnPage = sal_False;
1175 			if ( mpDrawView->AreObjectsMarked() )
1176 			{
1177                 maMarkRect = mpDrawView->GetAllMarkedRect();
1178                 long nW = (long) (maMarkRect.GetWidth()  * 1.03);
1179                 long nH = (long) (maMarkRect.GetHeight() * 1.03);
1180 				Point aPos = maMarkRect.Center();
1181 				aPos.X() -= nW / 2;
1182 				aPos.Y() -= nH / 2;
1183 				if ( nW && nH )
1184 				{
1185 					SetZoomRect(Rectangle(aPos, Size(nW, nH)));
1186 
1187 					Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1188 											  GetActiveWindow()->GetOutputSizePixel()) );
1189 					mpZoomList->InsertZoomRect(aVisAreaWin);
1190 				}
1191 			}
1192 			Invalidate( SID_ZOOM_IN );
1193 			Invalidate( SID_ZOOM_OUT );
1194 			Invalidate( SID_ZOOM_PANNING );
1195 			Invalidate( SID_ZOOM_TOOLBOX );
1196 			rReq.Done ();
1197 		}
1198 		break;
1199 
1200 		// Namensverwirrung: SID_SIZE_ALL -> Zoom auf alle Objekte
1201 		// --> Wird als Optimal im Programm angeboten
1202 		case SID_SIZE_ALL:	// BASIC
1203 		{
1204 			mbZoomOnPage = sal_False;
1205 			SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1206 
1207 			if( pPageView )
1208 			{
1209 				Rectangle aBoundRect( pPageView->GetObjList()->GetAllObjBoundRect() );
1210 
1211                 long nW = (long) (aBoundRect.GetWidth() * 1.03);
1212                 long nH = (long) (aBoundRect.GetHeight() * 1.03);
1213 				Point aPos = aBoundRect.Center();
1214 				aPos.X() -= nW / 2;
1215 				aPos.Y() -= nH / 2;
1216 				if ( nW && nH )
1217 				{
1218 					SetZoomRect( Rectangle( aPos, Size( nW, nH ) ) );
1219 
1220 					Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
1221 											  GetActiveWindow()->GetOutputSizePixel()) );
1222 					mpZoomList->InsertZoomRect(aVisAreaWin);
1223 				}
1224 
1225 				Invalidate( SID_ZOOM_IN );
1226 				Invalidate( SID_ZOOM_OUT );
1227 				Invalidate( SID_ZOOM_PANNING );
1228 				Invalidate( SID_ZOOM_TOOLBOX );
1229 			}
1230 			rReq.Done ();
1231 		}
1232 		break;
1233 
1234 		case SID_ZOOM_PREV:
1235 		{
1236 			if (mpDrawView->IsTextEdit())
1237 			{
1238 				mpDrawView->SdrEndTextEdit();
1239 			}
1240 
1241 			if (mpZoomList->IsPreviousPossible())
1242 			{
1243 				// Vorheriges ZoomRect einstellen
1244 				SetZoomRect(mpZoomList->GetPreviousZoomRect());
1245 			}
1246 			rReq.Done ();
1247 			Invalidate( SID_ZOOM_TOOLBOX );
1248 		}
1249 		break;
1250 
1251 		case SID_ZOOM_NEXT:
1252 		{
1253 			if (mpDrawView->IsTextEdit())
1254 			{
1255 				mpDrawView->SdrEndTextEdit();
1256 			}
1257 
1258 			if (mpZoomList->IsNextPossible())
1259 			{
1260 				// Naechstes ZoomRect einstellen
1261 				SetZoomRect(mpZoomList->GetNextZoomRect());
1262 			}
1263 			rReq.Done ();
1264 			Invalidate( SID_ZOOM_TOOLBOX );
1265 		}
1266 		break;
1267 
1268 		case SID_GLUE_INSERT_POINT:
1269 		case SID_GLUE_PERCENT:
1270 		case SID_GLUE_ESCDIR:
1271 		case SID_GLUE_ESCDIR_LEFT:
1272 		case SID_GLUE_ESCDIR_RIGHT:
1273 		case SID_GLUE_ESCDIR_TOP:
1274 		case SID_GLUE_ESCDIR_BOTTOM:
1275 		case SID_GLUE_HORZALIGN_CENTER:
1276 		case SID_GLUE_HORZALIGN_LEFT:
1277 		case SID_GLUE_HORZALIGN_RIGHT:
1278 		case SID_GLUE_VERTALIGN_CENTER:
1279 		case SID_GLUE_VERTALIGN_TOP:
1280 		case SID_GLUE_VERTALIGN_BOTTOM:
1281 		{
1282 			FunctionReference xFunc( GetCurrentFunction() );
1283 			FuEditGluePoints* pFunc = dynamic_cast< FuEditGluePoints* >( xFunc.get() );
1284 
1285 			if(pFunc)
1286 				pFunc->ReceiveRequest(rReq);
1287 
1288 			rReq.Done();
1289 		}
1290 		break;
1291 
1292 #ifdef DBG_UTIL
1293 		case SID_SHOW_ITEMBROWSER:
1294 		{
1295 			mpDrawView->ShowItemBrowser( !mpDrawView->IsItemBrowserVisible() );
1296 			rReq.Done ();
1297 		}
1298 		break;
1299 #endif
1300 
1301         case SID_AUTOSPELL_CHECK:
1302 		{
1303             sal_Bool bOnlineSpell = !GetDoc()->GetOnlineSpell();
1304             GetDoc()->SetOnlineSpell(bOnlineSpell);
1305 
1306             ::Outliner* pOL = mpDrawView->GetTextEditOutliner();
1307 
1308             if (pOL)
1309             {
1310                 sal_uLong nCntrl = pOL->GetControlWord();
1311 
1312                 if (bOnlineSpell)
1313                     nCntrl |= EE_CNTRL_ONLINESPELLING;
1314                 else
1315                     nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1316 
1317                 pOL->SetControlWord(nCntrl);
1318             }
1319 
1320             GetActiveWindow()->Invalidate();
1321 			rReq.Done ();
1322 		}
1323 		break;
1324 
1325         case SID_CONVERT_TO_1BIT_THRESHOLD:
1326         case SID_CONVERT_TO_1BIT_MATRIX:
1327         case SID_CONVERT_TO_4BIT_GRAYS:
1328         case SID_CONVERT_TO_4BIT_COLORS:
1329         case SID_CONVERT_TO_8BIT_GRAYS:
1330         case SID_CONVERT_TO_8BIT_COLORS:
1331         case SID_CONVERT_TO_24BIT:
1332         {
1333             BmpConversion eBmpConvert = BMP_CONVERSION_NONE;
1334 
1335             switch( nSId )
1336             {
1337                 case SID_CONVERT_TO_1BIT_THRESHOLD:
1338                     eBmpConvert = BMP_CONVERSION_1BIT_THRESHOLD;
1339                     break;
1340 
1341                 case SID_CONVERT_TO_1BIT_MATRIX:
1342                     eBmpConvert = BMP_CONVERSION_1BIT_MATRIX;
1343                     break;
1344 
1345                 case SID_CONVERT_TO_4BIT_GRAYS:
1346                     eBmpConvert = BMP_CONVERSION_4BIT_GREYS;
1347                     break;
1348 
1349                 case SID_CONVERT_TO_4BIT_COLORS:
1350                     eBmpConvert = BMP_CONVERSION_4BIT_COLORS;
1351                     break;
1352 
1353                 case SID_CONVERT_TO_8BIT_GRAYS:
1354                     eBmpConvert = BMP_CONVERSION_8BIT_GREYS;
1355                     break;
1356 
1357                 case SID_CONVERT_TO_8BIT_COLORS:
1358                     eBmpConvert = BMP_CONVERSION_8BIT_COLORS;
1359                     break;
1360 
1361                 case SID_CONVERT_TO_24BIT:
1362                     eBmpConvert = BMP_CONVERSION_24BIT;
1363                     break;
1364             }
1365 
1366             mpDrawView->BegUndo(String(SdResId(STR_UNDO_COLORRESOLUTION)));
1367             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1368 
1369             for (sal_uLong i=0; i<rMarkList.GetMarkCount(); i++)
1370             {
1371                 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1372 
1373                 if (pObj->GetObjInventor() == SdrInventor)
1374                 {
1375                     if (pObj->GetObjIdentifier() == OBJ_GRAF && !((SdrGrafObj*) pObj)->IsLinkedGraphic())
1376                     {
1377                         const Graphic& rGraphic = ((SdrGrafObj*) pObj)->GetGraphic();
1378 
1379                         if( rGraphic.GetType() == GRAPHIC_BITMAP )
1380                         {
1381                             SdrGrafObj*	pNewObj = (SdrGrafObj*) pObj->Clone();
1382 
1383 							if( rGraphic.IsAnimated() )
1384 							{
1385 								Animation aAnim( rGraphic.GetAnimation() );
1386 								aAnim.Convert( eBmpConvert );
1387 	                            pNewObj->SetGraphic( aAnim );
1388 							}
1389 							else
1390 							{
1391 								BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
1392 								aBmpEx.Convert( eBmpConvert );
1393 	                            pNewObj->SetGraphic( aBmpEx );
1394 							}
1395 
1396                             mpDrawView->ReplaceObjectAtView( pObj, *mpDrawView->GetSdrPageView(), pNewObj );
1397                         }
1398                     }
1399                 }
1400             }
1401 
1402             mpDrawView->EndUndo();
1403 			rReq.Done ();
1404 		}
1405 		break;
1406 
1407         case SID_TRANSLITERATE_SENTENCE_CASE:
1408         case SID_TRANSLITERATE_TITLE_CASE:
1409         case SID_TRANSLITERATE_TOGGLE_CASE:
1410 		case SID_TRANSLITERATE_UPPER:
1411 		case SID_TRANSLITERATE_LOWER:
1412 		case SID_TRANSLITERATE_HALFWIDTH:
1413 		case SID_TRANSLITERATE_FULLWIDTH:
1414 		case SID_TRANSLITERATE_HIRAGANA:
1415 		case SID_TRANSLITERATE_KATAGANA:
1416 		{
1417 			OutlinerView* pOLV = GetView()->GetTextEditOutlinerView();
1418 			if( pOLV )
1419 			{
1420 				using namespace ::com::sun::star::i18n;
1421 				sal_Int32 nType = 0;
1422 
1423 				switch( nSId )
1424 				{
1425                     case SID_TRANSLITERATE_SENTENCE_CASE:
1426                         nType = TransliterationModulesExtra::SENTENCE_CASE;
1427                         break;
1428                     case SID_TRANSLITERATE_TITLE_CASE:
1429                         nType = TransliterationModulesExtra::TITLE_CASE;
1430                         break;
1431                     case SID_TRANSLITERATE_TOGGLE_CASE:
1432                         nType = TransliterationModulesExtra::TOGGLE_CASE;
1433                         break;
1434 					case SID_TRANSLITERATE_UPPER:
1435 						nType = TransliterationModules_LOWERCASE_UPPERCASE;
1436 						break;
1437 					case SID_TRANSLITERATE_LOWER:
1438 						nType = TransliterationModules_UPPERCASE_LOWERCASE;
1439 						break;
1440 					case SID_TRANSLITERATE_HALFWIDTH:
1441 						nType = TransliterationModules_FULLWIDTH_HALFWIDTH;
1442 						break;
1443 					case SID_TRANSLITERATE_FULLWIDTH:
1444 						nType = TransliterationModules_HALFWIDTH_FULLWIDTH;
1445 						break;
1446 					case SID_TRANSLITERATE_HIRAGANA:
1447 						nType = TransliterationModules_KATAKANA_HIRAGANA;
1448 						break;
1449 					case SID_TRANSLITERATE_KATAGANA:
1450 						nType = TransliterationModules_HIRAGANA_KATAKANA;
1451 						break;
1452 				}
1453 
1454 				pOLV->TransliterateText( nType );
1455 			}
1456 
1457 			rReq.Done();
1458 		}
1459 		break;
1460 
1461 		// #UndoRedo#
1462 		case SID_UNDO :
1463 		{
1464 			// #96090# moved implementation to BaseClass
1465 			ImpSidUndo(sal_True, rReq);
1466 		}
1467 		break;
1468 		case SID_REDO :
1469 		{
1470 			// #96090# moved implementation to BaseClass
1471 			ImpSidRedo(sal_True, rReq);
1472 		}
1473 		break;
1474 
1475         default:
1476 		break;
1477 	}
1478 }
1479 
1480 /*************************************************************************
1481 |*
1482 |* URL-Feld einfuegen
1483 |*
1484 \************************************************************************/
1485 
1486 void DrawViewShell::InsertURLField(const String& rURL, const String& rText,
1487 									 const String& rTarget, const Point* pPos)
1488 {
1489     OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
1490 
1491     if (pOLV)
1492 	{
1493         ESelection aSel( pOLV->GetSelection() );
1494         SvxFieldItem aURLItem( SvxURLField( rURL, rText, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
1495         pOLV->InsertField( aURLItem );
1496         if ( aSel.nStartPos <= aSel.nEndPos )
1497 		    aSel.nEndPos = aSel.nStartPos + 1;
1498         else
1499             aSel.nStartPos = aSel.nEndPos + 1;
1500         pOLV->SetSelection( aSel );
1501 	}
1502 	else
1503 	{
1504 		Outliner* pOutl = GetDoc()->GetInternalOutliner();
1505 		pOutl->Init( OUTLINERMODE_TEXTOBJECT );
1506 		sal_uInt16 nOutlMode = pOutl->GetMode();
1507 
1508 		SvxURLField aURLField(rURL, rText, SVXURLFORMAT_REPR);
1509 		aURLField.SetTargetFrame(rTarget);
1510         SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
1511 		pOutl->QuickInsertField( aURLItem, ESelection() );
1512 		OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
1513 
1514 		SdrRectObj* pRectObj = new SdrRectObj(OBJ_TEXT);
1515 
1516 		pOutl->UpdateFields();
1517 		pOutl->SetUpdateMode( sal_True );
1518 		Size aSize(pOutl->CalcTextSize());
1519 		pOutl->SetUpdateMode( sal_False );
1520 
1521 		Point aPos;
1522 
1523 		if (pPos)
1524 		{
1525 			aPos = *pPos;
1526 		}
1527 		else
1528 		{
1529 			Rectangle aRect(aPos, GetActiveWindow()->GetOutputSizePixel() );
1530 			aPos = aRect.Center();
1531 			aPos = GetActiveWindow()->PixelToLogic(aPos);
1532 			aPos.X() -= aSize.Width() / 2;
1533 			aPos.Y() -= aSize.Height() / 2;
1534 		}
1535 
1536 		Rectangle aLogicRect(aPos, aSize);
1537 		pRectObj->SetLogicRect(aLogicRect);
1538 		pRectObj->SetOutlinerParaObject( pOutlParaObject );
1539 		mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
1540 		pOutl->Init( nOutlMode );
1541 	}
1542 }
1543 
1544 /*************************************************************************
1545 |*
1546 |* URL-Button einfuegen
1547 |*
1548 \************************************************************************/
1549 
1550 void DrawViewShell::InsertURLButton(const String& rURL, const String& rText,
1551 									  const String& rTarget, const Point* pPos)
1552 {
1553     sal_Bool bNewObj = sal_True;
1554 
1555     const OUString sTargetURL( ::URIHelper::SmartRel2Abs( INetURLObject( GetDocSh()->GetMedium()->GetBaseURL() ), rURL, URIHelper::GetMaybeFileHdl(), true, false,
1556 																INetURLObject::WAS_ENCODED,
1557 																INetURLObject::DECODE_UNAMBIGUOUS ) );
1558     if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
1559     {
1560         SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1561         if( pMarkedObj ) try
1562         {
1563             // change first marked object
1564             if( (FmFormInventor == pMarkedObj->GetObjInventor() && pMarkedObj->GetObjIdentifier() == OBJ_FM_BUTTON) )
1565             {
1566                 bNewObj = sal_False;
1567 
1568 	            SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pMarkedObj );
1569 
1570                 Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), UNO_QUERY_THROW );
1571 			    Reference< beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY_THROW );
1572 
1573                 xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), Any( OUString( rText ) ) );
1574                 xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )), Any( sTargetURL ) );
1575 
1576 			    if( rTarget.Len() )
1577                     xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )), Any( OUString( rTarget ) ) );
1578 
1579                 xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )), Any( form::FormButtonType_URL ) );
1580 			    if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
1581 			    {
1582 				    // #105638# OJ
1583                     xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), Any( sal_True ) );
1584 			    }
1585             }
1586             else
1587             {
1588                 // add url as interaction for first selected shape
1589                 bNewObj = sal_False;
1590 
1591                 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj, true);
1592                 pInfo->meClickAction = presentation::ClickAction_DOCUMENT;
1593                 pInfo->SetBookmark( sTargetURL );
1594             }
1595         }
1596         catch( uno::Exception& )
1597         {
1598         }
1599     }
1600 
1601     if (bNewObj) try
1602     {
1603         SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( SdrObjFactory::MakeNewObject(FmFormInventor, OBJ_FM_BUTTON,
1604                                 mpDrawView->GetSdrPageView()->GetPage(), GetDoc()) );
1605 
1606         Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
1607 		Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
1608 
1609         xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), Any( OUString( rText ) ) );
1610 		xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )), Any( sTargetURL ) );
1611 
1612 		if( rTarget.Len() )
1613 			xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )), Any( OUString( rTarget ) ) );
1614 
1615 		xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )), Any(  form::FormButtonType_URL ) );
1616 		// #105638# OJ
1617 		if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
1618 			xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), Any( sal_True ) );
1619 
1620         Point aPos;
1621 
1622         if (pPos)
1623         {
1624             aPos = *pPos;
1625         }
1626         else
1627         {
1628             aPos = Rectangle(aPos, GetActiveWindow()->GetOutputSizePixel()).Center();
1629             aPos = GetActiveWindow()->PixelToLogic(aPos);
1630         }
1631 
1632         Size aSize(4000, 1000);
1633         aPos.X() -= aSize.Width() / 2;
1634         aPos.Y() -= aSize.Height() / 2;
1635         pUnoCtrl->SetLogicRect(Rectangle(aPos, aSize));
1636 
1637         sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
1638 
1639         OSL_ASSERT (GetViewShell()!=NULL);
1640         SfxInPlaceClient* pIpClient = GetViewShell()->GetIPClient();
1641         if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
1642         {
1643             nOptions |= SDRINSERT_DONTMARK;
1644         }
1645 
1646         mpDrawView->InsertObjectAtView(pUnoCtrl, *mpDrawView->GetSdrPageView(), nOptions);
1647     }
1648     catch( Exception& )
1649     {
1650     }
1651 }
1652 
1653 /*************************************************************************
1654 |*
1655 |*
1656 |*
1657 \************************************************************************/
1658 
1659 void DrawViewShell::ShowUIControls (bool bVisible)
1660 {
1661     ViewShell::ShowUIControls (bVisible);
1662 
1663     //AF: The LayerDialogChildWindow is not used anymore (I hope).
1664     //    GetViewFrame()->SetChildWindow(
1665     //        LayerDialogChildWindow::GetChildWindowId(),
1666     //        IsLayerModeActive() && bVisible);
1667     maTabControl.Show (bVisible);
1668 }
1669 
1670 void DrawViewShell::StopSlideShow (bool /*bCloseFrame*/)
1671 {
1672 	Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
1673     if(xPresentation.is() && xPresentation->isRunning())
1674     {
1675         if( mpDrawView->IsTextEdit() )
1676             mpDrawView->SdrEndTextEdit();
1677 
1678 		xPresentation->end();
1679     }
1680 }
1681 
1682 #ifdef _MSC_VER
1683 #pragma optimize ( "", on )
1684 #endif
1685 
1686 } // end of namespace sd
1687