xref: /AOO41X/main/sw/source/ui/shells/drwbassh.cxx (revision 707fc0d4d52eb4f69d89a98ffec6918ca5de6326)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <tools/shl.hxx>
29 #include <hintids.hxx>
30 #include <helpid.h>
31 #include <swtypes.hxx>
32 #include <sfx2/objface.hxx>
33 #include <sfx2/request.hxx>
34 #include <sfx2/bindings.hxx>
35 #include <svl/aeitem.hxx>
36 #include <svx/svdview.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <svl/srchitem.hxx>
39 #include <svl/whiter.hxx>
40 #include <svx/swframevalidation.hxx>
41 #include <svx/anchorid.hxx>
42 #include <svx/htmlmode.hxx>
43 #include <uitool.hxx>
44 #include <fmtornt.hxx>
45 #include <cmdid.h>
46 #include <swmodule.hxx>
47 #include <wrtsh.hxx>
48 #include <wview.hxx>
49 #include <edtwin.hxx>
50 #include <viewopt.hxx>
51 #include <dcontact.hxx>
52 #include <frmfmt.hxx>
53 #include <wrap.hxx>
54 #include <drawbase.hxx>
55 #include <drwbassh.hxx>
56 #include <swdtflvr.hxx>
57 #include <svx/svdogrp.hxx>
58 #include <svx/svdpage.hxx>
59 #include <svx/svditer.hxx>
60 
61 #include <shells.hrc>
62 #define SwDrawBaseShell
63 #include <sfx2/msg.hxx>
64 #include <swslots.hxx>
65 #include <svx/svxdlg.hxx>
66 #include <svx/dialogs.hrc>
67 #include "swabstdlg.hxx"
68 #include "dialog.hrc"
69 #include <swundo.hxx>
70 #include <com/sun/star/text/HoriOrientation.hpp>
71 #include <com/sun/star/text/VertOrientation.hpp>
72 #include <com/sun/star/text/RelOrientation.hpp>
73 
74 #include <IDocumentDrawModelAccess.hxx>
75 
76 using namespace ::com::sun::star;
77 
78 SFX_IMPL_INTERFACE(SwDrawBaseShell, SwBaseShell, SW_RES(0))
79 {
80 }
81 
82 TYPEINIT1(SwDrawBaseShell,SwBaseShell)
83 
84 /*--------------------------------------------------------------------
85     Beschreibung:
86  --------------------------------------------------------------------*/
87 
88 
89 SwDrawBaseShell::SwDrawBaseShell(SwView &_rView):
90     SwBaseShell( _rView )
91 {
92     GetShell().NoEdit(sal_True);
93 
94     SwEditWin& rWin = GetView().GetEditWin();
95 
96     rWin.SetBezierMode(SID_BEZIER_MOVE);
97 
98     if ( !_rView.GetDrawFuncPtr() )
99         _rView.GetEditWin().StdDrawMode( OBJ_NONE, sal_True );
100 
101     SwTransferable::CreateSelection( GetShell() );
102 }
103 
104 /*--------------------------------------------------------------------
105     Beschreibung:
106  --------------------------------------------------------------------*/
107 
108 
109 SwDrawBaseShell::~SwDrawBaseShell()
110 {
111     GetView().ExitDraw();
112     GetShell().Edit();
113     SwTransferable::ClearSelection( GetShell() );
114 }
115 
116 /*--------------------------------------------------------------------
117     Beschreibung:
118  --------------------------------------------------------------------*/
119 
120 
121 void SwDrawBaseShell::Execute(SfxRequest &rReq)
122 {
123     SwWrtShell *pSh = &GetShell();
124     SdrView*    pSdrView = pSh->GetDrawView();
125     const SfxItemSet *pArgs = rReq.GetArgs();
126     sal_uInt16      nSlotId = rReq.GetSlot();
127     sal_Bool        bChanged = pSdrView->GetModel()->IsChanged();
128     pSdrView->GetModel()->SetChanged(sal_False);
129     const SfxPoolItem* pItem = 0;
130     if(pArgs)
131         pArgs->GetItemState(nSlotId, sal_False, &pItem);
132 
133     //Sonderfall Align per Menue
134     if(pItem && nSlotId == SID_OBJECT_ALIGN)
135     {
136         DBG_ASSERT(PTR_CAST(SfxEnumItem, pItem),"SfxEnumItem erwartet");
137         nSlotId = nSlotId + ((const SfxEnumItem*)pItem)->GetValue();
138         nSlotId++;
139     }
140 
141     sal_Bool bAlignPossible = pSh->IsAlignPossible();
142 
143     sal_Bool bTopParam = sal_True, bBottomParam = sal_True;
144     sal_Bool bNotify = sal_False;
145     sal_Bool bDone = sal_False;
146     SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
147 
148     switch (nSlotId)
149     {
150         case FN_DRAW_WRAP_DLG:
151         {
152             if(pSdrView->AreObjectsMarked())
153             {
154                 if(!pArgs)
155                 {
156                     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
157                     if( rMarkList.GetMark(0) != 0 )
158                     {
159                         SfxItemSet aSet(GetPool(),  RES_SURROUND, RES_SURROUND,
160                                                     RES_ANCHOR, RES_ANCHOR,
161                                                     RES_LR_SPACE, RES_UL_SPACE,
162                                                     SID_HTML_MODE, SID_HTML_MODE,
163                                                     FN_DRAW_WRAP_DLG, FN_DRAW_WRAP_DLG,
164                                                     0);
165 
166                         aSet.Put(SfxBoolItem(SID_HTML_MODE,
167                             0 != ::GetHtmlMode(pSh->GetView().GetDocShell())));
168 
169                         aSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, pSh->GetLayerId()));
170 
171                         pSh->GetObjAttr(aSet);
172                         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
173                         DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
174 
175                         SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, sal_True, RC_DLG_SWWRAPDLG );
176                         DBG_ASSERT(pDlg, "Dialogdiet fail!");
177 
178                         if (pDlg->Execute() == RET_OK)
179                         {
180                             const SfxPoolItem* pWrapItem;
181                             const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
182                             if(SFX_ITEM_SET == pOutSet->GetItemState(FN_DRAW_WRAP_DLG, sal_False, &pWrapItem))
183                             {
184                                 short nLayer = ((const SfxInt16Item*)pWrapItem)->GetValue();
185                                 if (nLayer == 1)
186                                     pSh->SelectionToHeaven();
187                                 else
188                                     pSh->SelectionToHell();
189                             }
190 
191                             pSh->SetObjAttr(*pOutSet);
192                         }
193                     delete pDlg;
194                     }
195                 }
196             }
197         }
198         break;
199 
200         case SID_ATTR_TRANSFORM:
201         {
202             if(pSdrView->AreObjectsMarked())
203             {
204                 if(!pArgs)
205                 {
206                     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
207                     if( rMarkList.GetMark(0) != 0 )
208                     {
209                         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
210                         SfxAbstractTabDialog *pDlg=NULL;
211                         sal_Bool bCaption = sal_False;
212 
213                         // Erlaubte Verankerungen:
214                         short nAnchor = pSh->GetAnchorId();
215                         sal_uInt16 nAllowedAnchors = SVX_OBJ_AT_CNTNT|SVX_OBJ_IN_CNTNT;
216                         sal_uInt16 nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
217 
218                         if( !((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))) )
219                             nAllowedAnchors |= SVX_OBJ_PAGE;
220                         if ( pSh->IsFlyInFly() )
221                             nAllowedAnchors |= SVX_OBJ_AT_FLY;
222 
223                         if (pObj->GetObjIdentifier() == OBJ_CAPTION )
224                             bCaption = sal_True;
225 
226                         if (bCaption)
227                         {
228                             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
229                             if ( pFact )
230                             {
231                                 AbstractSvxCaptionDialog* pCaptionDlg =
232                                         pFact->CreateCaptionDialog( NULL, pSdrView, nAllowedAnchors );
233                                 pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
234                                 pDlg = pCaptionDlg;
235                                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
236                             }
237                         }
238                         else
239                         {
240                             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
241                             if ( pFact )
242                             {
243 
244                                 AbstractSvxTransformTabDialog* pTransform =
245                                             pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, nAllowedAnchors );
246                                 pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
247                                 pDlg = pTransform;
248                                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
249                             }
250                         }
251                         SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
252 
253                         const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
254                         SfxItemSet aSet( *aNewAttr.GetPool(), pRange );
255                         FieldUnit eMetric = ::GetDfltMetric(0 != dynamic_cast<SwWebView*>(&GetView()));
256                         SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
257 
258                         aSet.Put( aNewAttr, sal_False );
259 
260                         if (bCaption)
261                             pSdrView->GetAttributes( aSet );
262 
263                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
264                         sal_Bool bRTL;
265                         sal_Bool bVertL2R;
266                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, pSh->IsFrmVertical(sal_True, bRTL, bVertL2R)));
267                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT, bRTL));
268 
269                         SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
270 
271                         aSet.Put( pFrmFmt->GetFmtAttr(RES_FOLLOW_TEXT_FLOW) );
272 
273                         SwFmtVertOrient aVOrient((const SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
274                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, aVOrient.GetVertOrient()));
275                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, aVOrient.GetRelationOrient() ));
276                         aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, aVOrient.GetPos()));
277 
278                         SwFmtHoriOrient aHOrient((const SwFmtHoriOrient&)pFrmFmt->GetFmtAttr(RES_HORI_ORIENT));
279                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, aHOrient.GetHoriOrient()));
280                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, aHOrient.GetRelationOrient() ));
281                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, aHOrient.IsPosToggle()));
282                         aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos()));
283 
284                         aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
285 
286                         pDlg->SetInputSet( &aSet );
287 
288                         if (pDlg->Execute() == RET_OK)
289                         {
290                             const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
291                             pSh->StartAllAction();
292 
293                             // --> OD 2004-07-14 #i30451#
294                             pSh->StartUndo(UNDO_INSFMTATTR);
295 
296                             pSdrView->SetGeoAttrToMarked(*pOutSet);
297 
298                             if (bCaption)
299                                 pSdrView->SetAttributes(*pOutSet);
300 
301                             sal_Bool bPosCorr =
302                                 SFX_ITEM_SET != pOutSet->GetItemState(
303                                     SID_ATTR_TRANSFORM_POS_X, sal_False ) &&
304                                 SFX_ITEM_SET != pOutSet->GetItemState(
305                                     SID_ATTR_TRANSFORM_POS_Y, sal_False );
306 
307                             SfxItemSet aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1);
308 
309                             bool bSingleSelection = rMarkList.GetMarkCount() == 1;
310 
311                             const SfxPoolItem* pAnchorItem;
312                             if(SFX_ITEM_SET == pOutSet->GetItemState(
313                                 SID_ATTR_TRANSFORM_ANCHOR, sal_False, &pAnchorItem))
314                             {
315                                 if(!bSingleSelection)
316                                     pSh->ChgAnchor(((const SfxInt16Item*)pAnchorItem)
317                                             ->GetValue(), sal_False, bPosCorr );
318                                 else
319                                 {
320                                     SwFmtAnchor aAnchor(pFrmFmt->GetAnchor());
321                                     aAnchor.SetType((RndStdIds)((const SfxInt16Item*)pAnchorItem)->GetValue());
322                                     aFrmAttrSet.Put( aAnchor );
323                                 }
324                             }
325                             const SfxPoolItem* pHoriOrient = 0;
326                             const SfxPoolItem* pHoriRelation = 0;
327                             const SfxPoolItem* pHoriPosition = 0;
328                             const SfxPoolItem* pHoriMirror = 0;
329                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, sal_False, &pHoriOrient);
330                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, sal_False, &pHoriRelation);
331                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, sal_False, &pHoriPosition);
332                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, sal_False, &pHoriMirror);
333                             if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror)
334                             {
335                                 if(pHoriOrient)
336                                     aHOrient.SetHoriOrient(
337                                           static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue());
338                                 if(pHoriRelation)
339                                     aHOrient.SetRelationOrient(
340                                               static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue());
341                                 if(pHoriPosition)
342                                     aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue());
343                                 if(pHoriMirror)
344                                     aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue());
345                                 aFrmAttrSet.Put(aHOrient);
346                             }
347 
348                             const SfxPoolItem* pVertOrient = 0;
349                             const SfxPoolItem* pVertRelation = 0;
350                             const SfxPoolItem* pVertPosition = 0;
351                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, sal_False, &pVertOrient);
352                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, sal_False, &pVertRelation);
353                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, sal_False, &pVertPosition);
354                             if(pVertOrient || pVertRelation || pVertPosition )
355                             {
356                                 if(pVertOrient)
357                                     aVOrient.SetVertOrient(
358                                         static_cast<const SfxInt16Item*>(pVertOrient)->GetValue());
359                                 if(pVertRelation)
360                                     aVOrient.SetRelationOrient(
361                                         static_cast<const SfxInt16Item*>(pVertRelation)->GetValue());
362                                 if(pVertPosition)
363                                     aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue());
364                                 aFrmAttrSet.Put( aVOrient );
365                             }
366                             const SfxPoolItem* pFollowItem = 0;
367                             pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, sal_False, &pFollowItem);
368                             if(pFollowItem)
369                                 aFrmAttrSet.Put(*pFollowItem);
370 
371                             if(aFrmAttrSet.Count())
372                                 pSh->SetDrawingAttr(aFrmAttrSet);
373 
374                             rBind.InvalidateAll(sal_False);
375 
376                             // --> OD 2004-07-14 #i30451#
377                             pSh->EndUndo( UNDO_INSFMTATTR );
378 
379                             pSh->EndAllAction();
380                         }
381                         delete pDlg;
382 
383                     }
384                 }
385             }
386         }
387         break;
388 
389         case SID_DELETE:
390         case FN_BACKSPACE:
391             if (pSh->IsObjSelected() && !pSdrView->IsTextEdit())
392             {
393                 bDone = sal_True;
394 
395                 if( GetView().IsDrawRotate() )
396                 {
397                     pSh->SetDragMode( SDRDRAG_MOVE );
398                     GetView().FlipDrawRotate();
399                 }
400 
401                 pSh->SetModified();
402                 pSh->DelSelectedObj();
403 
404                 if (rReq.IsAPI() ||
405                     GetView().GetEditWin().IsObjectSelect() )
406                 {
407                     // Wenn Basic-Aufruf, dann zurueck in die Textshell, da das
408                     // Basic sonst keine Rueckkehrmoeglichkeit hat.
409                     if (GetView().GetDrawFuncPtr())
410                     {
411                         GetView().GetDrawFuncPtr()->Deactivate();
412                         GetView().SetDrawFuncPtr(NULL);
413                     }
414                     GetView().LeaveDrawCreate();    // In Selektionsmode wechseln
415                 }
416 
417                 if (pSh->IsSelFrmMode())
418                 {
419                     pSh->LeaveSelFrmMode();
420                     // #105852# FME
421 //                   pSh->NoEdit();
422                 }
423                 bNotify = sal_True;
424             }
425             break;
426 
427         case SID_GROUP:
428             if (pSh->IsObjSelected() > 1 && pSh->IsGroupAllowed())
429             {
430                 pSh->GroupSelection();  // Objekt gruppieren
431                 rBind.Invalidate(SID_UNGROUP);
432             }
433             break;
434 
435         case SID_UNGROUP:
436             if (pSh->IsGroupSelected())
437             {
438                 pSh->UnGroupSelection();    // Objektgruppierung aufheben
439                 rBind.Invalidate(SID_GROUP);
440             }
441             break;
442 
443         case SID_ENTER_GROUP:
444             if (pSh->IsGroupSelected())
445             {
446                 pSdrView->EnterMarkedGroup();
447                 rBind.InvalidateAll(sal_False);
448             }
449             break;
450 
451         case SID_LEAVE_GROUP:
452             if (pSdrView->IsGroupEntered())
453             {
454                 pSdrView->LeaveOneGroup();
455                 rBind.Invalidate(SID_ENTER_GROUP);
456                 rBind.Invalidate(SID_UNGROUP);
457             }
458             break;
459 
460         case SID_OBJECT_ALIGN_LEFT:
461         case SID_OBJECT_ALIGN_CENTER:
462         case SID_OBJECT_ALIGN_RIGHT:
463         case SID_OBJECT_ALIGN_UP:
464         case SID_OBJECT_ALIGN_MIDDLE:
465         case SID_OBJECT_ALIGN_DOWN:
466         {
467             if ( bAlignPossible )
468             {
469                 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
470                 if( rMarkList.GetMarkCount() == 1 && bAlignPossible )
471                 {   // Objekte nicht aneinander ausrichten
472 
473                     sal_uInt16 nAnchor = pSh->GetAnchorId();
474                     if (nAnchor == FLY_AS_CHAR)
475                     {
476                         sal_Int16 nVertOrient = -1;
477 
478                         switch (nSlotId)
479                         {
480                             case SID_OBJECT_ALIGN_UP:
481                                 nVertOrient = text::VertOrientation::TOP;
482                                 break;
483                             case SID_OBJECT_ALIGN_MIDDLE:
484                                 nVertOrient = text::VertOrientation::CENTER;
485                                 break;
486                             case SID_OBJECT_ALIGN_DOWN:
487                                 nVertOrient = text::VertOrientation::BOTTOM;
488                                 break;
489                             default:
490                                 break;
491                         }
492                         if (nVertOrient != -1)
493                         {
494                             pSh->StartAction();
495                             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
496                             SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
497                             SwFmtVertOrient aVOrient((SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
498                             aVOrient.SetVertOrient( nVertOrient );
499                             pFrmFmt->SetFmtAttr(aVOrient);
500                             pSh->EndAction();
501                         }
502                         break;
503                     }
504                     if (nAnchor == FLY_AT_PARA)
505                         break;  // Absatzverankerte Rahmen nicht ausrichten
506                 }
507 
508                 pSh->StartAction();
509                 switch (nSlotId)
510                 {
511                     case SID_OBJECT_ALIGN_LEFT:
512                         pSdrView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
513                         break;
514                     case SID_OBJECT_ALIGN_CENTER:
515                         pSdrView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
516                         break;
517                     case SID_OBJECT_ALIGN_RIGHT:
518                         pSdrView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
519                         break;
520                     case SID_OBJECT_ALIGN_UP:
521                         pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
522                         break;
523                     case SID_OBJECT_ALIGN_MIDDLE:
524                         pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
525                         break;
526                     case SID_OBJECT_ALIGN_DOWN:
527                         pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
528                         break;
529                 }
530                 pSh->EndAction();
531             }
532         }
533         break;
534 
535         case FN_FRAME_UP:
536             bTopParam = sal_False;
537             /* no break */
538         case SID_FRAME_TO_TOP:
539             pSh->SelectionToTop( bTopParam );
540             break;
541 
542         case FN_FRAME_DOWN:
543             bBottomParam = sal_False;
544             /* no break */
545         case SID_FRAME_TO_BOTTOM:
546             pSh->SelectionToBottom( bBottomParam );
547             break;
548 
549         case FN_NAME_SHAPE:
550         {
551             bDone = sal_True;
552 
553             if(1L == pSdrView->GetMarkedObjectCount())
554             {
555                 // #i68101#
556                 SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
557                 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
558                 String aName(pSelected->GetName());
559 
560                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
561                 OSL_ENSURE(pFact, "Dialogdiet fail!");
562                 AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
563                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
564 
565                 pDlg->SetCheckNameHdl(LINK(this, SwDrawBaseShell, CheckGroupShapeNameHdl));
566 
567                 if(RET_OK == pDlg->Execute())
568                 {
569                     pDlg->GetName(aName);
570                     pSelected->SetName(aName);
571                     pSh->SetModified();
572                 }
573 
574                 delete pDlg;
575             }
576 
577             break;
578         }
579 
580         // #i68101#
581         case FN_TITLE_DESCRIPTION_SHAPE:
582         {
583             bDone = sal_True;
584 
585             if(1L == pSdrView->GetMarkedObjectCount())
586             {
587                 SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
588                 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
589                 String aTitle(pSelected->GetTitle());
590                 String aDescription(pSelected->GetDescription());
591 
592                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
593                 OSL_ENSURE(pFact, "Dialogdiet fail!");
594                 AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
595                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
596 
597                 if(RET_OK == pDlg->Execute())
598                 {
599                     pDlg->GetTitle(aTitle);
600                     pDlg->GetDescription(aDescription);
601 
602                     pSelected->SetTitle(aTitle);
603                     pSelected->SetDescription(aDescription);
604 
605                     pSh->SetModified();
606                 }
607 
608                 delete pDlg;
609             }
610 
611             break;
612         }
613 
614         default:
615             DBG_ASSERT(!this, "falscher Dispatcher");
616             return;
617     }
618     if(!bDone)
619     {
620         if(nSlotId >= SID_OBJECT_ALIGN_LEFT && nSlotId <= SID_OBJECT_ALIGN_DOWN)
621             rBind.Invalidate(SID_ATTR_LONG_LRSPACE);
622         if (pSdrView->GetModel()->IsChanged())
623             pSh->SetModified();
624         else if (bChanged)
625             pSdrView->GetModel()->SetChanged(sal_True);
626         // 40220: Nach dem Loeschen von DrawObjekten ueber die API GPF durch Selbstzerstoerung
627         if(bNotify)
628             GetView().AttrChangedNotify(pSh); // ggf Shellwechsel...
629     }
630 }
631 /* -----------------------------27.02.2002 15:27------------------------------
632     Checks whether a given name is allowed for a group shape
633  ---------------------------------------------------------------------------*/
634 IMPL_LINK( SwDrawBaseShell, CheckGroupShapeNameHdl, AbstractSvxNameDialog*, pNameDialog )
635 {
636     SwWrtShell          &rSh = GetShell();
637     SdrView *pSdrView = rSh.GetDrawView();
638     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
639     DBG_ASSERT(rMarkList.GetMarkCount() == 1, "wrong draw selection");
640     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
641     const String sCurrentName = pObj->GetName();
642     String sNewName;
643     pNameDialog->GetName(sNewName);
644     long nRet = 0;
645     if(!sNewName.Len() || sCurrentName == sNewName)
646         nRet = 1;
647     else
648     {
649         nRet = 1;
650         SdrModel* pModel = rSh.getIDocumentDrawModelAccess()->GetDrawModel();
651         // --> OD 2006-03-09 #i51726# - all drawing objects can be named now.
652         // consider also drawing objects inside group objects
653 //        SdrPage* pPage = pModel->GetPage(0);
654 //        sal_uInt32 nCount = pPage->GetObjCount();
655 //        for( sal_uInt32 i=0; i< nCount; i++ )
656 //        {
657 //            SdrObject* pTemp = pPage->GetObj(i);
658 //            if(pObj != pTemp && pTemp->ISA(SdrObjGroup) && pTemp->GetName() == sNewName)
659 //            {
660 //                nRet = 0;
661 //                break;
662 //            }
663 //        }
664         SdrObjListIter aIter( *(pModel->GetPage(0)), IM_DEEPWITHGROUPS );
665         while( aIter.IsMore() )
666         {
667             SdrObject* pTempObj = aIter.Next();
668             if ( pObj != pTempObj && pTempObj->GetName() == sNewName )
669             {
670                 nRet = 0;
671                 break;
672             }
673         }
674         // <--
675     }
676     return nRet;
677 }
678 /*--------------------------------------------------------------------
679     Beschreibung:
680  --------------------------------------------------------------------*/
681 void SwDrawBaseShell::GetState(SfxItemSet& rSet)
682 {
683     SwWrtShell &rSh = GetShell();
684     SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
685     SfxWhichIter aIter( rSet );
686     sal_uInt16 nWhich = aIter.FirstWhich();
687     sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
688 
689     if (!bProtected)    // Im Parent nachsehen
690         bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
691 
692     while( nWhich )
693     {
694         switch( nWhich )
695         {
696             case FN_DRAW_WRAP_DLG:
697             case SID_ATTR_TRANSFORM:
698             case SID_FRAME_TO_TOP:
699             case SID_FRAME_TO_BOTTOM:
700             case FN_FRAME_UP:
701             case FN_FRAME_DOWN:
702             case SID_DELETE:
703             case FN_BACKSPACE:
704                 if( bProtected || !rSh.IsObjSelected() )
705                     rSet.DisableItem( nWhich );
706                 break;
707             case SID_GROUP:
708                 if ( rSh.IsObjSelected() < 2 || bProtected || !rSh.IsGroupAllowed() )
709                     rSet.DisableItem( nWhich );
710                 break;
711             case SID_UNGROUP:
712                 if ( !rSh.IsGroupSelected() || bProtected )
713                     rSet.DisableItem( nWhich );
714                 break;
715             case SID_ENTER_GROUP:
716                 if ( !rSh.IsGroupSelected() )
717                     rSet.DisableItem( nWhich );
718                 break;
719             case SID_LEAVE_GROUP:
720                 if ( !pSdrView->IsGroupEntered() )
721                     rSet.DisableItem( nWhich );
722                 break;
723             case SID_OBJECT_ALIGN_LEFT:
724             case SID_OBJECT_ALIGN_CENTER:
725             case SID_OBJECT_ALIGN_RIGHT:
726             case SID_OBJECT_ALIGN_UP:
727             case SID_OBJECT_ALIGN_MIDDLE:
728             case SID_OBJECT_ALIGN_DOWN:
729             case SID_OBJECT_ALIGN:
730                 if ( !rSh.IsAlignPossible() || bProtected )
731                     rSet.DisableItem( nWhich );
732                 else
733                 {
734                     SfxAllEnumItem aEnumItem(nWhich, USHRT_MAX);
735                     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
736                     //if only one object is selected it can only be vertically
737                     // aligned because it is character bound
738                     if( rMarkList.GetMarkCount() == 1 )
739                     {
740                         aEnumItem.DisableValue(SID_OBJECT_ALIGN_LEFT);
741                         aEnumItem.DisableValue(SID_OBJECT_ALIGN_CENTER);
742                         aEnumItem.DisableValue(SID_OBJECT_ALIGN_RIGHT);
743                     }
744                     rSet.Put(aEnumItem);
745                 }
746                 break;
747 
748             case FN_NAME_SHAPE :
749                 {
750                     if(1L != pSdrView->GetMarkedObjectCount())
751                     {
752                         rSet.DisableItem( nWhich );
753                     }
754                 }
755                 break;
756 
757             // #i68101#
758             case FN_TITLE_DESCRIPTION_SHAPE:
759                 {
760                     const bool bIsWebView(NULL != dynamic_cast<SwWebView*>(&GetView()));
761 
762                     if(!bIsWebView && 1L != pSdrView->GetMarkedObjectCount())
763                     {
764                         rSet.DisableItem( nWhich );
765                     }
766                 }
767                 break;
768         }
769         nWhich = aIter.NextWhich();
770     }
771 }
772 
773 /*--------------------------------------------------------------------
774     Beschreibung:
775  --------------------------------------------------------------------*/
776 
777 
778 sal_Bool SwDrawBaseShell::Disable(SfxItemSet& rSet, sal_uInt16 nWhich)
779 {
780     sal_Bool bDisable = GetShell().IsSelObjProtected(FLYPROTECT_CONTENT);
781 
782     if (bDisable)
783     {
784         if (nWhich)
785             rSet.DisableItem( nWhich );
786         else
787         {
788             SfxWhichIter aIter( rSet );
789             nWhich = aIter.FirstWhich();
790             while (nWhich)
791             {
792                 rSet.DisableItem( nWhich );
793                 nWhich = aIter.NextWhich();
794             }
795         }
796     }
797 
798     return bDisable;
799 }
800 
801 /*-- 09.03.2004 13:15:03---------------------------------------------------
802     Validate of drawing positions
803   -----------------------------------------------------------------------*/
804 IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation )
805 {
806     SwWrtShell *pSh = &GetShell();
807     pValidation->nMinHeight = MINFLY;
808     pValidation->nMinWidth =  MINFLY;
809 
810     SwRect aBoundRect;
811 
812     // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
813     //      aligned to page for fly frame anchored to paragraph or to character.
814     const RndStdIds eAnchorType = static_cast<RndStdIds >(pValidation->nAnchorType);
815     const SwPosition* pCntntPos = 0;
816     SdrView*  pSdrView = pSh->GetDrawView();
817     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
818     if( rMarkList.GetMarkCount() == 1 )
819     {
820         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
821         SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
822         pCntntPos = pFrmFmt->GetAnchor().GetCntntAnchor();
823     }
824 
825     pSh->CalcBoundRect( aBoundRect, eAnchorType,
826                            pValidation->nHRelOrient,
827                            pValidation->nVRelOrient,
828                            pCntntPos,
829                            pValidation->bFollowTextFlow,
830                            pValidation->bMirror, NULL, &pValidation->aPercentSize);
831 
832     sal_Bool bIsInVertical( sal_False );
833     {
834         sal_Bool bRTL;
835         sal_Bool bVertL2R;
836         bIsInVertical = pSh->IsFrmVertical(sal_True, bRTL, bVertL2R);
837     }
838     if(bIsInVertical)
839     {
840         Point aPos(aBoundRect.Pos());
841         long nTmp = aPos.X();
842         aPos.X() = aPos.Y();
843         aPos.Y() = nTmp;
844         Size aSize(aBoundRect.SSize());
845         nTmp = aSize.Width();
846         aSize.Width() = aSize.Height();
847         aSize.Height() = nTmp;
848         aBoundRect.Chg( aPos, aSize );
849         //exchange width/height to enable correct values
850         nTmp = pValidation->nWidth;
851         pValidation->nWidth = pValidation->nHeight;
852         pValidation->nHeight = nTmp;
853     }
854     if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY))
855     {
856         // MinimalPosition
857         pValidation->nMinHPos = aBoundRect.Left();
858         pValidation->nMinVPos = aBoundRect.Top();
859         SwTwips nH = pValidation->nHPos;
860         SwTwips nV = pValidation->nVPos;
861 
862         if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
863         {
864             if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
865             {
866                 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
867                 nH = pValidation->nHPos;
868             }
869             else
870                 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
871         }
872 
873         if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
874             pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
875 
876         if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
877         {
878             if (pValidation->nVertOrient == text::VertOrientation::NONE)
879             {
880                 pValidation->nVPos -= ((pValidation->nVPos + pValidation->nHeight) - aBoundRect.Bottom());
881                 nV = pValidation->nVPos;
882             }
883             else
884                 pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
885         }
886 
887         if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
888             pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
889 
890         if ( pValidation->nVertOrient != text::VertOrientation::NONE )
891             nV = aBoundRect.Top();
892 
893         if ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
894             nH = aBoundRect.Left();
895 
896         pValidation->nMaxHPos   = aBoundRect.Right()  - pValidation->nWidth;
897         pValidation->nMaxHeight = aBoundRect.Bottom() - nV;
898 
899         pValidation->nMaxVPos   = aBoundRect.Bottom() - pValidation->nHeight;
900         pValidation->nMaxWidth  = aBoundRect.Right()  - nH;
901     }
902     else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR))
903     {
904         if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
905         {
906             if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
907             {
908                 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
909             }
910             else
911                 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
912         }
913 
914         // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
915         // and alignment at page areas.
916         const bool bMaxVPosAtBottom = !pValidation->bFollowTextFlow ||
917                                       pValidation->nVRelOrient == text::RelOrientation::PAGE_FRAME ||
918                                       pValidation->nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
919         {
920             SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
921                                     ? aBoundRect.Bottom()
922                                     : aBoundRect.Height() ) -
923                                   pValidation->nHeight;
924             if ( pValidation->nVPos > nTmpMaxVPos )
925             {
926                 if (pValidation->nVertOrient == text::VertOrientation::NONE)
927                 {
928                     pValidation->nVPos = nTmpMaxVPos;
929                 }
930                 else
931                 {
932                     pValidation->nHeight = ( bMaxVPosAtBottom
933                                      ? aBoundRect.Bottom()
934                                      : aBoundRect.Height() ) - pValidation->nVPos;
935                 }
936             }
937         }
938 
939         pValidation->nMinHPos  = aBoundRect.Left();
940         pValidation->nMaxHPos  = aBoundRect.Right() - pValidation->nWidth;
941 
942         pValidation->nMinVPos  = aBoundRect.Top();
943         // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
944         if ( bMaxVPosAtBottom )
945         {
946             pValidation->nMaxVPos  = aBoundRect.Bottom() - pValidation->nHeight;
947         }
948         else
949         {
950             pValidation->nMaxVPos  = aBoundRect.Height() - pValidation->nHeight;
951         }
952 
953         // Maximale Breite Hoehe
954         const SwTwips nH = ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
955                            ? aBoundRect.Left()
956                            : pValidation->nHPos;
957         const SwTwips nV = ( pValidation->nVertOrient != text::VertOrientation::NONE )
958                            ? aBoundRect.Top()
959                            : pValidation->nVPos;
960         pValidation->nMaxHeight  = pValidation->nMaxVPos + pValidation->nHeight - nV;
961         pValidation->nMaxWidth   = pValidation->nMaxHPos + pValidation->nWidth - nH;
962     }
963     else if (eAnchorType == FLY_AS_CHAR)
964     {
965         pValidation->nMinHPos = 0;
966         pValidation->nMaxHPos = 0;
967 
968         pValidation->nMaxHeight = aBoundRect.Height();
969         pValidation->nMaxWidth  = aBoundRect.Width();
970 
971         pValidation->nMaxVPos   = aBoundRect.Height();
972         pValidation->nMinVPos   = -aBoundRect.Height() + pValidation->nHeight;
973         if (pValidation->nMaxVPos < pValidation->nMinVPos)
974         {
975             pValidation->nMinVPos = pValidation->nMaxVPos;
976             pValidation->nMaxVPos = -aBoundRect.Height();
977         }
978     }
979     if(bIsInVertical)
980     {
981         //restore width/height exchange
982         long nTmp = pValidation->nWidth;
983         pValidation->nWidth = pValidation->nHeight;
984         pValidation->nHeight = nTmp;
985     }
986 
987     if (pValidation->nMaxWidth < pValidation->nWidth)
988         pValidation->nWidth = pValidation->nMaxWidth;
989     if (pValidation->nMaxHeight < pValidation->nHeight)
990         pValidation->nHeight = pValidation->nMaxHeight;
991     return 0;
992 }
993 
994 
995 
996 
997