merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / view / drviews2.cxx
blob86c47746a0e2891225919cea72e4da08c0bc1c2e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviews2.cxx,v $
10 * $Revision: 1.55.68.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawViewShell.hxx"
35 #include "ViewShellImplementation.hxx"
36 #include <vcl/waitobj.hxx>
37 #include <svx/svdograf.hxx>
38 #ifndef _SVXIDS_HRC
39 #include <svx/svxids.hrc>
40 #endif
41 #include <svx/svdpagv.hxx>
42 #include <svx/svdundo.hxx>
43 #ifndef _ZOOMITEM_HXX
44 #include <svx/zoomitem.hxx>
45 #endif
46 #ifndef _EDITDATA_HXX
47 #include <svx/editdata.hxx>
48 #endif
49 #include <basic/sberrors.hxx>
50 #include <vcl/msgbox.hxx>
51 #include <sfx2/request.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <svx/xfillit0.hxx>
54 #include <svx/xflclit.hxx>
55 #include <svtools/aeitem.hxx>
56 #include <svx/eeitem.hxx>
57 #include <basic/sbstar.hxx>
58 #include <svx/flditem.hxx>
59 #include <svx/xlineit0.hxx>
60 #include <svx/xfillit0.hxx>
61 #include <svx/svdoole2.hxx>
63 #ifndef _SDOUTL_HXX //autogen
64 #include <svx/svdoutl.hxx>
65 #endif
66 #include <svx/xlnwtit.hxx>
67 #include <svx/svdoattr.hxx>
68 #include <svx/xlnstwit.hxx>
69 #include <svx/sdtmfitm.hxx>
70 #include <svx/sdtagitm.hxx>
71 #include <svx/xlnedwit.hxx>
72 #include <svx/fontworkbar.hxx>
74 #include <svx/svxdlg.hxx>
75 #include <svx/dialogs.hrc>
77 #include <sfx2/viewfrm.hxx>
78 #include "sdgrffilter.hxx"
80 #include "app.hrc"
81 #include "glob.hrc"
82 #include "helpids.h"
83 #include "sdattr.hxx"
84 #include "drawview.hxx"
85 #include "Window.hxx"
86 #include "drawdoc.hxx"
87 #include "DrawDocShell.hxx"
88 #include "sdpage.hxx"
89 #include "fuscale.hxx"
90 #include "sdresid.hxx"
91 #include "GraphicViewShell.hxx"
92 #include "unmodpg.hxx"
93 #include "slideshow.hxx"
94 #include "fuvect.hxx"
95 #include "stlpool.hxx"
97 // #90356#
98 #include "optsitem.hxx"
99 #include "sdabstdlg.hxx"
100 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
101 #include <com/sun/star/drawing/XDrawPages.hpp>
102 #include <com/sun/star/embed/EmbedVerbs.hpp>
104 #include <strings.hrc>
106 using namespace ::com::sun::star;
107 using namespace ::com::sun::star::uno;
109 namespace sd {
111 /*************************************************************************
113 |* modal dialog for #90356#
115 \************************************************************************/
117 class ImpUndoDeleteWarning : public ModalDialog
119 private:
120 FixedImage maImage;
121 FixedText maWarningFT;
122 CheckBox maDisableCB;
123 OKButton maYesBtn;
124 CancelButton maNoBtn;
126 public:
127 ImpUndoDeleteWarning(Window* pParent);
128 BOOL IsWarningDisabled() const { return maDisableCB.IsChecked(); }
131 ImpUndoDeleteWarning::ImpUndoDeleteWarning(Window* pParent)
132 : ModalDialog(pParent, SdResId(RID_UNDO_DELETE_WARNING)),
133 maImage(this, SdResId(IMG_UNDO_DELETE_WARNING)),
134 maWarningFT(this, SdResId(FT_UNDO_DELETE_WARNING)),
135 maDisableCB(this, SdResId(CB_UNDO_DELETE_DISABLE)),
136 maYesBtn(this, SdResId(BTN_UNDO_DELETE_YES)),
137 maNoBtn(this, SdResId(BTN_UNDO_DELETE_NO))
139 FreeResource();
141 SetHelpId( HID_SD_UNDODELETEWARNING_DLG );
142 maDisableCB.SetHelpId( HID_SD_UNDODELETEWARNING_CBX );
144 maYesBtn.SetText(Button::GetStandardText(BUTTON_YES));
145 maNoBtn.SetText(Button::GetStandardText(BUTTON_NO));
146 maImage.SetImage(WarningBox::GetStandardImage());
148 // #93721# Set focus to YES-Button
149 maYesBtn.GrabFocus();
153 /*************************************************************************
155 |* SfxRequests fuer temporaere Funktionen
157 \************************************************************************/
159 void DrawViewShell::FuTemporary(SfxRequest& rReq)
161 // Waehrend einer Native-Diashow wird nichts ausgefuehrt!
162 if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR))
163 return;
165 DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" );
166 if( !mpDrawView )
167 return;
169 CheckLineTo (rReq);
171 DeactivateCurrentFunction();
173 USHORT nSId = rReq.GetSlot();
175 // Slot wird gemapped (ToolboxImages/-Slots)
176 MapSlot( nSId );
178 switch ( nSId )
180 case SID_OUTLINE_TEXT_AUTOFIT:
182 SfxUndoManager* pUndoManager = GetDocSh()->GetUndoManager();
183 SdrObject* pObj = NULL;
184 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
185 if( rMarkList.GetMarkCount() == 1 )
187 pUndoManager->EnterListAction( String(), String() );
188 mpDrawView->BegUndo();
190 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
191 bool bSet = ((const SdrTextFitToSizeTypeItem*)pObj->GetMergedItemSet().GetItem(SDRATTR_TEXT_FITTOSIZE))->GetValue() != SDRTEXTFIT_NONE;
193 mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
195 pObj->SetMergedItem(SdrTextFitToSizeTypeItem(bSet ? SDRTEXTFIT_NONE : SDRTEXTFIT_AUTOFIT));
197 mpDrawView->EndUndo();
198 pUndoManager->LeaveListAction();
200 Cancel();
201 rReq.Done();
203 break;
205 // Flaechen und Linien-Attribute:
206 // Sollten (wie StateMethode) eine eigene
207 // Execute-Methode besitzen
208 case SID_ATTR_FILL_STYLE:
209 case SID_ATTR_FILL_COLOR:
210 case SID_ATTR_FILL_GRADIENT:
211 case SID_ATTR_FILL_HATCH:
212 case SID_ATTR_FILL_BITMAP:
213 case SID_ATTR_FILL_SHADOW:
215 case SID_ATTR_LINE_STYLE:
216 case SID_ATTR_LINE_DASH:
217 case SID_ATTR_LINE_WIDTH:
218 case SID_ATTR_LINE_COLOR:
219 case SID_ATTR_LINEEND_STYLE:
221 case SID_ATTR_TEXT_FITTOSIZE:
223 if( rReq.GetArgs() )
225 BOOL bMergeUndo = FALSE;
226 SfxUndoManager* pUndoManager = GetDocSh()->GetUndoManager();
228 // Anpassungen Start/EndWidth #63083#
229 if(nSId == SID_ATTR_LINE_WIDTH)
231 SdrObject* pObj = NULL;
232 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
233 ULONG nCount = rMarkList.GetMarkCount();
235 INT32 nNewLineWidth = ((const XLineWidthItem&)rReq.GetArgs()->Get(XATTR_LINEWIDTH)).GetValue();
237 for (ULONG i=0; i<nCount; i++)
239 SfxItemSet aAttr(GetDoc()->GetPool());
240 pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
241 aAttr.Put(pObj->GetMergedItemSet());
243 INT32 nActLineWidth = ((const XLineWidthItem&)aAttr.Get(XATTR_LINEWIDTH)).GetValue();
245 if(nActLineWidth != nNewLineWidth)
247 BOOL bSetItemSet(FALSE);
249 // #86265# do this for SFX_ITEM_DEFAULT and for SFX_ITEM_SET
250 if(SFX_ITEM_DONTCARE != aAttr.GetItemState(XATTR_LINESTARTWIDTH))
252 INT32 nValAct = ((const XLineStartWidthItem&)aAttr.Get(XATTR_LINESTARTWIDTH)).GetValue();
253 INT32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
254 if(nValNew < 0)
255 nValNew = 0;
256 bSetItemSet = TRUE;
257 aAttr.Put(XLineStartWidthItem(nValNew));
260 // #86265# do this for SFX_ITEM_DEFAULT and for SFX_ITEM_SET
261 if(SFX_ITEM_DONTCARE != aAttr.GetItemState(XATTR_LINEENDWIDTH))
263 INT32 nValAct = ((const XLineEndWidthItem&)aAttr.Get(XATTR_LINEENDWIDTH)).GetValue();
264 INT32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
265 if(nValNew < 0)
266 nValNew = 0;
267 bSetItemSet = TRUE;
268 aAttr.Put(XLineEndWidthItem(nValNew));
271 if(bSetItemSet)
272 pObj->SetMergedItemSet(aAttr);
277 if (nSId == SID_ATTR_FILL_SHADOW)
279 // Ggf. werden transparente Objekte wei?gefuellt
280 SdrObject* pObj = NULL;
281 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
282 ULONG nCount = rMarkList.GetMarkCount();
284 const bool bUndo = mpDrawView->IsUndoEnabled();
286 for (ULONG i=0; i<nCount; i++)
288 SfxItemSet aAttr(GetDoc()->GetPool());
289 pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
291 // #i25616#
292 if(!pObj->ISA(SdrGrafObj))
294 aAttr.Put(pObj->GetMergedItemSet());
296 const XFillStyleItem& rFillStyle =
297 (const XFillStyleItem&) aAttr.Get(XATTR_FILLSTYLE);
299 if (rFillStyle.GetValue() == XFILL_NONE)
301 if( bUndo )
303 // Vorlage hat keine Fuellung,
304 // daher hart attributieren: Fuellung setzen
305 if (!bMergeUndo)
307 bMergeUndo = TRUE;
308 pUndoManager->EnterListAction( String(), String() );
309 mpDrawView->BegUndo();
312 mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
315 aAttr.Put(XFillStyleItem(XFILL_SOLID));
316 aAttr.Put(XFillColorItem(String(), COL_WHITE));
318 pObj->SetMergedItemSet(aAttr);
323 if (bMergeUndo)
325 mpDrawView->EndUndo();
329 mpDrawView->SetAttributes(*rReq.GetArgs());
331 if (bMergeUndo)
333 pUndoManager->LeaveListAction();
336 rReq.Done();
338 else
340 switch( rReq.GetSlot() )
342 case SID_ATTR_FILL_SHADOW:
343 case SID_ATTR_FILL_STYLE:
344 case SID_ATTR_FILL_COLOR:
345 case SID_ATTR_FILL_GRADIENT:
346 case SID_ATTR_FILL_HATCH:
347 case SID_ATTR_FILL_BITMAP:
348 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA, SFX_CALLMODE_ASYNCHRON );
349 break;
350 case SID_ATTR_LINE_STYLE:
351 case SID_ATTR_LINE_DASH:
352 case SID_ATTR_LINE_WIDTH:
353 case SID_ATTR_LINE_COLOR:
354 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE, SFX_CALLMODE_ASYNCHRON );
355 break;
356 case SID_ATTR_TEXT_FITTOSIZE:
357 GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG, SFX_CALLMODE_ASYNCHRON );
358 break;
361 Cancel();
363 break;
365 case SID_HYPHENATION:
367 // const SfxPoolItem* pItem = rReq.GetArg( SID_HYPHENATION );
368 // ^-- Soll so nicht benutzt werden (Defaults sind falsch) !
369 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_HYPHENATION, FALSE);
371 if( pItem )
373 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
374 BOOL bValue = ( (const SfxBoolItem*) pItem)->GetValue();
375 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
376 mpDrawView->SetAttributes( aSet );
378 else // nur zum Test
380 DBG_ERROR(" Kein Wert fuer Silbentrennung!");
381 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
382 BOOL bValue = TRUE;
383 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
384 mpDrawView->SetAttributes( aSet );
386 rReq.Done();
387 Cancel();
389 break;
391 case SID_INSERTPAGE:
392 case SID_INSERTPAGE_QUICK:
393 case SID_DUPLICATE_PAGE:
395 SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
396 Cancel();
397 if(HasCurrentFunction(SID_BEZIER_EDIT) )
398 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
399 if (pNewPage != NULL)
400 SwitchPage((pNewPage->GetPageNum()-1)/2);
401 rReq.Done ();
403 break;
405 case SID_INSERT_MASTER_PAGE:
407 // Use the API to create a new page.
408 Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier (
409 GetDoc()->getUnoModel(), UNO_QUERY);
410 if (xMasterPagesSupplier.is())
412 Reference<drawing::XDrawPages> xMasterPages (
413 xMasterPagesSupplier->getMasterPages());
414 if (xMasterPages.is())
416 USHORT nIndex = GetCurPageId();
417 xMasterPages->insertNewByIndex (nIndex);
419 // Create shapes for the default layout.
420 SdPage* pMasterPage = GetDoc()->GetMasterSdPage(
421 nIndex, PK_STANDARD);
422 pMasterPage->CreateTitleAndLayout (TRUE,TRUE);
426 Cancel();
427 if(HasCurrentFunction(SID_BEZIER_EDIT))
428 GetViewFrame()->GetDispatcher()->Execute(
429 SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
430 rReq.Done ();
432 break;
434 case SID_MODIFYPAGE:
436 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES ||
437 (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE) )
439 if ( mpDrawView->IsTextEdit() )
441 mpDrawView->SdrEndTextEdit();
443 USHORT nPage = maTabControl.GetCurPageId() - 1;
444 mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind);
445 ::sd::ViewShell::mpImpl->ProcessModifyPageSlot (
446 rReq,
447 mpActualPage,
448 mePageKind);
451 Cancel();
452 rReq.Done ();
454 break;
456 case SID_ASSIGN_LAYOUT:
458 if (mePageKind==PK_STANDARD
459 || mePageKind==PK_NOTES
460 || (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE))
462 if ( mpDrawView->IsTextEdit() )
463 mpDrawView->SdrEndTextEdit();
465 SFX_REQUEST_ARG (rReq, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, FALSE);
466 SFX_REQUEST_ARG (rReq, pWhatLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, FALSE);
467 ::sd::ViewShell::mpImpl->AssignLayout (
468 GetDoc()->GetSdPage((USHORT)pWhatPage->GetValue(), mePageKind),
469 (AutoLayout)pWhatLayout->GetValue());
471 Cancel();
472 rReq.Done ();
474 break;
476 case SID_RENAMEPAGE:
477 case SID_RENAME_MASTER_PAGE:
479 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
481 if ( mpDrawView->IsTextEdit() )
483 mpDrawView->SdrEndTextEdit();
486 USHORT nPageId = maTabControl.GetCurPageId();
487 SdPage* pCurrentPage = ( GetEditMode() == EM_PAGE )
488 ? GetDoc()->GetSdPage( nPageId - 1, GetPageKind() )
489 : GetDoc()->GetMasterSdPage( nPageId - 1, GetPageKind() );
491 String aTitle( SdResId( STR_TITLE_RENAMESLIDE ) );
492 String aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
493 String aPageName = pCurrentPage->GetName();
495 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
496 DBG_ASSERT(pFact, "Dialogdiet fail!");
497 AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( GetActiveWindow(), aPageName, aDescr, RID_SVXDLG_NAME );
498 DBG_ASSERT(aNameDlg, "Dialogdiet fail!");
499 aNameDlg->SetText( aTitle );
500 aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl ), true );
501 aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
503 if( aNameDlg->Execute() == RET_OK )
505 String aNewName;
506 aNameDlg->GetName( aNewName );
507 if( ! aNewName.Equals( aPageName ) )
509 #ifdef DBG_UTIL
510 bool bResult =
511 #endif
512 RenameSlide( nPageId, aNewName );
513 DBG_ASSERT( bResult, "Couldn't rename slide" );
516 delete aNameDlg;
519 Cancel();
520 rReq.Ignore ();
522 break;
524 case SID_RENAMEPAGE_QUICK:
526 if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
528 if ( mpDrawView->IsTextEdit() )
530 mpDrawView->SdrEndTextEdit();
533 maTabControl.StartEditMode( maTabControl.GetCurPageId() );
536 Cancel();
537 rReq.Ignore ();
539 break;
541 case SID_PAGESIZE : // entweder dieses (kein menueeintrag o. ae. !!)
543 const SfxItemSet *pArgs = rReq.GetArgs ();
545 if (pArgs)
546 if (pArgs->Count () == 3)
548 SFX_REQUEST_ARG (rReq, pWidth, SfxUInt32Item, ID_VAL_PAGEWIDTH, FALSE);
549 SFX_REQUEST_ARG (rReq, pHeight, SfxUInt32Item, ID_VAL_PAGEHEIGHT, FALSE);
550 SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, FALSE);
552 Size aSize (pWidth->GetValue (), pHeight->GetValue ());
554 SetupPage (aSize, 0, 0, 0, 0, TRUE, FALSE, pScaleAll->GetValue ());
555 rReq.Ignore ();
556 break;
559 StarBASIC::FatalError (SbERR_WRONG_ARGS);
560 rReq.Ignore ();
561 break;
564 case SID_PAGEMARGIN : // oder dieses (kein menueeintrag o. ae. !!)
566 const SfxItemSet *pArgs = rReq.GetArgs ();
568 if (pArgs)
569 if (pArgs->Count () == 5)
571 SFX_REQUEST_ARG (rReq, pLeft, SfxUInt32Item, ID_VAL_PAGELEFT, FALSE);
572 SFX_REQUEST_ARG (rReq, pRight, SfxUInt32Item, ID_VAL_PAGERIGHT, FALSE);
573 SFX_REQUEST_ARG (rReq, pUpper, SfxUInt32Item, ID_VAL_PAGETOP, FALSE);
574 SFX_REQUEST_ARG (rReq, pLower, SfxUInt32Item, ID_VAL_PAGEBOTTOM, FALSE);
575 SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, FALSE);
577 Size aEmptySize (0, 0);
579 SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (),
580 pUpper->GetValue (), pLower->GetValue (),
581 FALSE, TRUE, pScaleAll->GetValue ());
582 rReq.Ignore ();
583 break;
586 StarBASIC::FatalError (SbERR_WRONG_ARGS);
587 rReq.Ignore ();
588 break;
591 case SID_ATTR_ZOOMSLIDER:
593 const SfxItemSet* pArgs = rReq.GetArgs();
595 if (pArgs && pArgs->Count () == 1 )
597 SFX_REQUEST_ARG (rReq, pScale, SfxUInt16Item, SID_ATTR_ZOOMSLIDER, FALSE);
598 if (CHECK_RANGE (5, pScale->GetValue (), 3000))
600 SetZoom (pScale->GetValue ());
602 SfxBindings& rBindings = GetViewFrame()->GetBindings();
603 rBindings.Invalidate( SID_ATTR_ZOOM );
604 rBindings.Invalidate( SID_ZOOM_IN );
605 rBindings.Invalidate( SID_ZOOM_OUT );
606 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
611 Cancel();
612 rReq.Done ();
613 break;
615 case SID_ZOOMING : // kein Menueintrag, sondern aus dem Zoomdialog generiert
617 const SfxItemSet* pArgs = rReq.GetArgs();
619 if (pArgs)
620 if (pArgs->Count () == 1)
622 SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, FALSE);
623 if (CHECK_RANGE (10, pScale->GetValue (), 1000))
625 SetZoom (pScale->GetValue ());
627 SfxBindings& rBindings = GetViewFrame()->GetBindings();
628 rBindings.Invalidate( SID_ATTR_ZOOM );
629 rBindings.Invalidate( SID_ZOOM_IN );
630 rBindings.Invalidate( SID_ZOOM_OUT );
631 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
633 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
635 rReq.Ignore ();
636 break;
639 StarBASIC::FatalError (SbERR_WRONG_ARGS);
640 rReq.Ignore ();
641 break;
644 case SID_ATTR_ZOOM:
646 const SfxItemSet* pArgs = rReq.GetArgs();
647 mbZoomOnPage = FALSE;
649 if ( pArgs )
651 SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs->
652 Get( SID_ATTR_ZOOM ) ).GetType();
653 switch( eZT )
655 case SVX_ZOOM_PERCENT:
656 SetZoom( (long) ( ( const SvxZoomItem& ) pArgs->
657 Get( SID_ATTR_ZOOM ) ).GetValue() );
658 break;
660 case SVX_ZOOM_OPTIMAL:
661 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL,
662 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
663 break;
665 case SVX_ZOOM_PAGEWIDTH:
666 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH,
667 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
668 break;
670 case SVX_ZOOM_WHOLEPAGE:
671 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE,
672 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
673 break;
674 case SVX_ZOOM_PAGEWIDTH_NOBORDER:
675 DBG_ERROR("sd::DrawViewShell::FuTemporary(), SVX_ZOOM_PAGEWIDTH_NOBORDER not handled!" );
676 break;
678 rReq.Ignore ();
680 else
682 // hier den Zoom-Dialog oeffnen
683 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
685 Cancel();
687 break;
689 case SID_CHANGEBEZIER:
690 case SID_CHANGEPOLYGON:
691 if ( mpDrawView->IsTextEdit() )
693 mpDrawView->SdrEndTextEdit();
694 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
697 if ( mpDrawView->IsPresObjSelected() )
699 ::sd::Window* pWindow = GetActiveWindow();
700 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
702 else
704 if( rReq.GetSlot() == SID_CHANGEBEZIER )
706 WaitObject aWait( (Window*)GetActiveWindow() );
707 mpDrawView->ConvertMarkedToPathObj(FALSE);
709 else
711 if( mpDrawView->IsVectorizeAllowed() )
712 SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
713 else
715 WaitObject aWait( (Window*)GetActiveWindow() );
716 mpDrawView->ConvertMarkedToPolyObj(FALSE);
720 Invalidate(SID_CHANGEBEZIER);
721 Invalidate(SID_CHANGEPOLYGON);
723 Cancel();
725 if( HasCurrentFunction(SID_BEZIER_EDIT) )
726 { // ggf. die richtige Editfunktion aktivieren
727 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT,
728 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
730 rReq.Ignore ();
731 break;
733 case SID_CONVERT_TO_CONTOUR:
734 if ( mpDrawView->IsTextEdit() )
736 mpDrawView->SdrEndTextEdit();
737 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
740 if ( mpDrawView->IsPresObjSelected() )
742 ::sd::Window* pWindow = GetActiveWindow();
743 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
745 else
747 WaitObject aWait( (Window*)GetActiveWindow() );
748 mpDrawView->ConvertMarkedToPathObj(TRUE);
750 Invalidate(SID_CONVERT_TO_CONTOUR);
752 Cancel();
754 rReq.Ignore ();
755 break;
757 case SID_CONVERT_TO_METAFILE:
758 case SID_CONVERT_TO_BITMAP:
760 // End text edit mode when it is active because the metafile or
761 // bitmap that will be created does not support it.
762 if ( mpDrawView->IsTextEdit() )
764 mpDrawView->SdrEndTextEdit();
765 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
768 if ( mpDrawView->IsPresObjSelected(true,true,true) )
770 ::sd::Window* pWindow = GetActiveWindow();
771 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
773 else
775 WaitObject aWait( (Window*)GetActiveWindow() );
777 // switch on undo for the next operations
778 mpDrawView->BegUndo(
779 String(
780 SdResId (nSId==SID_CONVERT_TO_METAFILE ? STR_UNDO_CONVERT_TO_METAFILE : STR_UNDO_CONVERT_TO_BITMAP)));
782 // create SdrGrafObj from metafile/bitmap
783 Graphic aGraphic;
784 switch (nSId)
786 case SID_CONVERT_TO_METAFILE:
788 GDIMetaFile aMetaFile(mpDrawView->GetAllMarkedMetaFile ());
789 aGraphic = Graphic(aMetaFile);
791 break;
792 case SID_CONVERT_TO_BITMAP:
794 Bitmap aBitmap (mpDrawView->GetAllMarkedBitmap ());
795 aGraphic = Graphic(aBitmap);
797 break;
800 // create new object
801 SdrGrafObj* pGraphicObj = new SdrGrafObj (aGraphic);
803 // get some necessary info and ensure it
804 const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
805 const sal_uInt32 nMarkCount(rMarkList.GetMarkCount());
806 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
807 OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)");
808 OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)");
810 // fit rectangle of new graphic object to selection's mark rect
811 Rectangle aAllMarkedRect;
812 rMarkList.TakeBoundRect(pPageView, aAllMarkedRect);
813 pGraphicObj->SetLogicRect(aAllMarkedRect);
815 // #i71540# to keep the order, it is necessary to replace the lowest object
816 // of the selection with the new object. This also means that with multi
817 // selection, all other objects need to be deleted first
818 SdrMark* pFirstMark = rMarkList.GetMark(0L);
819 SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj();
821 if(nMarkCount > 1L)
823 // take first object out of selection
824 mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true);
826 // clear remaining selection
827 mpDrawView->DeleteMarkedObj();
830 // now replace lowest object with new one
831 mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj);
833 // switch off undo
834 mpDrawView->EndUndo();
838 Cancel();
840 rReq.Done ();
841 break;
843 case SID_SET_DEFAULT:
845 SfxItemSet* pSet = NULL;
847 if (mpDrawView->IsTextEdit())
849 ::Outliner* pOutl = mpDrawView->GetTextEditOutliner();
850 if (pOutl)
852 pOutl->RemoveFields(TRUE, (TypeId) SvxURLField::StaticType());
855 pSet = new SfxItemSet( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
856 mpDrawView->SetAttributes( *pSet, TRUE );
858 else
860 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
861 ULONG nCount = rMarkList.GetMarkCount();
863 // In diese Liste werden fuer jedes Praesentationsobjekt ein SfxItemSet
864 // der harten Attribute sowie der UserCall eingetragen, da diese beim nachfolgenden
865 // mpDrawView->SetAttributes( *pSet, TRUE ) verloren gehen und spaeter restauriert
866 // werden muessen
867 List* pAttrList = new List();
868 SdPage* pPresPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
869 ULONG i;
871 for ( i = 0; i < nCount; i++ )
873 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
875 if( pPresPage->IsPresObj( pObj ) )
877 SfxItemSet* pNewSet = new SfxItemSet( GetDoc()->GetPool(), SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 0 );
878 pNewSet->Put(pObj->GetMergedItemSet());
879 pAttrList->Insert( pNewSet, LIST_APPEND );
880 pAttrList->Insert( pObj->GetUserCall(), LIST_APPEND );
884 pSet = new SfxItemSet( GetPool() );
885 mpDrawView->SetAttributes( *pSet, TRUE );
887 ULONG j = 0;
889 for ( i = 0; i < nCount; i++ )
891 SfxStyleSheet* pSheet = NULL;
892 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
894 if (pObj->GetObjIdentifier() == OBJ_TITLETEXT)
896 pSheet = mpActualPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
897 if (pSheet)
898 pObj->SetStyleSheet(pSheet, FALSE);
900 else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
902 for (USHORT nLevel = 1; nLevel < 10; nLevel++)
904 pSheet = mpActualPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
905 DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
906 if (pSheet)
908 pObj->StartListening(*pSheet);
910 if( nLevel == 1 )
911 // Textrahmen hoert auf StyleSheet der Ebene1
912 pObj->NbcSetStyleSheet(pSheet, FALSE);
918 if( pPresPage->IsPresObj( pObj ) )
920 SfxItemSet* pNewSet = (SfxItemSet*) pAttrList->GetObject(j++);
921 SdrObjUserCall* pUserCall = (SdrObjUserCall*) pAttrList->GetObject(j++);
923 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SFX_ITEM_ON )
925 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT));
928 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SFX_ITEM_ON )
930 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT));
933 if( pUserCall )
934 pObj->SetUserCall( pUserCall );
936 delete pNewSet;
940 delete pAttrList;
943 delete pSet;
944 Cancel();
946 break;
948 case SID_DELETE_SNAPITEM:
950 SdrPageView* pPV;
951 Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos );
952 USHORT nHitLog = (USHORT) GetActiveWindow()->PixelToLogic( Size(
953 FuPoor::HITPIX, 0 ) ).Width();
954 USHORT nHelpLine;
956 mbMousePosFreezed = FALSE;
958 if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
960 pPV->DeleteHelpLine( nHelpLine );
962 Cancel();
963 rReq.Ignore ();
965 break;
967 case SID_DELETE_PAGE:
968 case SID_DELETE_MASTER_PAGE:
969 DeleteActualPage();
970 Cancel();
971 rReq.Ignore ();
972 break;
974 case SID_DELETE_LAYER:
975 DeleteActualLayer();
976 Cancel();
977 rReq.Ignore ();
978 break;
980 case SID_ORIGINAL_SIZE:
981 mpDrawView->SetMarkedOriginalSize();
982 Cancel();
983 rReq.Done();
984 break;
986 case SID_DRAW_FONTWORK:
987 case SID_DRAW_FONTWORK_VERTICAL:
989 svx::FontworkBar::execute( mpView, rReq, GetViewFrame()->GetBindings() ); // SJ: can be removed (I think)
990 Cancel();
991 rReq.Done();
993 break;
995 case SID_SAVEGRAPHIC:
997 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
998 if( rMarkList.GetMarkCount() == 1 )
1000 SdrGrafObj *pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
1001 if(pGrafObj )
1003 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape( pGrafObj->getUnoShape(), com::sun::star::uno::UNO_QUERY );
1004 SdGRFFilter::SaveGraphic( xShape );
1007 Cancel();
1008 rReq.Ignore();
1010 break;
1012 case SID_INPLACE_OBJECT:
1013 case SID_OUTPLACE_OBJECT:
1015 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1016 if( rMarkList.GetMarkCount() == 1 )
1018 SdrOle2Obj *pOleObj = dynamic_cast< SdrOle2Obj* >( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
1019 if( pOleObj && !GetDocSh()->IsUIActive() )
1021 if( SID_OUTPLACE_OBJECT == nSId )
1022 ActivateObject( pOleObj, embed::EmbedVerbs::MS_OLEVERB_OPEN );
1023 else
1024 ActivateObject( pOleObj, embed::EmbedVerbs::MS_OLEVERB_PRIMARY );
1027 Cancel();
1028 rReq.Ignore();
1030 break;
1032 default:
1034 // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
1035 // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8)
1036 // gewandert.
1037 FuTemp01(rReq);
1039 break;
1042 if(HasCurrentFunction())
1044 GetCurrentFunction()->Activate();
1051 /** This method consists basically of three parts:
1052 1. Process the arguments of the SFX request.
1053 2. Use the model to create a new page or duplicate an existing one.
1054 3. Update the tab control and switch to the new page.
1056 SdPage* DrawViewShell::CreateOrDuplicatePage (
1057 SfxRequest& rRequest,
1058 PageKind ePageKind,
1059 SdPage* pPage)
1061 SdPage* pNewPage = NULL;
1062 if (ePageKind == PK_STANDARD && meEditMode != EM_MASTERPAGE)
1064 if ( mpDrawView->IsTextEdit() )
1066 mpDrawView->SdrEndTextEdit();
1068 pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage);
1070 return pNewPage;
1073 } // end of namespace sd