xref: /AOO41X/main/sd/source/ui/view/drviews2.cxx (revision ff0525f24f03981d56b7579b645949f111420994)
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 <svx/svxdlg.hxx>
67 #include <svx/dialogs.hrc>
68 
69 #include <sfx2/viewfrm.hxx>
70 #include "sdgrffilter.hxx"
71 
72 #include "app.hrc"
73 #include "glob.hrc"
74 #include "helpids.h"
75 #include "sdattr.hxx"
76 #include "drawview.hxx"
77 #include "Window.hxx"
78 #include "drawdoc.hxx"
79 #include "DrawDocShell.hxx"
80 #include "sdpage.hxx"
81 #include "fuscale.hxx"
82 #include "sdresid.hxx"
83 #include "GraphicViewShell.hxx"
84 #include "unmodpg.hxx"
85 #include "slideshow.hxx"
86 #include "fuvect.hxx"
87 #include "stlpool.hxx"
88 
89 // #90356#
90 #include "optsitem.hxx"
91 #include "sdabstdlg.hxx"
92 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
93 #include <com/sun/star/drawing/XDrawPages.hpp>
94 
95 #include <strings.hrc>
96 
97 using namespace ::com::sun::star;
98 using namespace ::com::sun::star::uno;
99 
100 namespace sd {
101 
102 /*************************************************************************
103 |*
104 |* SfxRequests fuer temporaere Funktionen
105 |*
106 \************************************************************************/
107 
108 void DrawViewShell::FuTemporary(SfxRequest& rReq)
109 {
110     // Waehrend einer Native-Diashow wird nichts ausgefuehrt!
111     if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR))
112         return;
113 
114     DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" );
115     if( !mpDrawView )
116         return;
117 
118     CheckLineTo (rReq);
119 
120     DeactivateCurrentFunction();
121 
122     sal_uInt16 nSId = rReq.GetSlot();
123 
124     // Slot wird gemapped (ToolboxImages/-Slots)
125     MapSlot( nSId );
126 
127     switch ( nSId )
128     {
129         // Flaechen und Linien-Attribute:
130         // Sollten (wie StateMethode) eine eigene
131         // Execute-Methode besitzen
132         case SID_ATTR_FILL_STYLE:
133         case SID_ATTR_FILL_COLOR:
134         case SID_ATTR_FILL_GRADIENT:
135         case SID_ATTR_FILL_HATCH:
136         case SID_ATTR_FILL_BITMAP:
137         case SID_ATTR_FILL_SHADOW:
138         case SID_ATTR_FILL_TRANSPARENCE:
139         case SID_ATTR_FILL_FLOATTRANSPARENCE:
140 
141         case SID_ATTR_LINE_STYLE:
142         case SID_ATTR_LINE_DASH:
143         case SID_ATTR_LINE_WIDTH:
144         case SID_ATTR_LINE_COLOR:
145         case SID_ATTR_LINEEND_STYLE:
146         case SID_ATTR_LINE_START:
147         case SID_ATTR_LINE_END:
148         case SID_ATTR_LINE_TRANSPARENCE:
149         case SID_ATTR_LINE_JOINT:
150         case SID_ATTR_LINE_CAP:
151 
152         case SID_ATTR_TEXT_FITTOSIZE:
153         {
154             if( rReq.GetArgs() )
155             {
156                 sal_Bool bMergeUndo = sal_False;
157                 ::svl::IUndoManager* pUndoManager = GetDocSh()->GetUndoManager();
158 
159                 // Anpassungen Start/EndWidth #63083#
160                 if(nSId == SID_ATTR_LINE_WIDTH)
161                 {
162                     SdrObject* pObj = NULL;
163                     const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
164                     sal_uLong nCount = rMarkList.GetMarkCount();
165                     const sal_Int32 nNewLineWidth(((const XLineWidthItem&)rReq.GetArgs()->Get(XATTR_LINEWIDTH)).GetValue());
166                     const bool bUndo(mpDrawView->IsUndoEnabled());
167 
168                     for (sal_uLong i=0; i<nCount; i++)
169                     {
170                         SfxItemSet aAttr(GetDoc()->GetPool());
171                         pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
172                         aAttr.Put(pObj->GetMergedItemSet());
173 
174                         sal_Int32 nActLineWidth = ((const XLineWidthItem&)aAttr.Get(XATTR_LINEWIDTH)).GetValue();
175 
176                         if(nActLineWidth != nNewLineWidth)
177                         {
178                             sal_Bool bSetItemSet(sal_False);
179 
180                             // #86265# do this for SFX_ITEM_DEFAULT and for SFX_ITEM_SET
181                             if(SFX_ITEM_DONTCARE != aAttr.GetItemState(XATTR_LINESTARTWIDTH))
182                             {
183                                 sal_Int32 nValAct = ((const XLineStartWidthItem&)aAttr.Get(XATTR_LINESTARTWIDTH)).GetValue();
184                                 sal_Int32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
185                                 if(nValNew < 0)
186                                     nValNew = 0;
187                                 bSetItemSet = sal_True;
188                                 aAttr.Put(XLineStartWidthItem(nValNew));
189                             }
190 
191                             // #86265# do this for SFX_ITEM_DEFAULT and for SFX_ITEM_SET
192                             if(SFX_ITEM_DONTCARE != aAttr.GetItemState(XATTR_LINEENDWIDTH))
193                             {
194                                 sal_Int32 nValAct = ((const XLineEndWidthItem&)aAttr.Get(XATTR_LINEENDWIDTH)).GetValue();
195                                 sal_Int32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
196                                 if(nValNew < 0)
197                                     nValNew = 0;
198                                 bSetItemSet = sal_True;
199                                 aAttr.Put(XLineEndWidthItem(nValNew));
200                             }
201 
202                             if(bSetItemSet)
203                             {
204                                 if(bUndo)
205                                 {
206                                     if(!bMergeUndo)
207                                     {
208                                         pUndoManager->EnterListAction( String(), String() );
209                                         mpDrawView->BegUndo();
210                                         bMergeUndo = sal_True;
211                                     }
212 
213                                     mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
214                                 }
215 
216                                 pObj->SetMergedItemSet(aAttr);
217                             }
218                         }
219                     }
220 
221                     if(bMergeUndo)
222                     {
223                         mpDrawView->EndUndo();
224                     }
225                 }
226 
227                 if (nSId == SID_ATTR_FILL_SHADOW)
228                 {
229                     // Ggf. werden transparente Objekte wei?gefuellt
230                     SdrObject* pObj = NULL;
231                     const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
232                     sal_uLong nCount = rMarkList.GetMarkCount();
233                     const bool bUndo = mpDrawView->IsUndoEnabled();
234 
235                     for (sal_uLong i=0; i<nCount; i++)
236                     {
237                         SfxItemSet aAttr(GetDoc()->GetPool());
238                         pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
239 
240                         // #i25616#
241                         if(!pObj->ISA(SdrGrafObj))
242                         {
243                             aAttr.Put(pObj->GetMergedItemSet());
244 
245                             const XFillStyleItem& rFillStyle = (const XFillStyleItem&) aAttr.Get(XATTR_FILLSTYLE);
246                             const XLineStyleItem& rLineStyle = (const XLineStyleItem&) aAttr.Get(XATTR_LINESTYLE);
247 
248                             if(XFILL_NONE == rFillStyle.GetValue() && XLINE_NONE == rLineStyle.GetValue())
249                             {
250                                 if( bUndo )
251                                 {
252                                     // Vorlage hat keine Fuellung,
253                                     // daher hart attributieren: Fuellung setzen
254                                     if (!bMergeUndo)
255                                     {
256                                         bMergeUndo = sal_True;
257                                         pUndoManager->EnterListAction( String(), String() );
258                                         mpDrawView->BegUndo();
259                                     }
260 
261                                     mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
262                                 }
263 
264                                 aAttr.Put(XFillStyleItem(XFILL_SOLID));
265                                 aAttr.Put(XFillColorItem(String(), COL_WHITE));
266 
267                                 pObj->SetMergedItemSet(aAttr);
268                             }
269                         }
270                     }
271 
272                     if (bMergeUndo)
273                     {
274                         mpDrawView->EndUndo();
275                     }
276                 }
277 
278                 mpDrawView->SetAttributes(*rReq.GetArgs());
279 
280                 if (bMergeUndo)
281                 {
282                     pUndoManager->LeaveListAction();
283                 }
284 
285                 rReq.Done();
286             }
287             else
288             {
289                 switch( rReq.GetSlot() )
290                 {
291                     case SID_ATTR_FILL_SHADOW:
292                     case SID_ATTR_FILL_STYLE:
293                     case SID_ATTR_FILL_COLOR:
294                     case SID_ATTR_FILL_GRADIENT:
295                     case SID_ATTR_FILL_HATCH:
296                     case SID_ATTR_FILL_BITMAP:
297                     case SID_ATTR_FILL_TRANSPARENCE:
298                     case SID_ATTR_FILL_FLOATTRANSPARENCE:
299                         GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA, SFX_CALLMODE_ASYNCHRON );
300                         break;
301                     case SID_ATTR_LINE_STYLE:
302                     case SID_ATTR_LINE_DASH:
303                     case SID_ATTR_LINE_WIDTH:
304                     case SID_ATTR_LINE_COLOR:
305                     case SID_ATTR_LINE_TRANSPARENCE:
306                     case SID_ATTR_LINE_JOINT:
307                     case SID_ATTR_LINE_CAP:
308                         GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE, SFX_CALLMODE_ASYNCHRON );
309                         break;
310                     case SID_ATTR_TEXT_FITTOSIZE:
311                         GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG, SFX_CALLMODE_ASYNCHRON );
312                         break;
313                 }
314             }
315             Cancel();
316         }
317         break;
318 
319         case SID_HYPHENATION:
320         {
321             // const SfxPoolItem* pItem = rReq.GetArg( SID_HYPHENATION );
322             //  ^-- Soll so nicht benutzt werden (Defaults sind falsch) !
323             SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_HYPHENATION, sal_False);
324 
325             if( pItem )
326             {
327                 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
328                 sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
329                 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
330                 mpDrawView->SetAttributes( aSet );
331             }
332             else // nur zum Test
333             {
334                 DBG_ERROR(" Kein Wert fuer Silbentrennung!");
335                 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
336                 sal_Bool bValue = sal_True;
337                 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
338                 mpDrawView->SetAttributes( aSet );
339             }
340             rReq.Done();
341             Cancel();
342         }
343         break;
344 
345         case SID_INSERTPAGE:
346         case SID_INSERTPAGE_QUICK:
347         case SID_DUPLICATE_PAGE:
348         {
349             SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
350             Cancel();
351             if(HasCurrentFunction(SID_BEZIER_EDIT) )
352                 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
353             if (pNewPage != NULL)
354                 SwitchPage((pNewPage->GetPageNum()-1)/2);
355             rReq.Done ();
356         }
357         break;
358 
359         case SID_INSERT_MASTER_PAGE:
360         {
361             // Use the API to create a new page.
362             Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier (
363                 GetDoc()->getUnoModel(), UNO_QUERY);
364             if (xMasterPagesSupplier.is())
365             {
366                 Reference<drawing::XDrawPages> xMasterPages (
367                     xMasterPagesSupplier->getMasterPages());
368                 if (xMasterPages.is())
369                 {
370                     sal_uInt16 nIndex = GetCurPageId();
371                     xMasterPages->insertNewByIndex (nIndex);
372 
373                     // Create shapes for the default layout.
374                     SdPage* pMasterPage = GetDoc()->GetMasterSdPage(
375                         nIndex, PK_STANDARD);
376                     pMasterPage->CreateTitleAndLayout (sal_True,sal_True);
377                 }
378             }
379 
380             Cancel();
381             if(HasCurrentFunction(SID_BEZIER_EDIT))
382                 GetViewFrame()->GetDispatcher()->Execute(
383                     SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
384             rReq.Done ();
385         }
386         break;
387 
388         case SID_MODIFYPAGE:
389         {
390             if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES ||
391                 (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE) )
392             {
393                 if ( mpDrawView->IsTextEdit() )
394                 {
395                     mpDrawView->SdrEndTextEdit();
396                 }
397                 sal_uInt16 nPage = maTabControl.GetCurPageId() - 1;
398                 mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind);
399                 ::sd::ViewShell::mpImpl->ProcessModifyPageSlot (
400                     rReq,
401                     mpActualPage,
402                     mePageKind);
403             }
404 
405             Cancel();
406             rReq.Done ();
407         }
408         break;
409 
410         case SID_ASSIGN_LAYOUT:
411         {
412             if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES || (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE))
413             {
414                 if ( mpDrawView->IsTextEdit() )
415                     mpDrawView->SdrEndTextEdit();
416 
417                 ::sd::ViewShell::mpImpl->AssignLayout(rReq, mePageKind);
418             }
419             Cancel();
420             rReq.Done ();
421         }
422         break;
423 
424         case SID_RENAMEPAGE:
425         case SID_RENAME_MASTER_PAGE:
426         {
427             if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
428             {
429                 if ( mpDrawView->IsTextEdit() )
430                 {
431                     mpDrawView->SdrEndTextEdit();
432                 }
433 
434                 sal_uInt16 nPageId = maTabControl.GetCurPageId();
435                 SdPage* pCurrentPage = ( GetEditMode() == EM_PAGE )
436                     ? GetDoc()->GetSdPage( nPageId - 1, GetPageKind() )
437                     : GetDoc()->GetMasterSdPage( nPageId - 1, GetPageKind() );
438 
439                 String aTitle( SdResId( STR_TITLE_RENAMESLIDE ) );
440                 String aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
441                 String aPageName = pCurrentPage->GetName();
442 
443                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
444                 DBG_ASSERT(pFact, "Dialogdiet fail!");
445                 AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( GetActiveWindow(), aPageName, aDescr );
446                 DBG_ASSERT(aNameDlg, "Dialogdiet fail!");
447                 aNameDlg->SetText( aTitle );
448                 aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl ), true );
449                 aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
450 
451                 if( aNameDlg->Execute() == RET_OK )
452                 {
453                     String aNewName;
454                     aNameDlg->GetName( aNewName );
455                     if( ! aNewName.Equals( aPageName ) )
456                     {
457 #ifdef DBG_UTIL
458                         bool bResult =
459 #endif
460                             RenameSlide( nPageId, aNewName );
461                         DBG_ASSERT( bResult, "Couldn't rename slide" );
462                     }
463                 }
464                 delete aNameDlg;
465             }
466 
467             Cancel();
468             rReq.Ignore ();
469         }
470         break;
471 
472         case SID_RENAMEPAGE_QUICK:
473         {
474             if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
475             {
476                 if ( mpDrawView->IsTextEdit() )
477                 {
478                     mpDrawView->SdrEndTextEdit();
479                 }
480 
481                 maTabControl.StartEditMode( maTabControl.GetCurPageId() );
482             }
483 
484             Cancel();
485             rReq.Ignore ();
486         }
487         break;
488 
489         case SID_PAGESIZE :  // entweder dieses (kein menueeintrag o. ae. !!)
490         {
491             const SfxItemSet *pArgs = rReq.GetArgs ();
492 
493             if (pArgs)
494                 if (pArgs->Count () == 3)
495                 {
496                     SFX_REQUEST_ARG (rReq, pWidth, SfxUInt32Item, ID_VAL_PAGEWIDTH, sal_False);
497                     SFX_REQUEST_ARG (rReq, pHeight, SfxUInt32Item, ID_VAL_PAGEHEIGHT, sal_False);
498                     SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, sal_False);
499 
500                     Size aSize (pWidth->GetValue (), pHeight->GetValue ());
501 
502                     SetupPage (aSize, 0, 0, 0, 0, sal_True, sal_False, pScaleAll->GetValue ());
503                     rReq.Ignore ();
504                     break;
505                 }
506 
507             StarBASIC::FatalError (SbERR_WRONG_ARGS);
508             rReq.Ignore ();
509             break;
510         }
511 
512         case SID_PAGEMARGIN :  // oder dieses (kein menueeintrag o. ae. !!)
513         {
514             const SfxItemSet *pArgs = rReq.GetArgs ();
515 
516             if (pArgs)
517                 if (pArgs->Count () == 5)
518                 {
519                     SFX_REQUEST_ARG (rReq, pLeft, SfxUInt32Item, ID_VAL_PAGELEFT, sal_False);
520                     SFX_REQUEST_ARG (rReq, pRight, SfxUInt32Item, ID_VAL_PAGERIGHT, sal_False);
521                     SFX_REQUEST_ARG (rReq, pUpper, SfxUInt32Item, ID_VAL_PAGETOP, sal_False);
522                     SFX_REQUEST_ARG (rReq, pLower, SfxUInt32Item, ID_VAL_PAGEBOTTOM, sal_False);
523                     SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, sal_False);
524 
525                     Size aEmptySize (0, 0);
526 
527                     SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (),
528                                pUpper->GetValue (), pLower->GetValue (),
529                                sal_False, sal_True, pScaleAll->GetValue ());
530                     rReq.Ignore ();
531                     break;
532                 }
533 
534             StarBASIC::FatalError (SbERR_WRONG_ARGS);
535             rReq.Ignore ();
536             break;
537         }
538 
539         case SID_ATTR_ZOOMSLIDER:
540         {
541             const SfxItemSet* pArgs = rReq.GetArgs();
542 
543             if (pArgs && pArgs->Count () == 1 )
544             {
545                 SFX_REQUEST_ARG (rReq, pScale, SfxUInt16Item, SID_ATTR_ZOOMSLIDER, sal_False);
546                 if (CHECK_RANGE (5, pScale->GetValue (), 3000))
547                 {
548                     SetZoom (pScale->GetValue ());
549 
550                     SfxBindings& rBindings = GetViewFrame()->GetBindings();
551                     rBindings.Invalidate( SID_ATTR_ZOOM );
552                     rBindings.Invalidate( SID_ZOOM_IN );
553                     rBindings.Invalidate( SID_ZOOM_OUT );
554                     rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
555 
556                 }
557             }
558 
559             Cancel();
560             rReq.Done ();
561             break;
562         }
563         case SID_ZOOMING :  // kein Menueintrag, sondern aus dem Zoomdialog generiert
564         {
565             const SfxItemSet* pArgs = rReq.GetArgs();
566 
567             if (pArgs)
568                 if (pArgs->Count () == 1)
569                 {
570                     SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, sal_False);
571                     if (CHECK_RANGE (10, pScale->GetValue (), 1000))
572                     {
573                         SetZoom (pScale->GetValue ());
574 
575                         SfxBindings& rBindings = GetViewFrame()->GetBindings();
576                         rBindings.Invalidate( SID_ATTR_ZOOM );
577                         rBindings.Invalidate( SID_ZOOM_IN );
578                         rBindings.Invalidate( SID_ZOOM_OUT );
579                         rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
580                     }
581                     else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
582 
583                     rReq.Ignore ();
584                     break;
585                 }
586 
587             StarBASIC::FatalError (SbERR_WRONG_ARGS);
588             rReq.Ignore ();
589             break;
590         }
591 
592         case SID_ATTR_ZOOM:
593         {
594             const SfxItemSet* pArgs = rReq.GetArgs();
595             mbZoomOnPage = sal_False;
596 
597             if ( pArgs )
598             {
599                 SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs->
600                                             Get( SID_ATTR_ZOOM ) ).GetType();
601                 switch( eZT )
602                 {
603                     case SVX_ZOOM_PERCENT:
604                         SetZoom( (long) ( ( const SvxZoomItem& ) pArgs->
605                                             Get( SID_ATTR_ZOOM ) ).GetValue() );
606                         break;
607 
608                     case SVX_ZOOM_OPTIMAL:
609                         GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL,
610                                     SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
611                         break;
612 
613                     case SVX_ZOOM_PAGEWIDTH:
614                         GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH,
615                                     SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
616                         break;
617 
618                     case SVX_ZOOM_WHOLEPAGE:
619                         GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE,
620                                     SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
621                         break;
622                     case SVX_ZOOM_PAGEWIDTH_NOBORDER:
623                         DBG_ERROR("sd::DrawViewShell::FuTemporary(), SVX_ZOOM_PAGEWIDTH_NOBORDER not handled!" );
624                         break;
625                 }
626                 rReq.Ignore ();
627             }
628             else
629             {
630                 // hier den Zoom-Dialog oeffnen
631                 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
632             }
633             Cancel();
634         }
635         break;
636 
637         case SID_CHANGEBEZIER:
638         case SID_CHANGEPOLYGON:
639             if ( mpDrawView->IsTextEdit() )
640             {
641                 mpDrawView->SdrEndTextEdit();
642                 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
643             }
644 
645             if ( mpDrawView->IsPresObjSelected() )
646             {
647                 ::sd::Window* pWindow = GetActiveWindow();
648                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
649             }
650             else
651             {
652                 if( rReq.GetSlot() == SID_CHANGEBEZIER )
653                 {
654                     WaitObject aWait( (Window*)GetActiveWindow() );
655                     mpDrawView->ConvertMarkedToPathObj(sal_False);
656                 }
657                 else
658                 {
659                     if( mpDrawView->IsVectorizeAllowed() )
660                     {
661                         SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
662                     }
663                     else
664                     {
665                         WaitObject aWait( (Window*)GetActiveWindow() );
666                         mpDrawView->ConvertMarkedToPolyObj(sal_False);
667                     }
668                 }
669 
670                 Invalidate(SID_CHANGEBEZIER);
671                 Invalidate(SID_CHANGEPOLYGON);
672             }
673             Cancel();
674 
675             if( HasCurrentFunction(SID_BEZIER_EDIT) )
676             {   // ggf. die richtige Editfunktion aktivieren
677                 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT,
678                                         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
679             }
680             rReq.Ignore ();
681             break;
682 
683         case SID_CONVERT_TO_CONTOUR:
684             if ( mpDrawView->IsTextEdit() )
685             {
686                 mpDrawView->SdrEndTextEdit();
687                 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
688             }
689 
690             if ( mpDrawView->IsPresObjSelected() )
691             {
692                 ::sd::Window* pWindow = GetActiveWindow();
693                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
694             }
695             else
696             {
697                 WaitObject aWait( (Window*)GetActiveWindow() );
698                 mpDrawView->ConvertMarkedToPathObj(sal_True);
699 
700                 Invalidate(SID_CONVERT_TO_CONTOUR);
701             }
702             Cancel();
703 
704             rReq.Ignore ();
705             break;
706 
707         case SID_CONVERT_TO_METAFILE:
708         case SID_CONVERT_TO_BITMAP:
709         {
710             // End text edit mode when it is active because the metafile or
711             // bitmap that will be created does not support it.
712             if ( mpDrawView->IsTextEdit() )
713             {
714                 mpDrawView->SdrEndTextEdit();
715                 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
716             }
717 
718             if ( mpDrawView->IsPresObjSelected(true,true,true) )
719             {
720                 ::sd::Window* pWindow = GetActiveWindow();
721                 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
722             }
723             else
724             {
725                 WaitObject aWait( (Window*)GetActiveWindow() );
726 
727                 // switch on undo for the next operations
728                 mpDrawView->BegUndo(
729                     String(
730                     SdResId (nSId==SID_CONVERT_TO_METAFILE ? STR_UNDO_CONVERT_TO_METAFILE : STR_UNDO_CONVERT_TO_BITMAP)));
731 
732                 // create SdrGrafObj from metafile/bitmap
733                 Graphic aGraphic;
734                 switch (nSId)
735                 {
736                     case SID_CONVERT_TO_METAFILE:
737                     {
738                         GDIMetaFile aMetaFile(mpDrawView->GetMarkedObjMetaFile());
739                         aGraphic = Graphic(aMetaFile);
740                     }
741                     break;
742                     case SID_CONVERT_TO_BITMAP:
743                     {
744                         bool bDone(false);
745 
746                         // I have to get the image here directly since GetMarkedObjBitmapEx works
747                         // based on Bitmaps, but not on BitmapEx, thus throwing away the alpha
748                         // channel. Argh! GetMarkedObjBitmapEx itself is too widely used to safely
749                         // change that, e.g. in the exchange formats. For now I can only add this
750                         // exception to get good results for Svgs. This is how the code gets more
751                         // and more crowded, at last I made a remark for myself to change this
752                         // as one of the next tasks.
753                         if(1 == mpDrawView->GetMarkedObjectCount())
754                         {
755                             const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(mpDrawView->GetMarkedObjectByIndex(0));
756 
757                             if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg())
758                             {
759                                 aGraphic = Graphic(pSdrGrafObj->GetGraphic().getSvgData()->getReplacement());
760                                 bDone = true;
761                             }
762                         }
763 
764                         if(!bDone)
765                         {
766                             aGraphic = Graphic(mpDrawView->GetMarkedObjBitmapEx());
767                         }
768                     }
769                     break;
770                 }
771 
772                 // create new object
773                 SdrGrafObj* pGraphicObj = new SdrGrafObj (aGraphic);
774 
775                 // get some necessary info and ensure it
776                 const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
777                 const sal_uInt32 nMarkCount(rMarkList.GetMarkCount());
778                 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
779                 OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)");
780                 OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)");
781 
782                 // fit rectangle of new graphic object to selection's mark rect
783                 Rectangle aAllMarkedRect;
784                 rMarkList.TakeBoundRect(pPageView, aAllMarkedRect);
785                 pGraphicObj->SetLogicRect(aAllMarkedRect);
786 
787                 // #i71540# to keep the order, it is necessary to replace the lowest object
788                 // of the selection with the new object. This also means that with multi
789                 // selection, all other objects need to be deleted first
790                 SdrMark* pFirstMark = rMarkList.GetMark(0L);
791                 SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj();
792 
793                 if(nMarkCount > 1L)
794                 {
795                     // take first object out of selection
796                     mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true);
797 
798                     // clear remaining selection
799                     mpDrawView->DeleteMarkedObj();
800                 }
801 
802                 // now replace lowest object with new one
803                 mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj);
804 
805                 // switch off undo
806                 mpDrawView->EndUndo();
807             }
808         }
809 
810         Cancel();
811 
812         rReq.Done ();
813         break;
814 
815         case SID_SET_DEFAULT:
816         {
817             SfxItemSet* pSet = NULL;
818 
819             if (mpDrawView->IsTextEdit())
820             {
821                 ::Outliner* pOutl = mpDrawView->GetTextEditOutliner();
822                 if (pOutl)
823                 {
824                     pOutl->RemoveFields(sal_True, (TypeId) SvxURLField::StaticType());
825                 }
826 
827                 pSet = new SfxItemSet( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
828                 mpDrawView->SetAttributes( *pSet, sal_True );
829             }
830             else
831             {
832                 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
833                 sal_uLong nCount = rMarkList.GetMarkCount();
834 
835                 // In diese Liste werden fuer jedes Praesentationsobjekt ein SfxItemSet
836                 // der harten Attribute sowie der UserCall eingetragen, da diese beim nachfolgenden
837                 // mpDrawView->SetAttributes( *pSet, sal_True ) verloren gehen und spaeter restauriert
838                 // werden muessen
839                 List* pAttrList = new List();
840                 SdPage* pPresPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
841                 sal_uLong i;
842 
843                 for ( i = 0; i < nCount; i++ )
844                 {
845                     SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
846 
847                     if( pPresPage->IsPresObj( pObj ) )
848                     {
849                         SfxItemSet* pNewSet = new SfxItemSet( GetDoc()->GetPool(), SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 0 );
850                         pNewSet->Put(pObj->GetMergedItemSet());
851                         pAttrList->Insert( pNewSet, LIST_APPEND );
852                         pAttrList->Insert( pObj->GetUserCall(), LIST_APPEND );
853                     }
854                 }
855 
856                 pSet = new SfxItemSet( GetPool() );
857                 mpDrawView->SetAttributes( *pSet, sal_True );
858 
859                 sal_uLong j = 0;
860 
861                 for ( i = 0; i < nCount; i++ )
862                 {
863                     SfxStyleSheet* pSheet = NULL;
864                     SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
865 
866                     if (pObj->GetObjIdentifier() == OBJ_TITLETEXT)
867                     {
868                         pSheet = mpActualPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
869                         if (pSheet)
870                             pObj->SetStyleSheet(pSheet, sal_False);
871                     }
872                     else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
873                     {
874                         for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
875                         {
876                             pSheet = mpActualPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
877                             DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
878                             if (pSheet)
879                             {
880                                 pObj->StartListening(*pSheet);
881 
882                                 if( nLevel == 1 )
883                                     // Textrahmen hoert auf StyleSheet der Ebene1
884                                     pObj->NbcSetStyleSheet(pSheet, sal_False);
885 
886                             }
887                         }
888                     }
889 
890                     if( pPresPage->IsPresObj( pObj ) )
891                     {
892                         SfxItemSet* pNewSet = (SfxItemSet*) pAttrList->GetObject(j++);
893                         SdrObjUserCall* pUserCall = (SdrObjUserCall*) pAttrList->GetObject(j++);
894 
895                         if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SFX_ITEM_ON )
896                         {
897                             pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT));
898                         }
899 
900                         if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SFX_ITEM_ON )
901                         {
902                             pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT));
903                         }
904 
905                         if( pUserCall )
906                             pObj->SetUserCall( pUserCall );
907 
908                         delete pNewSet;
909                     }
910                 }
911 
912                 delete pAttrList;
913             }
914 
915             delete pSet;
916             Cancel();
917         }
918         break;
919 
920         case SID_DELETE_SNAPITEM:
921         {
922             SdrPageView* pPV;
923             Point   aMPos = GetActiveWindow()->PixelToLogic( maMousePos );
924             sal_uInt16  nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic( Size(
925                 FuPoor::HITPIX, 0 ) ).Width();
926             sal_uInt16  nHelpLine;
927 
928             mbMousePosFreezed = sal_False;
929 
930             if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
931             {
932                 pPV->DeleteHelpLine( nHelpLine );
933             }
934             Cancel();
935             rReq.Ignore ();
936         }
937         break;
938 
939         case SID_DELETE_PAGE:
940         case SID_DELETE_MASTER_PAGE:
941             DeleteActualPage();
942             Cancel();
943             rReq.Ignore ();
944         break;
945 
946         case SID_DELETE_LAYER:
947             DeleteActualLayer();
948             Cancel();
949             rReq.Ignore ();
950         break;
951 
952         case SID_ORIGINAL_SIZE:
953             mpDrawView->SetMarkedOriginalSize();
954             Cancel();
955             rReq.Done();
956         break;
957 
958         case SID_DRAW_FONTWORK:
959         case SID_DRAW_FONTWORK_VERTICAL:
960         {
961             svx::FontworkBar::execute( mpView, rReq, GetViewFrame()->GetBindings() );       // SJ: can be removed  (I think)
962             Cancel();
963             rReq.Done();
964         }
965         break;
966 
967         case SID_SAVEGRAPHIC:
968         {
969             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
970             if( rMarkList.GetMarkCount() == 1 )
971             {
972                 SdrGrafObj *pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
973                 if(pGrafObj )
974                 {
975                     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape( pGrafObj->getUnoShape(), com::sun::star::uno::UNO_QUERY );
976                     SdGRFFilter::SaveGraphic( xShape );
977                 }
978             }
979             Cancel();
980             rReq.Ignore();
981         }
982         break;
983 
984         default:
985         {
986             // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
987             // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8)
988             // gewandert.
989             FuTemp01(rReq);
990         }
991         break;
992     }
993 
994     if(HasCurrentFunction())
995     {
996         GetCurrentFunction()->Activate();
997     }
998 }
999 
1000 
1001 
1002 
1003 /** This method consists basically of three parts:
1004     1. Process the arguments of the SFX request.
1005     2. Use the model to create a new page or duplicate an existing one.
1006     3. Update the tab control and switch to the new page.
1007 */
1008 SdPage* DrawViewShell::CreateOrDuplicatePage (
1009     SfxRequest& rRequest,
1010     PageKind ePageKind,
1011     SdPage* pPage,
1012     const sal_Int32 nInsertPosition)
1013 {
1014     SdPage* pNewPage = NULL;
1015     if (ePageKind == PK_STANDARD && meEditMode != EM_MASTERPAGE)
1016     {
1017         if ( mpDrawView->IsTextEdit() )
1018         {
1019             mpDrawView->SdrEndTextEdit();
1020         }
1021         pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition);
1022     }
1023     return pNewPage;
1024 }
1025 
1026 } // end of namespace sd
1027