update dev300-m58
[ooovba.git] / sw / source / ui / shells / drwbassh.cxx
blob75026e8d4e33731d2f22121e1c44c44c48486c85
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: drwbassh.cxx,v $
10 * $Revision: 1.29 $
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_sw.hxx"
35 #include <tools/shl.hxx>
36 #include <hintids.hxx>
37 #include <helpid.h>
38 #include <swtypes.hxx>
39 #include <sfx2/objface.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/bindings.hxx>
42 #include <svtools/aeitem.hxx>
43 #include <svx/svdview.hxx>
44 #include <vcl/msgbox.hxx>
45 #include <svx/srchitem.hxx>
46 #include <svtools/whiter.hxx>
47 #include <svx/swframevalidation.hxx>
48 #include <svx/anchorid.hxx>
49 #include <svx/htmlmode.hxx>
50 #include <uitool.hxx>
51 #include <fmtornt.hxx>
52 #ifndef _CMDID_H
53 #include <cmdid.h>
54 #endif
55 #include <swmodule.hxx>
56 #include <wrtsh.hxx>
57 #include <wview.hxx>
58 #include <edtwin.hxx>
59 #include <viewopt.hxx>
60 #include <dcontact.hxx>
61 #include <frmfmt.hxx>
62 #include <wrap.hxx>
63 #include <drawbase.hxx>
64 #include <drwbassh.hxx>
65 #include <swdtflvr.hxx>
66 #include <svx/svdogrp.hxx>
67 #include <svx/svdpage.hxx>
68 #include <svx/svditer.hxx>
70 #include <shells.hrc>
71 #define SwDrawBaseShell
72 #include <sfx2/msg.hxx>
73 #include <swslots.hxx>
74 #include <svx/svxdlg.hxx>
75 #include <svx/dialogs.hrc>
76 #include "swabstdlg.hxx"
77 #include "dialog.hrc"
78 #include <swundo.hxx>
79 #include <com/sun/star/text/HoriOrientation.hpp>
80 #include <com/sun/star/text/VertOrientation.hpp>
81 #include <com/sun/star/text/RelOrientation.hpp>
83 #include <IDocumentDrawModelAccess.hxx>
85 using namespace ::com::sun::star;
87 SFX_IMPL_INTERFACE(SwDrawBaseShell, SwBaseShell, SW_RES(0))
91 TYPEINIT1(SwDrawBaseShell,SwBaseShell)
93 /*--------------------------------------------------------------------
94 Beschreibung:
95 --------------------------------------------------------------------*/
98 SwDrawBaseShell::SwDrawBaseShell(SwView &_rView):
99 SwBaseShell( _rView )
101 GetShell().NoEdit(TRUE);
103 SwEditWin& rWin = GetView().GetEditWin();
105 rWin.SetBezierMode(SID_BEZIER_MOVE);
107 if ( !_rView.GetDrawFuncPtr() )
108 _rView.GetEditWin().StdDrawMode( OBJ_NONE, TRUE );
110 SwTransferable::CreateSelection( GetShell() );
113 /*--------------------------------------------------------------------
114 Beschreibung:
115 --------------------------------------------------------------------*/
118 SwDrawBaseShell::~SwDrawBaseShell()
120 GetView().ExitDraw();
121 GetShell().Edit();
122 SwTransferable::ClearSelection( GetShell() );
125 /*--------------------------------------------------------------------
126 Beschreibung:
127 --------------------------------------------------------------------*/
130 void SwDrawBaseShell::Execute(SfxRequest &rReq)
132 SwWrtShell *pSh = &GetShell();
133 SdrView* pSdrView = pSh->GetDrawView();
134 const SfxItemSet *pArgs = rReq.GetArgs();
135 USHORT nSlotId = rReq.GetSlot();
136 BOOL bChanged = pSdrView->GetModel()->IsChanged();
137 pSdrView->GetModel()->SetChanged(FALSE);
138 const SfxPoolItem* pItem = 0;
139 if(pArgs)
140 pArgs->GetItemState(nSlotId, FALSE, &pItem);
142 //Sonderfall Align per Menue
143 if(pItem && nSlotId == SID_OBJECT_ALIGN)
145 DBG_ASSERT(PTR_CAST(SfxEnumItem, pItem),"SfxEnumItem erwartet");
146 nSlotId = nSlotId + ((const SfxEnumItem*)pItem)->GetValue();
147 nSlotId++;
150 BOOL bAlignPossible = pSh->IsAlignPossible();
152 BOOL bTopParam = TRUE, bBottomParam = TRUE;
153 BOOL bNotify = FALSE;
154 BOOL bDone = FALSE;
155 SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
157 switch (nSlotId)
159 case FN_DRAW_WRAP_DLG:
161 if(pSdrView->AreObjectsMarked())
163 if(!pArgs)
165 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
166 if( rMarkList.GetMark(0) != 0 )
168 SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND,
169 RES_ANCHOR, RES_ANCHOR,
170 RES_LR_SPACE, RES_UL_SPACE,
171 SID_HTML_MODE, SID_HTML_MODE,
172 FN_DRAW_WRAP_DLG, FN_DRAW_WRAP_DLG,
175 aSet.Put(SfxBoolItem(SID_HTML_MODE,
176 0 != ::GetHtmlMode(pSh->GetView().GetDocShell())));
178 aSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, pSh->GetLayerId()));
180 pSh->GetObjAttr(aSet);
181 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
182 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
184 SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, TRUE, RC_DLG_SWWRAPDLG );
185 DBG_ASSERT(pDlg, "Dialogdiet fail!");
187 if (pDlg->Execute() == RET_OK)
189 const SfxPoolItem* pWrapItem;
190 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
191 if(SFX_ITEM_SET == pOutSet->GetItemState(FN_DRAW_WRAP_DLG, FALSE, &pWrapItem))
193 short nLayer = ((const SfxInt16Item*)pWrapItem)->GetValue();
194 if (nLayer == 1)
195 pSh->SelectionToHeaven();
196 else
197 pSh->SelectionToHell();
200 pSh->SetObjAttr(*pOutSet);
202 delete pDlg;
207 break;
209 case SID_ATTR_TRANSFORM:
211 if(pSdrView->AreObjectsMarked())
213 if(!pArgs)
215 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
216 if( rMarkList.GetMark(0) != 0 )
218 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
219 SfxAbstractTabDialog *pDlg=NULL;
220 BOOL bCaption = FALSE;
222 // Erlaubte Verankerungen:
223 short nAnchor = pSh->GetAnchorId();
224 USHORT nAllowedAnchors = SVX_OBJ_AT_CNTNT|SVX_OBJ_IN_CNTNT;
225 USHORT nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
227 if( !((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))) )
228 nAllowedAnchors |= SVX_OBJ_PAGE;
229 if ( pSh->IsFlyInFly() )
230 nAllowedAnchors |= SVX_OBJ_AT_FLY;
232 if (pObj->GetObjIdentifier() == OBJ_CAPTION )
233 bCaption = TRUE;
235 if (bCaption)
237 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
238 if ( pFact )
240 AbstractSvxCaptionDialog* pCaptionDlg =
241 pFact->CreateCaptionDialog( NULL, pSdrView, RID_SVXDLG_CAPTION, nAllowedAnchors );
242 pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
243 pDlg = pCaptionDlg;
244 DBG_ASSERT(pDlg, "Dialogdiet fail!");
247 else
249 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
250 if ( pFact )
253 AbstractSvxTransformTabDialog* pTransform =
254 pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, RID_SVXDLG_TRANSFORM, nAllowedAnchors );
255 pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
256 pDlg = pTransform;
257 DBG_ASSERT(pDlg, "Dialogdiet fail!");
260 SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
262 const USHORT* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
263 SfxItemSet aSet( *aNewAttr.GetPool(), pRange );
264 FieldUnit eMetric = ::GetDfltMetric(0 != dynamic_cast<SwWebView*>(&GetView()));
265 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) );
267 aSet.Put( aNewAttr, FALSE );
269 if (bCaption)
270 pSdrView->GetAttributes( aSet );
272 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
273 BOOL bRTL;
274 aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, pSh->IsFrmVertical(TRUE, bRTL)));
275 aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT, bRTL));
277 SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
279 aSet.Put( pFrmFmt->GetFmtAttr(RES_FOLLOW_TEXT_FLOW) );
281 SwFmtVertOrient aVOrient((const SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
282 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, aVOrient.GetVertOrient()));
283 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, aVOrient.GetRelationOrient() ));
284 aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, aVOrient.GetPos()));
286 SwFmtHoriOrient aHOrient((const SwFmtHoriOrient&)pFrmFmt->GetFmtAttr(RES_HORI_ORIENT));
287 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, aHOrient.GetHoriOrient()));
288 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, aHOrient.GetRelationOrient() ));
289 aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, aHOrient.IsPosToggle()));
290 aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos()));
292 aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
294 pDlg->SetInputSet( &aSet );
296 if (pDlg->Execute() == RET_OK)
298 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
299 pSh->StartAllAction();
301 // --> OD 2004-07-14 #i30451#
302 pSh->StartUndo();
304 pSdrView->SetGeoAttrToMarked(*pOutSet);
306 if (bCaption)
307 pSdrView->SetAttributes(*pOutSet);
309 BOOL bPosCorr =
310 SFX_ITEM_SET != pOutSet->GetItemState(
311 SID_ATTR_TRANSFORM_POS_X, FALSE ) &&
312 SFX_ITEM_SET != pOutSet->GetItemState(
313 SID_ATTR_TRANSFORM_POS_Y, FALSE );
315 SfxItemSet aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1);
317 bool bSingleSelection = rMarkList.GetMarkCount() == 1;
319 const SfxPoolItem* pAnchorItem;
320 if(SFX_ITEM_SET == pOutSet->GetItemState(
321 SID_ATTR_TRANSFORM_ANCHOR, FALSE, &pAnchorItem))
323 if(!bSingleSelection)
324 pSh->ChgAnchor(((const SfxInt16Item*)pAnchorItem)
325 ->GetValue(), FALSE, bPosCorr );
326 else
328 SwFmtAnchor aAnchor(pFrmFmt->GetAnchor());
329 aAnchor.SetType((RndStdIds)((const SfxInt16Item*)pAnchorItem)->GetValue());
330 aFrmAttrSet.Put( aAnchor );
333 const SfxPoolItem* pHoriOrient = 0;
334 const SfxPoolItem* pHoriRelation = 0;
335 const SfxPoolItem* pHoriPosition = 0;
336 const SfxPoolItem* pHoriMirror = 0;
337 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, FALSE, &pHoriOrient);
338 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, FALSE, &pHoriRelation);
339 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, FALSE, &pHoriPosition);
340 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, FALSE, &pHoriMirror);
341 if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror)
343 if(pHoriOrient)
344 aHOrient.SetHoriOrient(
345 static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue());
346 if(pHoriRelation)
347 aHOrient.SetRelationOrient(
348 static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue());
349 if(pHoriPosition)
350 aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue());
351 if(pHoriMirror)
352 aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue());
353 aFrmAttrSet.Put(aHOrient);
356 const SfxPoolItem* pVertOrient = 0;
357 const SfxPoolItem* pVertRelation = 0;
358 const SfxPoolItem* pVertPosition = 0;
359 pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, FALSE, &pVertOrient);
360 pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, FALSE, &pVertRelation);
361 pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, FALSE, &pVertPosition);
362 if(pVertOrient || pVertRelation || pVertPosition )
364 if(pVertOrient)
365 aVOrient.SetVertOrient(
366 static_cast<const SfxInt16Item*>(pVertOrient)->GetValue());
367 if(pVertRelation)
368 aVOrient.SetRelationOrient(
369 static_cast<const SfxInt16Item*>(pVertRelation)->GetValue());
370 if(pVertPosition)
371 aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue());
372 aFrmAttrSet.Put( aVOrient );
374 const SfxPoolItem* pFollowItem = 0;
375 pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, FALSE, &pFollowItem);
376 if(pFollowItem)
377 aFrmAttrSet.Put(*pFollowItem);
379 if(aFrmAttrSet.Count())
380 pSh->SetDrawingAttr(aFrmAttrSet);
382 rBind.InvalidateAll(FALSE);
384 // --> OD 2004-07-14 #i30451#
385 pSh->EndUndo( UNDO_INSFMTATTR );
387 pSh->EndAllAction();
389 delete pDlg;
395 break;
397 case SID_DELETE:
398 case FN_BACKSPACE:
399 if (pSh->IsObjSelected() && !pSdrView->IsTextEdit())
401 bDone = TRUE;
403 if( GetView().IsDrawRotate() )
405 pSh->SetDragMode( SDRDRAG_MOVE );
406 GetView().FlipDrawRotate();
409 pSh->SetModified();
410 pSh->DelSelectedObj();
412 if (rReq.IsAPI() ||
413 GetView().GetEditWin().IsObjectSelect() )
415 // Wenn Basic-Aufruf, dann zurueck in die Textshell, da das
416 // Basic sonst keine Rueckkehrmoeglichkeit hat.
417 if (GetView().GetDrawFuncPtr())
419 GetView().GetDrawFuncPtr()->Deactivate();
420 GetView().SetDrawFuncPtr(NULL);
422 GetView().LeaveDrawCreate(); // In Selektionsmode wechseln
425 if (pSh->IsSelFrmMode())
427 pSh->LeaveSelFrmMode();
428 // #105852# FME
429 // pSh->NoEdit();
431 bNotify = TRUE;
433 break;
435 case SID_GROUP:
436 if (pSh->IsObjSelected() > 1 && pSh->IsGroupAllowed())
438 pSh->GroupSelection(); // Objekt gruppieren
439 rBind.Invalidate(SID_UNGROUP);
441 break;
443 case SID_UNGROUP:
444 if (pSh->IsGroupSelected())
446 pSh->UnGroupSelection(); // Objektgruppierung aufheben
447 rBind.Invalidate(SID_GROUP);
449 break;
451 case SID_ENTER_GROUP:
452 if (pSh->IsGroupSelected())
454 pSdrView->EnterMarkedGroup();
455 rBind.InvalidateAll(FALSE);
457 break;
459 case SID_LEAVE_GROUP:
460 if (pSdrView->IsGroupEntered())
462 pSdrView->LeaveOneGroup();
463 rBind.Invalidate(SID_ENTER_GROUP);
464 rBind.Invalidate(SID_UNGROUP);
466 break;
468 case SID_OBJECT_ALIGN_LEFT:
469 case SID_OBJECT_ALIGN_CENTER:
470 case SID_OBJECT_ALIGN_RIGHT:
471 case SID_OBJECT_ALIGN_UP:
472 case SID_OBJECT_ALIGN_MIDDLE:
473 case SID_OBJECT_ALIGN_DOWN:
475 if ( bAlignPossible )
477 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
478 if( rMarkList.GetMarkCount() == 1 && bAlignPossible )
479 { // Objekte nicht aneinander ausrichten
481 USHORT nAnchor = pSh->GetAnchorId();
482 if (nAnchor == FLY_IN_CNTNT)
484 sal_Int16 nVertOrient = -1;
486 switch (nSlotId)
488 case SID_OBJECT_ALIGN_UP:
489 nVertOrient = text::VertOrientation::TOP;
490 break;
491 case SID_OBJECT_ALIGN_MIDDLE:
492 nVertOrient = text::VertOrientation::CENTER;
493 break;
494 case SID_OBJECT_ALIGN_DOWN:
495 nVertOrient = text::VertOrientation::BOTTOM;
496 break;
497 default:
498 break;
500 if (nVertOrient != -1)
502 pSh->StartAction();
503 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
504 SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
505 SwFmtVertOrient aVOrient((SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
506 aVOrient.SetVertOrient( nVertOrient );
507 pFrmFmt->SetFmtAttr(aVOrient);
508 pSh->EndAction();
510 break;
512 if (nAnchor == FLY_AT_CNTNT)
513 break; // Absatzverankerte Rahmen nicht ausrichten
516 pSh->StartAction();
517 switch (nSlotId)
519 case SID_OBJECT_ALIGN_LEFT:
520 pSdrView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
521 break;
522 case SID_OBJECT_ALIGN_CENTER:
523 pSdrView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
524 break;
525 case SID_OBJECT_ALIGN_RIGHT:
526 pSdrView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
527 break;
528 case SID_OBJECT_ALIGN_UP:
529 pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
530 break;
531 case SID_OBJECT_ALIGN_MIDDLE:
532 pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
533 break;
534 case SID_OBJECT_ALIGN_DOWN:
535 pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
536 break;
538 pSh->EndAction();
541 break;
543 case FN_FRAME_UP:
544 bTopParam = FALSE;
545 /* no break */
546 case SID_FRAME_TO_TOP:
547 pSh->SelectionToTop( bTopParam );
548 break;
550 case FN_FRAME_DOWN:
551 bBottomParam = FALSE;
552 /* no break */
553 case SID_FRAME_TO_BOTTOM:
554 pSh->SelectionToBottom( bBottomParam );
555 break;
557 case FN_NAME_SHAPE:
559 bDone = TRUE;
561 if(1L == pSdrView->GetMarkedObjectCount())
563 // #i68101#
564 SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
565 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
566 String aName(pSelected->GetName());
568 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
569 OSL_ENSURE(pFact, "Dialogdiet fail!");
570 AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName, RID_SVXDLG_OBJECT_NAME);
571 OSL_ENSURE(pDlg, "Dialogdiet fail!");
573 pDlg->SetCheckNameHdl(LINK(this, SwDrawBaseShell, CheckGroupShapeNameHdl));
575 if(RET_OK == pDlg->Execute())
577 pDlg->GetName(aName);
578 pSelected->SetName(aName);
579 pSh->SetModified();
582 delete pDlg;
585 break;
588 // #i68101#
589 case FN_TITLE_DESCRIPTION_SHAPE:
591 bDone = TRUE;
593 if(1L == pSdrView->GetMarkedObjectCount())
595 SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
596 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
597 String aTitle(pSelected->GetTitle());
598 String aDescription(pSelected->GetDescription());
600 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
601 OSL_ENSURE(pFact, "Dialogdiet fail!");
602 AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription, RID_SVXDLG_OBJECT_TITLE_DESC);
603 OSL_ENSURE(pDlg, "Dialogdiet fail!");
605 if(RET_OK == pDlg->Execute())
607 pDlg->GetTitle(aTitle);
608 pDlg->GetDescription(aDescription);
610 pSelected->SetTitle(aTitle);
611 pSelected->SetDescription(aDescription);
613 pSh->SetModified();
616 delete pDlg;
619 break;
622 default:
623 DBG_ASSERT(!this, "falscher Dispatcher");
624 return;
626 if(!bDone)
628 if(nSlotId >= SID_OBJECT_ALIGN_LEFT && nSlotId <= SID_OBJECT_ALIGN_DOWN)
629 rBind.Invalidate(SID_ATTR_LONG_LRSPACE);
630 if (pSdrView->GetModel()->IsChanged())
631 pSh->SetModified();
632 else if (bChanged)
633 pSdrView->GetModel()->SetChanged(TRUE);
634 // 40220: Nach dem Loeschen von DrawObjekten ueber die API GPF durch Selbstzerstoerung
635 if(bNotify)
636 GetView().AttrChangedNotify(pSh); // ggf Shellwechsel...
639 /* -----------------------------27.02.2002 15:27------------------------------
640 Checks whether a given name is allowed for a group shape
641 ---------------------------------------------------------------------------*/
642 IMPL_LINK( SwDrawBaseShell, CheckGroupShapeNameHdl, AbstractSvxNameDialog*, pNameDialog )
644 SwWrtShell &rSh = GetShell();
645 SdrView *pSdrView = rSh.GetDrawView();
646 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
647 DBG_ASSERT(rMarkList.GetMarkCount() == 1, "wrong draw selection");
648 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
649 const String sCurrentName = pObj->GetName();
650 String sNewName;
651 pNameDialog->GetName(sNewName);
652 long nRet = 0;
653 if(!sNewName.Len() || sCurrentName == sNewName)
654 nRet = 1;
655 else
657 nRet = 1;
658 SdrModel* pModel = rSh.getIDocumentDrawModelAccess()->GetDrawModel();
659 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now.
660 // consider also drawing objects inside group objects
661 // SdrPage* pPage = pModel->GetPage(0);
662 // sal_uInt32 nCount = pPage->GetObjCount();
663 // for( sal_uInt32 i=0; i< nCount; i++ )
664 // {
665 // SdrObject* pTemp = pPage->GetObj(i);
666 // if(pObj != pTemp && pTemp->ISA(SdrObjGroup) && pTemp->GetName() == sNewName)
667 // {
668 // nRet = 0;
669 // break;
670 // }
671 // }
672 SdrObjListIter aIter( *(pModel->GetPage(0)), IM_DEEPWITHGROUPS );
673 while( aIter.IsMore() )
675 SdrObject* pTempObj = aIter.Next();
676 if ( pObj != pTempObj && pTempObj->GetName() == sNewName )
678 nRet = 0;
679 break;
682 // <--
684 return nRet;
686 /*--------------------------------------------------------------------
687 Beschreibung:
688 --------------------------------------------------------------------*/
689 void SwDrawBaseShell::GetState(SfxItemSet& rSet)
691 SwWrtShell &rSh = GetShell();
692 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
693 SfxWhichIter aIter( rSet );
694 USHORT nWhich = aIter.FirstWhich();
695 BOOL bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
697 if (!bProtected) // Im Parent nachsehen
698 bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
700 while( nWhich )
702 switch( nWhich )
704 case FN_DRAW_WRAP_DLG:
705 case SID_ATTR_TRANSFORM:
706 case SID_FRAME_TO_TOP:
707 case SID_FRAME_TO_BOTTOM:
708 case FN_FRAME_UP:
709 case FN_FRAME_DOWN:
710 case SID_DELETE:
711 case FN_BACKSPACE:
712 if( bProtected || !rSh.IsObjSelected() )
713 rSet.DisableItem( nWhich );
714 break;
715 case SID_GROUP:
716 if ( rSh.IsObjSelected() < 2 || bProtected || !rSh.IsGroupAllowed() )
717 rSet.DisableItem( nWhich );
718 break;
719 case SID_UNGROUP:
720 if ( !rSh.IsGroupSelected() || bProtected )
721 rSet.DisableItem( nWhich );
722 break;
723 case SID_ENTER_GROUP:
724 if ( !rSh.IsGroupSelected() )
725 rSet.DisableItem( nWhich );
726 break;
727 case SID_LEAVE_GROUP:
728 if ( !pSdrView->IsGroupEntered() )
729 rSet.DisableItem( nWhich );
730 break;
731 case SID_OBJECT_ALIGN_LEFT:
732 case SID_OBJECT_ALIGN_CENTER:
733 case SID_OBJECT_ALIGN_RIGHT:
734 case SID_OBJECT_ALIGN_UP:
735 case SID_OBJECT_ALIGN_MIDDLE:
736 case SID_OBJECT_ALIGN_DOWN:
737 case SID_OBJECT_ALIGN:
738 if ( !rSh.IsAlignPossible() || bProtected )
739 rSet.DisableItem( nWhich );
740 else
742 SfxAllEnumItem aEnumItem(nWhich, USHRT_MAX);
743 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
744 //if only one object is selected it can only be vertically
745 // aligned because it is character bound
746 if( rMarkList.GetMarkCount() == 1 )
748 aEnumItem.DisableValue(SID_OBJECT_ALIGN_LEFT);
749 aEnumItem.DisableValue(SID_OBJECT_ALIGN_CENTER);
750 aEnumItem.DisableValue(SID_OBJECT_ALIGN_RIGHT);
752 rSet.Put(aEnumItem);
754 break;
756 case FN_NAME_SHAPE :
758 if(1L != pSdrView->GetMarkedObjectCount())
760 rSet.DisableItem( nWhich );
763 break;
765 // #i68101#
766 case FN_TITLE_DESCRIPTION_SHAPE:
768 const bool bIsWebView(NULL != dynamic_cast<SwWebView*>(&GetView()));
770 if(!bIsWebView && 1L != pSdrView->GetMarkedObjectCount())
772 rSet.DisableItem( nWhich );
775 break;
777 nWhich = aIter.NextWhich();
781 /*--------------------------------------------------------------------
782 Beschreibung:
783 --------------------------------------------------------------------*/
786 BOOL SwDrawBaseShell::Disable(SfxItemSet& rSet, USHORT nWhich)
788 BOOL bDisable = GetShell().IsSelObjProtected(FLYPROTECT_CONTENT);
790 if (bDisable)
792 if (nWhich)
793 rSet.DisableItem( nWhich );
794 else
796 SfxWhichIter aIter( rSet );
797 nWhich = aIter.FirstWhich();
798 while (nWhich)
800 rSet.DisableItem( nWhich );
801 nWhich = aIter.NextWhich();
806 return bDisable;
809 /*-- 09.03.2004 13:15:03---------------------------------------------------
810 Validate of drawing positions
811 -----------------------------------------------------------------------*/
812 IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation )
814 SwWrtShell *pSh = &GetShell();
815 pValidation->nMinHeight = MINFLY;
816 pValidation->nMinWidth = MINFLY;
818 SwRect aBoundRect;
820 // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
821 // aligned to page for fly frame anchored to paragraph or to character.
822 const RndStdIds eAnchorType = static_cast<RndStdIds >(pValidation->nAnchorType);
823 const SwPosition* pCntntPos = 0;
824 SdrView* pSdrView = pSh->GetDrawView();
825 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
826 if( rMarkList.GetMarkCount() == 1 )
828 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
829 SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
830 pCntntPos = pFrmFmt->GetAnchor().GetCntntAnchor();
833 pSh->CalcBoundRect( aBoundRect, eAnchorType,
834 pValidation->nHRelOrient,
835 pValidation->nVRelOrient,
836 pCntntPos,
837 pValidation->bFollowTextFlow,
838 pValidation->bMirror, NULL, &pValidation->aPercentSize);
840 BOOL bRTL;
841 BOOL bIsInVertical = pSh->IsFrmVertical(TRUE, bRTL);
842 if(bIsInVertical)
844 Point aPos(aBoundRect.Pos());
845 long nTmp = aPos.X();
846 aPos.X() = aPos.Y();
847 aPos.Y() = nTmp;
848 Size aSize(aBoundRect.SSize());
849 nTmp = aSize.Width();
850 aSize.Width() = aSize.Height();
851 aSize.Height() = nTmp;
852 aBoundRect.Chg( aPos, aSize );
853 //exchange width/height to enable correct values
854 nTmp = pValidation->nWidth;
855 pValidation->nWidth = pValidation->nHeight;
856 pValidation->nHeight = nTmp;
858 if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY )
860 // MinimalPosition
861 pValidation->nMinHPos = aBoundRect.Left();
862 pValidation->nMinVPos = aBoundRect.Top();
863 SwTwips nH = pValidation->nHPos;
864 SwTwips nV = pValidation->nVPos;
866 if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
868 if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
870 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
871 nH = pValidation->nHPos;
873 else
874 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
877 if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
878 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
880 if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
882 if (pValidation->nVertOrient == text::VertOrientation::NONE)
884 pValidation->nVPos -= ((pValidation->nVPos + pValidation->nHeight) - aBoundRect.Bottom());
885 nV = pValidation->nVPos;
887 else
888 pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
891 if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
892 pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
894 if ( pValidation->nVertOrient != text::VertOrientation::NONE )
895 nV = aBoundRect.Top();
897 if ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
898 nH = aBoundRect.Left();
900 pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth;
901 pValidation->nMaxHeight = aBoundRect.Bottom() - nV;
903 pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight;
904 pValidation->nMaxWidth = aBoundRect.Right() - nH;
906 else if ( eAnchorType == FLY_AT_CNTNT || eAnchorType == FLY_AUTO_CNTNT )
908 if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
910 if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
912 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
914 else
915 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
918 // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
919 // and alignment at page areas.
920 const bool bMaxVPosAtBottom = !pValidation->bFollowTextFlow ||
921 pValidation->nVRelOrient == text::RelOrientation::PAGE_FRAME ||
922 pValidation->nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
924 SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
925 ? aBoundRect.Bottom()
926 : aBoundRect.Height() ) -
927 pValidation->nHeight;
928 if ( pValidation->nVPos > nTmpMaxVPos )
930 if (pValidation->nVertOrient == text::VertOrientation::NONE)
932 pValidation->nVPos = nTmpMaxVPos;
934 else
936 pValidation->nHeight = ( bMaxVPosAtBottom
937 ? aBoundRect.Bottom()
938 : aBoundRect.Height() ) - pValidation->nVPos;
943 pValidation->nMinHPos = aBoundRect.Left();
944 pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth;
946 pValidation->nMinVPos = aBoundRect.Top();
947 // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
948 if ( bMaxVPosAtBottom )
950 pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight;
952 else
954 pValidation->nMaxVPos = aBoundRect.Height() - pValidation->nHeight;
957 // Maximale Breite Hoehe
958 const SwTwips nH = ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
959 ? aBoundRect.Left()
960 : pValidation->nHPos;
961 const SwTwips nV = ( pValidation->nVertOrient != text::VertOrientation::NONE )
962 ? aBoundRect.Top()
963 : pValidation->nVPos;
964 pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV;
965 pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH;
967 else if ( eAnchorType == FLY_IN_CNTNT )
969 pValidation->nMinHPos = 0;
970 pValidation->nMaxHPos = 0;
972 pValidation->nMaxHeight = aBoundRect.Height();
973 pValidation->nMaxWidth = aBoundRect.Width();
975 pValidation->nMaxVPos = aBoundRect.Height();
976 pValidation->nMinVPos = -aBoundRect.Height() + pValidation->nHeight;
977 if (pValidation->nMaxVPos < pValidation->nMinVPos)
979 pValidation->nMinVPos = pValidation->nMaxVPos;
980 pValidation->nMaxVPos = -aBoundRect.Height();
983 if(bIsInVertical)
985 //restore width/height exchange
986 long nTmp = pValidation->nWidth;
987 pValidation->nWidth = pValidation->nHeight;
988 pValidation->nHeight = nTmp;
991 if (pValidation->nMaxWidth < pValidation->nWidth)
992 pValidation->nWidth = pValidation->nMaxWidth;
993 if (pValidation->nMaxHeight < pValidation->nHeight)
994 pValidation->nHeight = pValidation->nMaxHeight;
995 return 0;