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 // now replace lowest object with new one
696 mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj);
697
698 // switch off undo
699 mpDrawView->EndUndo();
700 }
701 }
702
703 Cancel();
704
705 rReq.Done ();
706 break;
707
708 case SID_SET_DEFAULT:
709 {
710 SfxItemSet* pSet = NULL;
711
712 if (mpDrawView->IsTextEdit())
713 {
714 ::Outliner* pOutl = mpDrawView->GetTextEditOutliner();
715 if (pOutl)
716 {
717 pOutl->RemoveFields(sal_True, (TypeId) SvxURLField::StaticType());
718 }
719
720 pSet = new SfxItemSet( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
721 mpDrawView->SetAttributes( *pSet, sal_True );
722 }
723 else
724 {
725 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
726 sal_uLong nCount = rMarkList.GetMarkCount();
727
728 // In diese Liste werden fuer jedes Praesentationsobjekt ein SfxItemSet
729 // der harten Attribute sowie der UserCall eingetragen, da diese beim nachfolgenden
730 // mpDrawView->SetAttributes( *pSet, sal_True ) verloren gehen und spaeter restauriert
731 // werden muessen
732 List* pAttrList = new List();
733 SdPage* pPresPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
734 sal_uLong i;
735
736 for ( i = 0; i < nCount; i++ )
737 {
738 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
739
740 if( pPresPage->IsPresObj( pObj ) )
741 {
742 SfxItemSet* pNewSet = new SfxItemSet( GetDoc()->GetPool(), SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 0 );
743 pNewSet->Put(pObj->GetMergedItemSet());
744 pAttrList->Insert( pNewSet, LIST_APPEND );
745 pAttrList->Insert( pObj->GetUserCall(), LIST_APPEND );
746 }
747 }
748
749 pSet = new SfxItemSet( GetPool() );
750 mpDrawView->SetAttributes( *pSet, sal_True );
751
752 sal_uLong j = 0;
753
754 for ( i = 0; i < nCount; i++ )
755 {
756 SfxStyleSheet* pSheet = NULL;
757 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
758
759 if (pObj->GetObjIdentifier() == OBJ_TITLETEXT)
760 {
761 pSheet = mpActualPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
762 if (pSheet)
763 pObj->SetStyleSheet(pSheet, sal_False);
764 }
765 else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
766 {
767 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
768 {
769 pSheet = mpActualPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
770 DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
771 if (pSheet)
772 {
773 pObj->StartListening(*pSheet);
774
775 if( nLevel == 1 )
776 // Textrahmen hoert auf StyleSheet der Ebene1
777 pObj->NbcSetStyleSheet(pSheet, sal_False);
778
779 }
780 }
781 }
782
783 if( pPresPage->IsPresObj( pObj ) )
784 {
785 SfxItemSet* pNewSet = (SfxItemSet*) pAttrList->GetObject(j++);
786 SdrObjUserCall* pUserCall = (SdrObjUserCall*) pAttrList->GetObject(j++);
787
788 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SFX_ITEM_ON )
789 {
790 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT));
791 }
792
793 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SFX_ITEM_ON )
794 {
795 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT));
796 }
797
798 if( pUserCall )
799 pObj->SetUserCall( pUserCall );
800
801 delete pNewSet;
802 }
803 }
804
805 delete pAttrList;
806 }
807
808 delete pSet;
809 Cancel();
810 }
811 break;
812
813 case SID_DELETE_SNAPITEM:
814 {
815 SdrPageView* pPV;
816 Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos );
817 sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic( Size(
818 FuPoor::HITPIX, 0 ) ).Width();
819 sal_uInt16 nHelpLine;
820
821 mbMousePosFreezed = sal_False;
822
823 if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
824 {
825 pPV->DeleteHelpLine( nHelpLine );
826 }
827 Cancel();
828 rReq.Ignore ();
829 }
830 break;
831
832 case SID_DELETE_PAGE:
833 case SID_DELETE_MASTER_PAGE:
834 DeleteActualPage();
835 Cancel();
836 rReq.Ignore ();
837 break;
838
839 case SID_DELETE_LAYER:
840 DeleteActualLayer();
841 Cancel();
842 rReq.Ignore ();
843 break;
844
845 case SID_ORIGINAL_SIZE:
846 mpDrawView->SetMarkedOriginalSize();
847 Cancel();
848 rReq.Done();
849 break;
850
851 case SID_DRAW_FONTWORK:
852 case SID_DRAW_FONTWORK_VERTICAL:
853 {
854 svx::FontworkBar::execute( mpView, rReq, GetViewFrame()->GetBindings() ); // SJ: can be removed (I think)
855 Cancel();
856 rReq.Done();
857 }
858 break;
859
860 case SID_SAVEGRAPHIC:
861 {
862 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
863 if( rMarkList.GetMarkCount() == 1 )
864 {
865 SdrGrafObj *pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
866 if(pGrafObj )
867 {
868 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape( pGrafObj->getUnoShape(), com::sun::star::uno::UNO_QUERY );
869 SdGRFFilter::SaveGraphic( xShape );
870 }
871 }
872 Cancel();
873 rReq.Ignore();
874 }
875 break;
876
877 default:
878 {
879 // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
880 // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8)
881 // gewandert.
882 FuTemp01(rReq);
883 }
884 break;
885 }
886
887 if(HasCurrentFunction())
888 {
889 GetCurrentFunction()->Activate();
890 }
891 }
892
ExecChar(SfxRequest & rReq)893 void DrawViewShell::ExecChar( SfxRequest &rReq )
894 {
895 SdDrawDocument* pDoc = GetDoc();
896 if (!pDoc || !mpDrawView)
897 return;
898
899 SfxItemSet aEditAttr( pDoc->GetPool() );
900 mpDrawView->GetAttributes( aEditAttr );
901
902 //modified by wj for sym2_1580, if put old itemset into new set,
903 //when mpDrawView->SetAttributes(aNewAttr) it will invalidate all the item
904 // and use old attr to update all the attributes
905 // SfxItemSet aNewAttr( GetPool(),
906 // EE_ITEMS_START, EE_ITEMS_END );
907 // aNewAttr.Put( aEditAttr, sal_False );
908 SfxItemSet aNewAttr( pDoc->GetPool() );
909 //modified end
910
911 sal_uInt16 nSId = rReq.GetSlot();
912
913 MapSlot( nSId );
914
915 switch ( nSId )
916 {
917 case SID_ATTR_CHAR_FONT:
918 if( rReq.GetArgs() )
919 {
920 SFX_REQUEST_ARG( rReq, pItem, SvxFontItem, SID_ATTR_CHAR_FONT , sal_False );
921 if (pItem)
922 {
923 aNewAttr.Put(*pItem);
924 }
925 }
926 break;
927 case SID_ATTR_CHAR_FONTHEIGHT:
928 if( rReq.GetArgs() )
929 {
930 SFX_REQUEST_ARG( rReq, pItem, SvxFontHeightItem, SID_ATTR_CHAR_FONTHEIGHT , sal_False );
931 if (pItem)
932 {
933 aNewAttr.Put(*pItem);
934 }
935 }
936 break;
937 case SID_ATTR_CHAR_WEIGHT:
938 if( rReq.GetArgs() )
939 {
940 //const SvxWeightItem *pItem = (const SvxWeightItem*) rReq.GetArg( SID_ATTR_CHAR_WEIGHT, sal_False, TYPE(SvxWeightItem) );
941 SFX_REQUEST_ARG( rReq, pItem, SvxWeightItem, SID_ATTR_CHAR_WEIGHT , sal_False );
942 if (pItem)
943 {
944 aNewAttr.Put(*pItem);
945 }
946 }
947 break;
948 case SID_ATTR_CHAR_POSTURE:
949 if( rReq.GetArgs() )
950 {
951 //const SvxPostureItem *pItem = (const SvxPostureItem*) rReq.GetArg( SID_ATTR_CHAR_POSTURE, sal_False, TYPE(SvxPostureItem) );
952 SFX_REQUEST_ARG( rReq, pItem, SvxPostureItem, SID_ATTR_CHAR_POSTURE , sal_False );
953 if (pItem)
954 {
955 aNewAttr.Put(*pItem);
956 }
957 }
958 break;
959 case SID_ATTR_CHAR_UNDERLINE:
960 if( rReq.GetArgs() )
961 {
962 //<<modify by wj for sym2_1873
963 //SFX_REQUEST_ARG( rReq, pItem, SvxTextLineItem, SID_ATTR_CHAR_UNDERLINE , sal_False );
964 SFX_REQUEST_ARG( rReq, pItem, SvxUnderlineItem, SID_ATTR_CHAR_UNDERLINE , sal_False );
965 //end>>
966 if (pItem)
967 {
968 aNewAttr.Put(*pItem);
969 }
970 else
971 {
972 FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr.Get( EE_CHAR_UNDERLINE ) ).GetLineStyle();
973 aNewAttr.Put( SvxUnderlineItem( eFU != UNDERLINE_NONE ?UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE ) );
974 }//aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
975 }
976 break;
977 case SID_ATTR_CHAR_SHADOWED:
978 if( rReq.GetArgs() )
979 {
980 SFX_REQUEST_ARG( rReq, pItem, SvxShadowedItem, SID_ATTR_CHAR_SHADOWED , sal_False );
981 if (pItem)
982 {
983 aNewAttr.Put(*pItem);
984 }
985 }
986 break;
987 case SID_ATTR_CHAR_STRIKEOUT:
988 if( rReq.GetArgs() )
989 {
990 SFX_REQUEST_ARG( rReq, pItem, SvxCrossedOutItem, SID_ATTR_CHAR_STRIKEOUT , sal_False );
991 if (pItem)
992 {
993 aNewAttr.Put(*pItem);
994 }
995 }
996 break;
997 case SID_ATTR_CHAR_COLOR:
998 if( rReq.GetArgs() )
999 {
1000 SFX_REQUEST_ARG( rReq, pItem, SvxColorItem, SID_ATTR_CHAR_COLOR , sal_False );
1001 if (pItem)
1002 {
1003 aNewAttr.Put(*pItem);
1004 }
1005 }
1006 break;
1007 case SID_ATTR_CHAR_KERNING:
1008 if( rReq.GetArgs() )
1009 {
1010 SFX_REQUEST_ARG( rReq, pItem, SvxKerningItem, SID_ATTR_CHAR_KERNING , sal_False );
1011 if (pItem)
1012 {
1013 aNewAttr.Put(*pItem);
1014 }
1015 }
1016 break;
1017 case SID_SET_SUB_SCRIPT:
1018 if( rReq.GetArgs() )
1019 {
1020 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
1021 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
1022 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1023 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
1024 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
1025 else
1026 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
1027 aNewAttr.Put( aItem );
1028 }
1029 break;
1030 case SID_SET_SUPER_SCRIPT:
1031 if( rReq.GetArgs() )
1032 {
1033 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
1034 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
1035 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1036 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
1037 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
1038 else
1039 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
1040 aNewAttr.Put( aItem );
1041 }
1042 break;
1043 case SID_SHRINK_FONT_SIZE:
1044 case SID_GROW_FONT_SIZE:
1045 //if (rReq.GetArgs())
1046 {
1047 const SvxFontListItem* pFonts = dynamic_cast<const SvxFontListItem*>(GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
1048 const FontList* pFontList = pFonts->GetFontList();
1049 if( pFontList )
1050 {
1051 FuText::ChangeFontSize( nSId == SID_GROW_FONT_SIZE, NULL, pFontList, mpView );
1052 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
1053 }
1054 }
1055 default:
1056 ;
1057 }
1058
1059 mpDrawView->SetAttributes(aNewAttr);
1060 rReq.Done();
1061 Cancel();
1062 }
1063
1064
1065 /** This method consists basically of three parts:
1066 1. Process the arguments of the SFX request.
1067 2. Use the model to create a new page or duplicate an existing one.
1068 3. Update the tab control and switch to the new page.
1069 */
CreateOrDuplicatePage(SfxRequest & rRequest,PageKind ePageKind,SdPage * pPage,const sal_Int32 nInsertPosition)1070 SdPage* DrawViewShell::CreateOrDuplicatePage (
1071 SfxRequest& rRequest,
1072 PageKind ePageKind,
1073 SdPage* pPage,
1074 const sal_Int32 nInsertPosition)
1075 {
1076 SdPage* pNewPage = NULL;
1077 if (ePageKind == PK_STANDARD && meEditMode != EM_MASTERPAGE)
1078 {
1079 if ( mpDrawView->IsTextEdit() )
1080 {
1081 mpDrawView->SdrEndTextEdit();
1082 }
1083 pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition);
1084 }
1085 return pNewPage;
1086 }
1087
ExecutePropPanelAttr(SfxRequest & rReq)1088 void DrawViewShell::ExecutePropPanelAttr (SfxRequest& rReq)
1089 {
1090 if(SlideShow::IsRunning( GetViewShellBase() ))
1091 return;
1092
1093 SdDrawDocument* pDoc = GetDoc();
1094 if (!pDoc || !mpDrawView)
1095 return;
1096
1097 sal_uInt16 nSId = rReq.GetSlot();
1098 SfxItemSet aAttrs( pDoc->GetPool() );
1099
1100 switch ( nSId )
1101 {
1102 case SID_TABLE_VERT_NONE:
1103 case SID_TABLE_VERT_CENTER:
1104 case SID_TABLE_VERT_BOTTOM:
1105 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
1106 if (nSId == SID_TABLE_VERT_CENTER)
1107 eTVA = SDRTEXTVERTADJUST_CENTER;
1108 else if (nSId == SID_TABLE_VERT_BOTTOM)
1109 eTVA = SDRTEXTVERTADJUST_BOTTOM;
1110
1111 aAttrs.Put( SdrTextVertAdjustItem(eTVA) );
1112 mpDrawView->SetAttributes(aAttrs);
1113
1114 break;
1115 }
1116 }
1117
GetStatePropPanelAttr(SfxItemSet & rSet)1118 void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet)
1119 {
1120 SfxWhichIter aIter( rSet );
1121 sal_uInt16 nWhich = aIter.FirstWhich();
1122
1123 SdDrawDocument* pDoc = GetDoc();
1124 if (!pDoc || !mpDrawView)
1125 return;
1126
1127 SfxItemSet aAttrs( pDoc->GetPool() );
1128 mpDrawView->GetAttributes( aAttrs );
1129
1130 while ( nWhich )
1131 {
1132 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1133 ? GetPool().GetSlotId(nWhich)
1134 : nWhich;
1135 switch ( nSlotId )
1136 {
1137 case SID_TABLE_VERT_NONE:
1138 case SID_TABLE_VERT_CENTER:
1139 case SID_TABLE_VERT_BOTTOM:
1140 sal_Bool bContour = sal_False;
1141 SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1142 if( eConState != SFX_ITEM_DONTCARE )
1143 {
1144 bContour = ( ( const SdrTextContourFrameItem& )aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
1145 }
1146 if (bContour) break;
1147
1148 SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
1149 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1150
1151 //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
1152 if(SFX_ITEM_DONTCARE != eVState)
1153 {
1154 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
1155 sal_Bool bSet = nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP||
1156 nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER ||
1157 nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM;
1158 rSet.Put(SfxBoolItem(nSlotId, bSet));
1159 }
1160 else
1161 {
1162 rSet.Put(SfxBoolItem(nSlotId, sal_False));
1163 }
1164 break;
1165 }
1166 nWhich = aIter.NextWhich();
1167 }
1168 }
1169
1170 } // end of namespace sd
1171