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