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