1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #include "DrawViewShell.hxx"
28 #include "ViewShellImplementation.hxx"
29 #include <vcl/waitobj.hxx>
30 #include <svx/svdograf.hxx>
31 #ifndef _SVXIDS_HRC
32 #include <svx/svxids.hrc>
33 #endif
34 #include <svx/svdpagv.hxx>
35 #include <svx/svdundo.hxx>
36 #ifndef _ZOOMITEM_HXX
37 #include <svx/zoomitem.hxx>
38 #endif
39 #ifndef _EDITDATA_HXX
40 #include <editeng/editdata.hxx>
41 #endif
42 #include <basic/sberrors.hxx>
43 #include <vcl/msgbox.hxx>
44 #include <sfx2/request.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <svx/xfillit0.hxx>
47 #include <svx/xflclit.hxx>
48 #include <svl/aeitem.hxx>
49 #include <editeng/eeitem.hxx>
50 #include <basic/sbstar.hxx>
51 #include <editeng/flditem.hxx>
52 #include <svx/xlineit0.hxx>
53 #include <svx/xfillit0.hxx>
54
55 #ifndef _SDOUTL_HXX //autogen
56 #include <svx/svdoutl.hxx>
57 #endif
58 #include <svx/xlnwtit.hxx>
59 #include <svx/svdoattr.hxx>
60 #include <svx/xlnstwit.hxx>
61 #include <svx/sdtmfitm.hxx>
62 #include <svx/sdtagitm.hxx>
63 #include <svx/xlnedwit.hxx>
64 #include <svx/fontworkbar.hxx>
65
66 #include <editeng/escpitem.hxx>
67 #include <editeng/kernitem.hxx>
68 #include <editeng/wghtitem.hxx>
69 #include <editeng/postitem.hxx>
70 #include <editeng/udlnitem.hxx>
71 #include <editeng/crsditem.hxx>
72 #include <editeng/cntritem.hxx>
73 #include <editeng/shdditem.hxx>
74 #include <svx/xtable.hxx>
75 #include <svx/svdobj.hxx>
76 #include <editeng/outlobj.hxx>
77 #include <editeng/flstitem.hxx>
78 #include <editeng/scripttypeitem.hxx>
79 #include <editeng/fontitem.hxx>
80 #include <editeng/fhgtitem.hxx>
81 #include <editeng/colritem.hxx>
82 #include <editeng/brshitem.hxx>
83
84 #include <svl/whiter.hxx>
85
86 #include <svx/svxdlg.hxx>
87 #include <svx/dialogs.hrc>
88
89 #include <sfx2/viewfrm.hxx>
90 #include "sdgrffilter.hxx"
91
92 #include "app.hrc"
93 #include "glob.hrc"
94 #include "helpids.h"
95 #include "sdattr.hxx"
96 #include "drawview.hxx"
97 #include "Window.hxx"
98 #include "drawdoc.hxx"
99 #include "DrawDocShell.hxx"
100 #include "sdpage.hxx"
101 #include "fuscale.hxx"
102 #include "sdresid.hxx"
103 #include "GraphicViewShell.hxx"
104 #include "unmodpg.hxx"
105 #include "slideshow.hxx"
106 #include "fuvect.hxx"
107 #include "futext.hxx"
108 #include "stlpool.hxx"
109
110 // #90356#
111 #include "optsitem.hxx"
112 #include "sdabstdlg.hxx"
113 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
114 #include <com/sun/star/drawing/XDrawPages.hpp>
115
116 #include <strings.hrc>
117
118 using namespace ::com::sun::star;
119 using namespace ::com::sun::star::uno;
120
121 namespace sd {
122
123 /*************************************************************************
124 |*
125 |* SfxRequests fuer temporaere Funktionen
126 |*
127 \************************************************************************/
128
FuTemporary(SfxRequest & rReq)129 void DrawViewShell::FuTemporary(SfxRequest& rReq)
130 {
131 // Waehrend einer Native-Diashow wird nichts ausgefuehrt!
132 if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR))
133 return;
134
135 DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" );
136 if( !mpDrawView )
137 return;
138
139 CheckLineTo (rReq);
140
141 DeactivateCurrentFunction();
142
143 sal_uInt16 nSId = rReq.GetSlot();
144
145 // Slot wird gemapped (ToolboxImages/-Slots)
146 MapSlot( nSId );
147
148 switch ( nSId )
149 {
150 // Flaechen und Linien-Attribute:
151 // Sollten (wie StateMethode) eine eigene
152 // Execute-Methode besitzen
153 case SID_ATTR_FILL_STYLE:
154 case SID_ATTR_FILL_COLOR:
155 case SID_ATTR_FILL_GRADIENT:
156 case SID_ATTR_FILL_HATCH:
157 case SID_ATTR_FILL_BITMAP:
158 case SID_ATTR_FILL_SHADOW:
159 case SID_ATTR_FILL_TRANSPARENCE:
160 case SID_ATTR_FILL_FLOATTRANSPARENCE:
161
162 case SID_ATTR_LINE_STYLE:
163 case SID_ATTR_LINE_DASH:
164 case SID_ATTR_LINE_WIDTH:
165 case SID_ATTR_LINE_COLOR:
166 case SID_ATTR_LINEEND_STYLE:
167 case SID_ATTR_LINE_START:
168 case SID_ATTR_LINE_END:
169 case SID_ATTR_LINE_TRANSPARENCE:
170 case SID_ATTR_LINE_JOINT:
171 case SID_ATTR_LINE_CAP:
172
173 case SID_ATTR_TEXT_FITTOSIZE:
174 {
175 if( rReq.GetArgs() )
176 {
177 mpDrawView->SetAttributes(*rReq.GetArgs());
178 rReq.Done();
179 }
180 else
181 {
182 switch( rReq.GetSlot() )
183 {
184 case SID_ATTR_FILL_SHADOW:
185 case SID_ATTR_FILL_STYLE:
186 case SID_ATTR_FILL_COLOR:
187 case SID_ATTR_FILL_GRADIENT:
188 case SID_ATTR_FILL_HATCH:
189 case SID_ATTR_FILL_BITMAP:
190 case SID_ATTR_FILL_TRANSPARENCE:
191 case SID_ATTR_FILL_FLOATTRANSPARENCE:
192 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA, SFX_CALLMODE_ASYNCHRON );
193 break;
194 case SID_ATTR_LINE_STYLE:
195 case SID_ATTR_LINE_DASH:
196 case SID_ATTR_LINE_WIDTH:
197 case SID_ATTR_LINE_COLOR:
198 case SID_ATTR_LINE_TRANSPARENCE:
199 case SID_ATTR_LINE_JOINT:
200 case SID_ATTR_LINE_CAP:
201 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE, SFX_CALLMODE_ASYNCHRON );
202 break;
203 case SID_ATTR_TEXT_FITTOSIZE:
204 GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG, SFX_CALLMODE_ASYNCHRON );
205 break;
206 }
207 }
208 Cancel();
209 }
210 break;
211
212 case SID_HYPHENATION:
213 {
214 // const SfxPoolItem* pItem = rReq.GetArg( SID_HYPHENATION );
215 // ^-- Soll so nicht benutzt werden (Defaults sind falsch) !
216 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_HYPHENATION, sal_False);
217
218 if( pItem )
219 {
220 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
221 sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
222 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
223 mpDrawView->SetAttributes( aSet );
224 }
225 else // nur zum Test
226 {
227 DBG_ERROR(" Kein Wert fuer Silbentrennung!");
228 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
229 sal_Bool bValue = sal_True;
230 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
231 mpDrawView->SetAttributes( aSet );
232 }
233 rReq.Done();
234 Cancel();
235 }
236 break;
237
238 case SID_INSERTPAGE:
239 case SID_INSERTPAGE_QUICK:
240 case SID_DUPLICATE_PAGE:
241 {
242 SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
243 Cancel();
244 if(HasCurrentFunction(SID_BEZIER_EDIT) )
245 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
246 if (pNewPage != NULL)
247 SwitchPage((pNewPage->GetPageNum()-1)/2);
248 rReq.Done ();
249 }
250 break;
251
252 case SID_INSERT_MASTER_PAGE:
253 {
254 // Use the API to create a new page.
255 Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier (
256 GetDoc()->getUnoModel(), UNO_QUERY);
257 if (xMasterPagesSupplier.is())
258 {
259 Reference<drawing::XDrawPages> xMasterPages (
260 xMasterPagesSupplier->getMasterPages());
261 if (xMasterPages.is())
262 {
263 sal_uInt16 nIndex = GetCurPageId();
264 xMasterPages->insertNewByIndex (nIndex);
265
266 // Create shapes for the default layout.
267 SdPage* pMasterPage = GetDoc()->GetMasterSdPage(
268 nIndex, PK_STANDARD);
269 pMasterPage->CreateTitleAndLayout (sal_True,sal_True);
270 }
271 }
272
273 Cancel();
274 if(HasCurrentFunction(SID_BEZIER_EDIT))
275 GetViewFrame()->GetDispatcher()->Execute(
276 SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
277 rReq.Done ();
278 }
279 break;
280
281 case SID_MODIFYPAGE:
282 {
283 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES ||
284 (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE) )
285 {
286 if ( mpDrawView->IsTextEdit() )
287 {
288 mpDrawView->SdrEndTextEdit();
289 }
290 sal_uInt16 nPage = maTabControl.GetCurPageId() - 1;
291 mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind);
292 ::sd::ViewShell::mpImpl->ProcessModifyPageSlot (
293 rReq,
294 mpActualPage,
295 mePageKind);
296 }
297
298 Cancel();
299 rReq.Done ();
300 }
301 break;
302
303 case SID_ASSIGN_LAYOUT:
304 {
305 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES || (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE))
306 {
307 if ( mpDrawView->IsTextEdit() )
308 mpDrawView->SdrEndTextEdit();
309
310 ::sd::ViewShell::mpImpl->AssignLayout(rReq, mePageKind);
311 }
312 Cancel();
313 rReq.Done ();
314 }
315 break;
316
317 case SID_RENAMEPAGE:
318 case SID_RENAME_MASTER_PAGE:
319 {
320 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
321 {
322 if ( mpDrawView->IsTextEdit() )
323 {
324 mpDrawView->SdrEndTextEdit();
325 }
326
327 sal_uInt16 nPageId = maTabControl.GetCurPageId();
328 SdPage* pCurrentPage = ( GetEditMode() == EM_PAGE )
329 ? GetDoc()->GetSdPage( nPageId - 1, GetPageKind() )
330 : GetDoc()->GetMasterSdPage( nPageId - 1, GetPageKind() );
331
332 String aTitle( SdResId( STR_TITLE_RENAMESLIDE ) );
333 String aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
334 String aPageName = pCurrentPage->GetName();
335
336 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
337 DBG_ASSERT(pFact, "Dialogdiet fail!");
338 AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( GetActiveWindow(), aPageName, aDescr );
339 DBG_ASSERT(aNameDlg, "Dialogdiet fail!");
340 aNameDlg->SetText( aTitle );
341 aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl ), true );
342 aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
343
344 if( aNameDlg->Execute() == RET_OK )
345 {
346 String aNewName;
347 aNameDlg->GetName( aNewName );
348 if( ! aNewName.Equals( aPageName ) )
349 {
350 #ifdef DBG_UTIL
351 bool bResult =
352 #endif
353 RenameSlide( nPageId, aNewName );
354 DBG_ASSERT( bResult, "Couldn't rename slide" );
355 }
356 }
357 delete aNameDlg;
358 }
359
360 Cancel();
361 rReq.Ignore ();
362 }
363 break;
364
365 case SID_RENAMEPAGE_QUICK:
366 {
367 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
368 {
369 if ( mpDrawView->IsTextEdit() )
370 {
371 mpDrawView->SdrEndTextEdit();
372 }
373
374 maTabControl.StartEditMode( maTabControl.GetCurPageId() );
375 }
376
377 Cancel();
378 rReq.Ignore ();
379 }
380 break;
381
382 case SID_PAGESIZE : // entweder dieses (kein menueeintrag o. ae. !!)
383 {
384 const SfxItemSet *pArgs = rReq.GetArgs ();
385
386 if (pArgs)
387 if (pArgs->Count () == 3)
388 {
389 SFX_REQUEST_ARG (rReq, pWidth, SfxUInt32Item, ID_VAL_PAGEWIDTH, sal_False);
390 SFX_REQUEST_ARG (rReq, pHeight, SfxUInt32Item, ID_VAL_PAGEHEIGHT, sal_False);
391 SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, sal_False);
392
393 Size aSize (pWidth->GetValue (), pHeight->GetValue ());
394
395 SetupPage (aSize, 0, 0, 0, 0, sal_True, sal_False, pScaleAll->GetValue ());
396 rReq.Ignore ();
397 break;
398 }
399
400 StarBASIC::FatalError (SbERR_WRONG_ARGS);
401 rReq.Ignore ();
402 break;
403 }
404
405 case SID_PAGEMARGIN : // oder dieses (kein menueeintrag o. ae. !!)
406 {
407 const SfxItemSet *pArgs = rReq.GetArgs ();
408
409 if (pArgs)
410 if (pArgs->Count () == 5)
411 {
412 SFX_REQUEST_ARG (rReq, pLeft, SfxUInt32Item, ID_VAL_PAGELEFT, sal_False);
413 SFX_REQUEST_ARG (rReq, pRight, SfxUInt32Item, ID_VAL_PAGERIGHT, sal_False);
414 SFX_REQUEST_ARG (rReq, pUpper, SfxUInt32Item, ID_VAL_PAGETOP, sal_False);
415 SFX_REQUEST_ARG (rReq, pLower, SfxUInt32Item, ID_VAL_PAGEBOTTOM, sal_False);
416 SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, sal_False);
417
418 Size aEmptySize (0, 0);
419
420 SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (),
421 pUpper->GetValue (), pLower->GetValue (),
422 sal_False, sal_True, pScaleAll->GetValue ());
423 rReq.Ignore ();
424 break;
425 }
426
427 StarBASIC::FatalError (SbERR_WRONG_ARGS);
428 rReq.Ignore ();
429 break;
430 }
431
432 case SID_ATTR_ZOOMSLIDER:
433 {
434 const SfxItemSet* pArgs = rReq.GetArgs();
435
436 if (pArgs && pArgs->Count () == 1 )
437 {
438 SFX_REQUEST_ARG (rReq, pScale, SfxUInt16Item, SID_ATTR_ZOOMSLIDER, sal_False);
439 if (CHECK_RANGE (5, pScale->GetValue (), 3000))
440 {
441 SetZoom (pScale->GetValue ());
442
443 SfxBindings& rBindings = GetViewFrame()->GetBindings();
444 rBindings.Invalidate( SID_ATTR_ZOOM );
445 rBindings.Invalidate( SID_ZOOM_IN );
446 rBindings.Invalidate( SID_ZOOM_OUT );
447 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
448
449 }
450 }
451
452 Cancel();
453 rReq.Done ();
454 break;
455 }
456 case SID_ZOOMING : // kein Menueintrag, sondern aus dem Zoomdialog generiert
457 {
458 const SfxItemSet* pArgs = rReq.GetArgs();
459
460 if (pArgs)
461 if (pArgs->Count () == 1)
462 {
463 SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, sal_False);
464 if (CHECK_RANGE (10, pScale->GetValue (), 1000))
465 {
466 SetZoom (pScale->GetValue ());
467
468 SfxBindings& rBindings = GetViewFrame()->GetBindings();
469 rBindings.Invalidate( SID_ATTR_ZOOM );
470 rBindings.Invalidate( SID_ZOOM_IN );
471 rBindings.Invalidate( SID_ZOOM_OUT );
472 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
473 }
474 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
475
476 rReq.Ignore ();
477 break;
478 }
479
480 StarBASIC::FatalError (SbERR_WRONG_ARGS);
481 rReq.Ignore ();
482 break;
483 }
484
485 case SID_ATTR_ZOOM:
486 {
487 const SfxItemSet* pArgs = rReq.GetArgs();
488 mbZoomOnPage = sal_False;
489
490 if ( pArgs )
491 {
492 SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs->
493 Get( SID_ATTR_ZOOM ) ).GetType();
494 switch( eZT )
495 {
496 case SVX_ZOOM_PERCENT:
497 SetZoom( (long) ( ( const SvxZoomItem& ) pArgs->
498 Get( SID_ATTR_ZOOM ) ).GetValue() );
499 break;
500
501 case SVX_ZOOM_OPTIMAL:
502 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL,
503 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
504 break;
505
506 case SVX_ZOOM_PAGEWIDTH:
507 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH,
508 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
509 break;
510
511 case SVX_ZOOM_WHOLEPAGE:
512 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE,
513 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
514 break;
515 case SVX_ZOOM_PAGEWIDTH_NOBORDER:
516 DBG_ERROR("sd::DrawViewShell::FuTemporary(), SVX_ZOOM_PAGEWIDTH_NOBORDER not handled!" );
517 break;
518 }
519 rReq.Ignore ();
520 }
521 else
522 {
523 // hier den Zoom-Dialog oeffnen
524 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
525 }
526 Cancel();
527 }
528 break;
529
530 case SID_CHANGEBEZIER:
531 case SID_CHANGEPOLYGON:
532 if ( mpDrawView->IsTextEdit() )
533 {
534 mpDrawView->SdrEndTextEdit();
535 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
536 }
537
538 if ( mpDrawView->IsPresObjSelected() )
539 {
540 ::sd::Window* pWindow = GetActiveWindow();
541 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
542 }
543 else
544 {
545 if( rReq.GetSlot() == SID_CHANGEBEZIER )
546 {
547 WaitObject aWait( (Window*)GetActiveWindow() );
548 mpDrawView->ConvertMarkedToPathObj(sal_False);
549 }
550 else
551 {
552 if( mpDrawView->IsVectorizeAllowed() )
553 {
554 SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
555 }
556 else
557 {
558 WaitObject aWait( (Window*)GetActiveWindow() );
559 mpDrawView->ConvertMarkedToPolyObj(sal_False);
560 }
561 }
562
563 Invalidate(SID_CHANGEBEZIER);
564 Invalidate(SID_CHANGEPOLYGON);
565 }
566 Cancel();
567
568 if( HasCurrentFunction(SID_BEZIER_EDIT) )
569 { // ggf. die richtige Editfunktion aktivieren
570 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT,
571 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
572 }
573 rReq.Ignore ();
574 break;
575
576 case SID_CONVERT_TO_CONTOUR:
577 if ( mpDrawView->IsTextEdit() )
578 {
579 mpDrawView->SdrEndTextEdit();
580 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
581 }
582
583 if ( mpDrawView->IsPresObjSelected() )
584 {
585 ::sd::Window* pWindow = GetActiveWindow();
586 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
587 }
588 else
589 {
590 WaitObject aWait( (Window*)GetActiveWindow() );
591 mpDrawView->ConvertMarkedToPathObj(sal_True);
592
593 Invalidate(SID_CONVERT_TO_CONTOUR);
594 }
595 Cancel();
596
597 rReq.Ignore ();
598 break;
599
600 case SID_CONVERT_TO_METAFILE:
601 case SID_CONVERT_TO_BITMAP:
602 {
603 // End text edit mode when it is active because the metafile or
604 // bitmap that will be created does not support it.
605 if ( mpDrawView->IsTextEdit() )
606 {
607 mpDrawView->SdrEndTextEdit();
608 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
609 }
610
611 if ( mpDrawView->IsPresObjSelected(true,true,true) )
612 {
613 ::sd::Window* pWindow = GetActiveWindow();
614 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
615 }
616 else
617 {
618 WaitObject aWait( (Window*)GetActiveWindow() );
619
620 // switch on undo for the next operations
621 mpDrawView->BegUndo(
622 String(
623 SdResId (nSId==SID_CONVERT_TO_METAFILE ? STR_UNDO_CONVERT_TO_METAFILE : STR_UNDO_CONVERT_TO_BITMAP)));
624
625 // create SdrGrafObj from metafile/bitmap
626 Graphic aGraphic;
627 switch (nSId)
628 {
629 case SID_CONVERT_TO_METAFILE:
630 {
631 GDIMetaFile aMetaFile(mpDrawView->GetMarkedObjMetaFile());
632 aGraphic = Graphic(aMetaFile);
633 }
634 break;
635 case SID_CONVERT_TO_BITMAP:
636 {
637 bool bDone(false);
638
639 // I have to get the image here directly since GetMarkedObjBitmapEx works
640 // based on Bitmaps, but not on BitmapEx, thus throwing away the alpha
641 // channel. Argh! GetMarkedObjBitmapEx itself is too widely used to safely
642 // change that, e.g. in the exchange formats. For now I can only add this
643 // exception to get good results for Svgs. This is how the code gets more
644 // and more crowded, at last I made a remark for myself to change this
645 // as one of the next tasks.
646 if(1 == mpDrawView->GetMarkedObjectCount())
647 {
648 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(mpDrawView->GetMarkedObjectByIndex(0));
649
650 if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg())
651 {
652 aGraphic = Graphic(pSdrGrafObj->GetGraphic().getSvgData()->getReplacement());
653 bDone = true;
654 }
655 }
656
657 if(!bDone)
658 {
659 aGraphic = Graphic(mpDrawView->GetMarkedObjBitmapEx());
660 }
661 }
662 break;
663 }
664
665 // create new object
666 SdrGrafObj* pGraphicObj = new SdrGrafObj (aGraphic);
667
668 // get some necessary info and ensure it
669 const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
670 const sal_uInt32 nMarkCount(rMarkList.GetMarkCount());
671 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
672 OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)");
673 OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)");
674
675 // fit rectangle of new graphic object to selection's mark rect
676 Rectangle aAllMarkedRect;
677 rMarkList.TakeBoundRect(pPageView, aAllMarkedRect);
678 pGraphicObj->SetLogicRect(aAllMarkedRect);
679
680 // #i71540# to keep the order, it is necessary to replace the lowest object
681 // of the selection with the new object. This also means that with multi
682 // selection, all other objects need to be deleted first
683 SdrMark* pFirstMark = rMarkList.GetMark(0L);
684 SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj();
685
686 if(nMarkCount > 1L)
687 {
688 // take first object out of selection
689 mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true);
690
691 // clear remaining selection
692 mpDrawView->DeleteMarkedObj();
693 }
694
695 // #124816# copy layer from lowest object which gets replaced
696 pGraphicObj->SetLayer(pReplacementCandidate->GetLayer());
697
698 // now replace lowest object with new one
699 mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj);
700
701 // switch off undo
702 mpDrawView->EndUndo();
703 }
704 }
705
706 Cancel();
707
708 rReq.Done ();
709 break;
710
711 case SID_SET_DEFAULT:
712 {
713 SfxItemSet* pSet = NULL;
714
715 if (mpDrawView->IsTextEdit())
716 {
717 ::Outliner* pOutl = mpDrawView->GetTextEditOutliner();
718 if (pOutl)
719 {
720 pOutl->RemoveFields(sal_True, (TypeId) SvxURLField::StaticType());
721 }
722
723 pSet = new SfxItemSet( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
724 mpDrawView->SetAttributes( *pSet, sal_True );
725 }
726 else
727 {
728 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
729 sal_uLong nCount = rMarkList.GetMarkCount();
730
731 // In diese Liste werden fuer jedes Praesentationsobjekt ein SfxItemSet
732 // der harten Attribute sowie der UserCall eingetragen, da diese beim nachfolgenden
733 // mpDrawView->SetAttributes( *pSet, sal_True ) verloren gehen und spaeter restauriert
734 // werden muessen
735 List* pAttrList = new List();
736 SdPage* pPresPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
737 sal_uLong i;
738
739 for ( i = 0; i < nCount; i++ )
740 {
741 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
742
743 if( pPresPage->IsPresObj( pObj ) )
744 {
745 SfxItemSet* pNewSet = new SfxItemSet( GetDoc()->GetPool(), SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 0 );
746 pNewSet->Put(pObj->GetMergedItemSet());
747 pAttrList->Insert( pNewSet, LIST_APPEND );
748 pAttrList->Insert( pObj->GetUserCall(), LIST_APPEND );
749 }
750 }
751
752 pSet = new SfxItemSet( GetPool() );
753 mpDrawView->SetAttributes( *pSet, sal_True );
754
755 sal_uLong j = 0;
756
757 for ( i = 0; i < nCount; i++ )
758 {
759 SfxStyleSheet* pSheet = NULL;
760 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
761
762 if (pObj->GetObjIdentifier() == OBJ_TITLETEXT)
763 {
764 pSheet = mpActualPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
765 if (pSheet)
766 pObj->SetStyleSheet(pSheet, sal_False);
767 }
768 else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
769 {
770 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
771 {
772 pSheet = mpActualPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
773 DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
774 if (pSheet)
775 {
776 pObj->StartListening(*pSheet);
777
778 if( nLevel == 1 )
779 // Textrahmen hoert auf StyleSheet der Ebene1
780 pObj->NbcSetStyleSheet(pSheet, sal_False);
781
782 }
783 }
784 }
785
786 if( pPresPage->IsPresObj( pObj ) )
787 {
788 SfxItemSet* pNewSet = (SfxItemSet*) pAttrList->GetObject(j++);
789 SdrObjUserCall* pUserCall = (SdrObjUserCall*) pAttrList->GetObject(j++);
790
791 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SFX_ITEM_ON )
792 {
793 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT));
794 }
795
796 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SFX_ITEM_ON )
797 {
798 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT));
799 }
800
801 if( pUserCall )
802 pObj->SetUserCall( pUserCall );
803
804 delete pNewSet;
805 }
806 }
807
808 delete pAttrList;
809 }
810
811 delete pSet;
812 Cancel();
813 }
814 break;
815
816 case SID_DELETE_SNAPITEM:
817 {
818 SdrPageView* pPV;
819 Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos );
820 sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic( Size(
821 FuPoor::HITPIX, 0 ) ).Width();
822 sal_uInt16 nHelpLine;
823
824 mbMousePosFreezed = sal_False;
825
826 if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
827 {
828 pPV->DeleteHelpLine( nHelpLine );
829 }
830 Cancel();
831 rReq.Ignore ();
832 }
833 break;
834
835 case SID_DELETE_PAGE:
836 case SID_DELETE_MASTER_PAGE:
837 DeleteActualPage();
838 Cancel();
839 rReq.Ignore ();
840 break;
841
842 case SID_DELETE_LAYER:
843 DeleteActualLayer();
844 Cancel();
845 rReq.Ignore ();
846 break;
847
848 case SID_ORIGINAL_SIZE:
849 mpDrawView->SetMarkedOriginalSize();
850 Cancel();
851 rReq.Done();
852 break;
853
854 case SID_DRAW_FONTWORK:
855 case SID_DRAW_FONTWORK_VERTICAL:
856 {
857 svx::FontworkBar::execute( mpView, rReq, GetViewFrame()->GetBindings() ); // SJ: can be removed (I think)
858 Cancel();
859 rReq.Done();
860 }
861 break;
862
863 case SID_SAVEGRAPHIC:
864 {
865 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
866 if( rMarkList.GetMarkCount() == 1 )
867 {
868 SdrGrafObj *pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
869 if(pGrafObj )
870 {
871 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape( pGrafObj->getUnoShape(), com::sun::star::uno::UNO_QUERY );
872 SdGRFFilter::SaveGraphic( xShape );
873 }
874 }
875 Cancel();
876 rReq.Ignore();
877 }
878 break;
879
880 default:
881 {
882 // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
883 // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8)
884 // gewandert.
885 FuTemp01(rReq);
886 }
887 break;
888 }
889
890 if(HasCurrentFunction())
891 {
892 GetCurrentFunction()->Activate();
893 }
894 }
895
ExecChar(SfxRequest & rReq)896 void DrawViewShell::ExecChar( SfxRequest &rReq )
897 {
898 SdDrawDocument* pDoc = GetDoc();
899 if (!pDoc || !mpDrawView)
900 return;
901
902 SfxItemSet aEditAttr( pDoc->GetPool() );
903 mpDrawView->GetAttributes( aEditAttr );
904
905 //modified by wj for sym2_1580, if put old itemset into new set,
906 //when mpDrawView->SetAttributes(aNewAttr) it will invalidate all the item
907 // and use old attr to update all the attributes
908 // SfxItemSet aNewAttr( GetPool(),
909 // EE_ITEMS_START, EE_ITEMS_END );
910 // aNewAttr.Put( aEditAttr, sal_False );
911 SfxItemSet aNewAttr( pDoc->GetPool() );
912 //modified end
913
914 sal_uInt16 nSId = rReq.GetSlot();
915
916 MapSlot( nSId );
917
918 switch ( nSId )
919 {
920 case SID_ATTR_CHAR_FONT:
921 if( rReq.GetArgs() )
922 {
923 SFX_REQUEST_ARG( rReq, pItem, SvxFontItem, SID_ATTR_CHAR_FONT , sal_False );
924 if (pItem)
925 {
926 aNewAttr.Put(*pItem);
927 }
928 }
929 break;
930 case SID_ATTR_CHAR_FONTHEIGHT:
931 if( rReq.GetArgs() )
932 {
933 SFX_REQUEST_ARG( rReq, pItem, SvxFontHeightItem, SID_ATTR_CHAR_FONTHEIGHT , sal_False );
934 if (pItem)
935 {
936 aNewAttr.Put(*pItem);
937 }
938 }
939 break;
940 case SID_ATTR_CHAR_WEIGHT:
941 if( rReq.GetArgs() )
942 {
943 //const SvxWeightItem *pItem = (const SvxWeightItem*) rReq.GetArg( SID_ATTR_CHAR_WEIGHT, sal_False, TYPE(SvxWeightItem) );
944 SFX_REQUEST_ARG( rReq, pItem, SvxWeightItem, SID_ATTR_CHAR_WEIGHT , sal_False );
945 if (pItem)
946 {
947 aNewAttr.Put(*pItem);
948 }
949 }
950 break;
951 case SID_ATTR_CHAR_POSTURE:
952 if( rReq.GetArgs() )
953 {
954 //const SvxPostureItem *pItem = (const SvxPostureItem*) rReq.GetArg( SID_ATTR_CHAR_POSTURE, sal_False, TYPE(SvxPostureItem) );
955 SFX_REQUEST_ARG( rReq, pItem, SvxPostureItem, SID_ATTR_CHAR_POSTURE , sal_False );
956 if (pItem)
957 {
958 aNewAttr.Put(*pItem);
959 }
960 }
961 break;
962 case SID_ATTR_CHAR_UNDERLINE:
963 if( rReq.GetArgs() )
964 {
965 //<<modify by wj for sym2_1873
966 //SFX_REQUEST_ARG( rReq, pItem, SvxTextLineItem, SID_ATTR_CHAR_UNDERLINE , sal_False );
967 SFX_REQUEST_ARG( rReq, pItem, SvxUnderlineItem, SID_ATTR_CHAR_UNDERLINE , sal_False );
968 //end>>
969 if (pItem)
970 {
971 aNewAttr.Put(*pItem);
972 }
973 else
974 {
975 FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr.Get( EE_CHAR_UNDERLINE ) ).GetLineStyle();
976 aNewAttr.Put( SvxUnderlineItem( eFU != UNDERLINE_NONE ?UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE ) );
977 }//aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
978 }
979 break;
980 case SID_ATTR_CHAR_SHADOWED:
981 if( rReq.GetArgs() )
982 {
983 SFX_REQUEST_ARG( rReq, pItem, SvxShadowedItem, SID_ATTR_CHAR_SHADOWED , sal_False );
984 if (pItem)
985 {
986 aNewAttr.Put(*pItem);
987 }
988 }
989 break;
990 case SID_ATTR_CHAR_STRIKEOUT:
991 if( rReq.GetArgs() )
992 {
993 SFX_REQUEST_ARG( rReq, pItem, SvxCrossedOutItem, SID_ATTR_CHAR_STRIKEOUT , sal_False );
994 if (pItem)
995 {
996 aNewAttr.Put(*pItem);
997 }
998 }
999 break;
1000 case SID_ATTR_CHAR_COLOR:
1001 if( rReq.GetArgs() )
1002 {
1003 SFX_REQUEST_ARG( rReq, pItem, SvxColorItem, SID_ATTR_CHAR_COLOR , sal_False );
1004 if (pItem)
1005 {
1006 aNewAttr.Put(*pItem);
1007 }
1008 }
1009 break;
1010 case SID_ATTR_CHAR_KERNING:
1011 if( rReq.GetArgs() )
1012 {
1013 SFX_REQUEST_ARG( rReq, pItem, SvxKerningItem, SID_ATTR_CHAR_KERNING , sal_False );
1014 if (pItem)
1015 {
1016 aNewAttr.Put(*pItem);
1017 }
1018 }
1019 break;
1020 case SID_SET_SUB_SCRIPT:
1021 if( rReq.GetArgs() )
1022 {
1023 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
1024 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
1025 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1026 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
1027 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
1028 else
1029 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
1030 aNewAttr.Put( aItem );
1031 }
1032 break;
1033 case SID_SET_SUPER_SCRIPT:
1034 if( rReq.GetArgs() )
1035 {
1036 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
1037 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
1038 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1039 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
1040 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
1041 else
1042 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
1043 aNewAttr.Put( aItem );
1044 }
1045 break;
1046 case SID_SHRINK_FONT_SIZE:
1047 case SID_GROW_FONT_SIZE:
1048 //if (rReq.GetArgs())
1049 {
1050 const SvxFontListItem* pFonts = dynamic_cast<const SvxFontListItem*>(GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
1051 const FontList* pFontList = pFonts->GetFontList();
1052 if( pFontList )
1053 {
1054 FuText::ChangeFontSize( nSId == SID_GROW_FONT_SIZE, NULL, pFontList, mpView );
1055 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
1056 }
1057 }
1058 default:
1059 ;
1060 }
1061
1062 mpDrawView->SetAttributes(aNewAttr);
1063 rReq.Done();
1064 Cancel();
1065 }
1066
1067
1068 /** This method consists basically of three parts:
1069 1. Process the arguments of the SFX request.
1070 2. Use the model to create a new page or duplicate an existing one.
1071 3. Update the tab control and switch to the new page.
1072 */
CreateOrDuplicatePage(SfxRequest & rRequest,PageKind ePageKind,SdPage * pPage,const sal_Int32 nInsertPosition)1073 SdPage* DrawViewShell::CreateOrDuplicatePage (
1074 SfxRequest& rRequest,
1075 PageKind ePageKind,
1076 SdPage* pPage,
1077 const sal_Int32 nInsertPosition)
1078 {
1079 SdPage* pNewPage = NULL;
1080 if (ePageKind == PK_STANDARD && meEditMode != EM_MASTERPAGE)
1081 {
1082 if ( mpDrawView->IsTextEdit() )
1083 {
1084 mpDrawView->SdrEndTextEdit();
1085 }
1086 pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition);
1087 }
1088 return pNewPage;
1089 }
1090
ExecutePropPanelAttr(SfxRequest & rReq)1091 void DrawViewShell::ExecutePropPanelAttr (SfxRequest& rReq)
1092 {
1093 if(SlideShow::IsRunning( GetViewShellBase() ))
1094 return;
1095
1096 SdDrawDocument* pDoc = GetDoc();
1097 if (!pDoc || !mpDrawView)
1098 return;
1099
1100 sal_uInt16 nSId = rReq.GetSlot();
1101 SfxItemSet aAttrs( pDoc->GetPool() );
1102
1103 switch ( nSId )
1104 {
1105 case SID_TABLE_VERT_NONE:
1106 case SID_TABLE_VERT_CENTER:
1107 case SID_TABLE_VERT_BOTTOM:
1108 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
1109 if (nSId == SID_TABLE_VERT_CENTER)
1110 eTVA = SDRTEXTVERTADJUST_CENTER;
1111 else if (nSId == SID_TABLE_VERT_BOTTOM)
1112 eTVA = SDRTEXTVERTADJUST_BOTTOM;
1113
1114 aAttrs.Put( SdrTextVertAdjustItem(eTVA) );
1115 mpDrawView->SetAttributes(aAttrs);
1116
1117 break;
1118 }
1119 }
1120
GetStatePropPanelAttr(SfxItemSet & rSet)1121 void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet)
1122 {
1123 SfxWhichIter aIter( rSet );
1124 sal_uInt16 nWhich = aIter.FirstWhich();
1125
1126 SdDrawDocument* pDoc = GetDoc();
1127 if (!pDoc || !mpDrawView)
1128 return;
1129
1130 SfxItemSet aAttrs( pDoc->GetPool() );
1131 mpDrawView->GetAttributes( aAttrs );
1132
1133 while ( nWhich )
1134 {
1135 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1136 ? GetPool().GetSlotId(nWhich)
1137 : nWhich;
1138 switch ( nSlotId )
1139 {
1140 case SID_TABLE_VERT_NONE:
1141 case SID_TABLE_VERT_CENTER:
1142 case SID_TABLE_VERT_BOTTOM:
1143 sal_Bool bContour = sal_False;
1144 SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1145 if( eConState != SFX_ITEM_DONTCARE )
1146 {
1147 bContour = ( ( const SdrTextContourFrameItem& )aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
1148 }
1149 if (bContour) break;
1150
1151 SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
1152 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1153
1154 //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
1155 if(SFX_ITEM_DONTCARE != eVState)
1156 {
1157 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
1158 sal_Bool bSet = nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP||
1159 nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER ||
1160 nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM;
1161 rSet.Put(SfxBoolItem(nSlotId, bSet));
1162 }
1163 else
1164 {
1165 rSet.Put(SfxBoolItem(nSlotId, sal_False));
1166 }
1167 break;
1168 }
1169 nWhich = aIter.NextWhich();
1170 }
1171 }
1172
1173 } // end of namespace sd
1174