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