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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24
25 #include <tools/shl.hxx>
26 #include <hintids.hxx>
27 #include <helpid.h>
28 #include <swtypes.hxx>
29 #include <sfx2/objface.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/bindings.hxx>
32 #include <svl/aeitem.hxx>
33 #include <svx/svdview.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <svl/srchitem.hxx>
36 #include <svl/whiter.hxx>
37 #include <svx/swframevalidation.hxx>
38 #include <svx/anchorid.hxx>
39 #include <svx/htmlmode.hxx>
40 #include <uitool.hxx>
41 #include <fmtornt.hxx>
42 #include <cmdid.h>
43 #include <swmodule.hxx>
44 #include <wrtsh.hxx>
45 #include <wview.hxx>
46 #include <edtwin.hxx>
47 #include <viewopt.hxx>
48 #include <dcontact.hxx>
49 #include <frmfmt.hxx>
50 #include <wrap.hxx>
51 #include <drawbase.hxx>
52 #include <drwbassh.hxx>
53 #include <swdtflvr.hxx>
54 #include <svx/svdogrp.hxx>
55 #include <svx/svdpage.hxx>
56 #include <svx/svditer.hxx>
57 #include <shells.hrc>
58 #define SwDrawBaseShell
59 #include <sfx2/msg.hxx>
60 #include <swslots.hxx>
61 #include <svx/svxdlg.hxx>
62 #include <svx/dialogs.hrc>
63 #include "swabstdlg.hxx"
64 #include "dialog.hrc"
65 #include <swundo.hxx>
66 #include <com/sun/star/text/HoriOrientation.hpp>
67 #include <com/sun/star/text/VertOrientation.hpp>
68 #include <com/sun/star/text/RelOrientation.hpp>
69 #include <IDocumentDrawModelAccess.hxx>
70 #include <drawdoc.hxx>
71
72 using namespace ::com::sun::star;
73
74 SFX_IMPL_INTERFACE(SwDrawBaseShell, SwBaseShell, SW_RES(0))
75 {
76 }
77
TYPEINIT1(SwDrawBaseShell,SwBaseShell)78 TYPEINIT1(SwDrawBaseShell,SwBaseShell)
79
80 /*--------------------------------------------------------------------
81 Beschreibung:
82 --------------------------------------------------------------------*/
83
84
85 SwDrawBaseShell::SwDrawBaseShell(SwView &_rView):
86 SwBaseShell( _rView )
87 {
88 GetShell().NoEdit(sal_True);
89
90 SwEditWin& rWin = GetView().GetEditWin();
91
92 rWin.SetBezierMode(SID_BEZIER_MOVE);
93
94 if ( !_rView.GetDrawFuncPtr() )
95 _rView.GetEditWin().StdDrawMode( OBJ_NONE, sal_True );
96
97 SwTransferable::CreateSelection( GetShell() );
98 }
99
100 /*--------------------------------------------------------------------
101 Beschreibung:
102 --------------------------------------------------------------------*/
103
104
~SwDrawBaseShell()105 SwDrawBaseShell::~SwDrawBaseShell()
106 {
107 GetView().ExitDraw();
108 GetShell().Edit();
109 SwTransferable::ClearSelection( GetShell() );
110 }
111
112 /*--------------------------------------------------------------------
113 Beschreibung:
114 --------------------------------------------------------------------*/
115
116
Execute(SfxRequest & rReq)117 void SwDrawBaseShell::Execute(SfxRequest &rReq)
118 {
119 SwWrtShell *pSh = &GetShell();
120 SdrView* pSdrView = pSh->GetDrawView();
121 const SfxItemSet *pArgs = rReq.GetArgs();
122 sal_uInt16 nSlotId = rReq.GetSlot();
123 sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
124 pSdrView->GetModel()->SetChanged(sal_False);
125 const SfxPoolItem* pItem = 0;
126 if(pArgs)
127 pArgs->GetItemState(nSlotId, sal_False, &pItem);
128
129 //Sonderfall Align per Menue
130 if(pItem && nSlotId == SID_OBJECT_ALIGN)
131 {
132 DBG_ASSERT(PTR_CAST(SfxEnumItem, pItem),"SfxEnumItem erwartet");
133 nSlotId = nSlotId + ((const SfxEnumItem*)pItem)->GetValue();
134 nSlotId++;
135 }
136
137 sal_Bool bAlignPossible = pSh->IsAlignPossible();
138
139 sal_Bool bTopParam = sal_True, bBottomParam = sal_True;
140 sal_Bool bNotify = sal_False;
141 sal_Bool bDone = sal_False;
142 SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
143
144 switch (nSlotId)
145 {
146 case FN_DRAW_WRAP_DLG:
147 {
148 if(pSdrView->AreObjectsMarked())
149 {
150 if(!pArgs)
151 {
152 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
153 if( rMarkList.GetMark(0) != 0 )
154 {
155 SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND,
156 RES_ANCHOR, RES_ANCHOR,
157 RES_LR_SPACE, RES_UL_SPACE,
158 SID_HTML_MODE, SID_HTML_MODE,
159 FN_DRAW_WRAP_DLG, FN_DRAW_WRAP_DLG,
160 0);
161
162 aSet.Put(SfxBoolItem(SID_HTML_MODE,
163 0 != ::GetHtmlMode(pSh->GetView().GetDocShell())));
164
165 aSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, pSh->GetLayerId()));
166
167 pSh->GetObjAttr(aSet);
168 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
169 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
170
171 SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, sal_True, RC_DLG_SWWRAPDLG );
172 DBG_ASSERT(pDlg, "Dialogdiet fail!");
173
174 if (pDlg->Execute() == RET_OK)
175 {
176 const SfxPoolItem* pWrapItem;
177 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
178 if(SFX_ITEM_SET == pOutSet->GetItemState(FN_DRAW_WRAP_DLG, sal_False, &pWrapItem))
179 {
180 short nLayer = ((const SfxInt16Item*)pWrapItem)->GetValue();
181 if (nLayer == 1)
182 pSh->SelectionToHeaven();
183 else
184 pSh->SelectionToHell();
185 }
186
187 pSh->SetObjAttr(*pOutSet);
188 }
189 delete pDlg;
190 }
191 }
192 }
193 }
194 break;
195
196 case SID_ATTR_TRANSFORM:
197 {
198 if(pSdrView->AreObjectsMarked())
199 {
200 if(!pArgs)
201 {
202 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
203 if( rMarkList.GetMark(0) != 0 )
204 {
205 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
206 SfxAbstractTabDialog *pDlg=NULL;
207 sal_Bool bCaption = sal_False;
208
209 // Erlaubte Verankerungen:
210 short nAnchor = pSh->GetAnchorId();
211 sal_uInt16 nAllowedAnchors = SVX_OBJ_AT_CNTNT|SVX_OBJ_IN_CNTNT;
212 sal_uInt16 nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
213
214 if( !((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))) )
215 nAllowedAnchors |= SVX_OBJ_PAGE;
216 if ( pSh->IsFlyInFly() )
217 nAllowedAnchors |= SVX_OBJ_AT_FLY;
218
219 if (pObj->GetObjIdentifier() == OBJ_CAPTION )
220 bCaption = sal_True;
221
222 if (bCaption)
223 {
224 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
225 if ( pFact )
226 {
227 AbstractSvxCaptionDialog* pCaptionDlg =
228 pFact->CreateCaptionDialog( NULL, pSdrView, nAllowedAnchors );
229 pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
230 pDlg = pCaptionDlg;
231 DBG_ASSERT(pDlg, "Dialogdiet fail!");
232 }
233 }
234 else
235 {
236 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
237 if ( pFact )
238 {
239
240 AbstractSvxTransformTabDialog* pTransform =
241 pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, nAllowedAnchors );
242 pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
243 pDlg = pTransform;
244 DBG_ASSERT(pDlg, "Dialogdiet fail!");
245 }
246 }
247 SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
248
249 const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
250 SfxItemSet aSet( *aNewAttr.GetPool(), pRange );
251 FieldUnit eMetric = ::GetDfltMetric(0 != dynamic_cast<SwWebView*>(&GetView()));
252 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
253
254 aSet.Put( aNewAttr, sal_False );
255
256 if (bCaption)
257 pSdrView->GetAttributes( aSet );
258
259 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
260 sal_Bool bRTL;
261 sal_Bool bVertL2R;
262 aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, pSh->IsFrmVertical(sal_True, bRTL, bVertL2R)));
263 aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT, bRTL));
264
265 SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
266
267 aSet.Put( pFrmFmt->GetFmtAttr(RES_FOLLOW_TEXT_FLOW) );
268
269 SwFmtVertOrient aVOrient((const SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
270 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, aVOrient.GetVertOrient()));
271 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, aVOrient.GetRelationOrient() ));
272 aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, aVOrient.GetPos()));
273
274 SwFmtHoriOrient aHOrient((const SwFmtHoriOrient&)pFrmFmt->GetFmtAttr(RES_HORI_ORIENT));
275 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, aHOrient.GetHoriOrient()));
276 aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, aHOrient.GetRelationOrient() ));
277 aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, aHOrient.IsPosToggle()));
278 aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos()));
279
280 aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
281
282 pDlg->SetInputSet( &aSet );
283
284 if (pDlg->Execute() == RET_OK)
285 {
286 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
287 pSh->StartAllAction();
288
289 // --> OD 2004-07-14 #i30451#
290 pSh->StartUndo(UNDO_INSFMTATTR);
291
292 pSdrView->SetGeoAttrToMarked(*pOutSet);
293
294 if (bCaption)
295 pSdrView->SetAttributes(*pOutSet);
296
297 sal_Bool bPosCorr =
298 SFX_ITEM_SET != pOutSet->GetItemState(
299 SID_ATTR_TRANSFORM_POS_X, sal_False ) &&
300 SFX_ITEM_SET != pOutSet->GetItemState(
301 SID_ATTR_TRANSFORM_POS_Y, sal_False );
302
303 SfxItemSet aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1);
304
305 bool bSingleSelection = rMarkList.GetMarkCount() == 1;
306
307 const SfxPoolItem* pAnchorItem;
308 if(SFX_ITEM_SET == pOutSet->GetItemState(
309 SID_ATTR_TRANSFORM_ANCHOR, sal_False, &pAnchorItem))
310 {
311 if(!bSingleSelection)
312 pSh->ChgAnchor(((const SfxInt16Item*)pAnchorItem)
313 ->GetValue(), sal_False, bPosCorr );
314 else
315 {
316 SwFmtAnchor aAnchor(pFrmFmt->GetAnchor());
317 aAnchor.SetType((RndStdIds)((const SfxInt16Item*)pAnchorItem)->GetValue());
318 aFrmAttrSet.Put( aAnchor );
319 }
320 }
321 const SfxPoolItem* pHoriOrient = 0;
322 const SfxPoolItem* pHoriRelation = 0;
323 const SfxPoolItem* pHoriPosition = 0;
324 const SfxPoolItem* pHoriMirror = 0;
325 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, sal_False, &pHoriOrient);
326 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, sal_False, &pHoriRelation);
327 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, sal_False, &pHoriPosition);
328 pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, sal_False, &pHoriMirror);
329 if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror)
330 {
331 if(pHoriOrient)
332 aHOrient.SetHoriOrient(
333 static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue());
334 if(pHoriRelation)
335 aHOrient.SetRelationOrient(
336 static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue());
337 if(pHoriPosition)
338 aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue());
339 if(pHoriMirror)
340 aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue());
341 aFrmAttrSet.Put(aHOrient);
342 }
343
344 const SfxPoolItem* pVertOrient = 0;
345 const SfxPoolItem* pVertRelation = 0;
346 const SfxPoolItem* pVertPosition = 0;
347 pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, sal_False, &pVertOrient);
348 pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, sal_False, &pVertRelation);
349 pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, sal_False, &pVertPosition);
350 if(pVertOrient || pVertRelation || pVertPosition )
351 {
352 if(pVertOrient)
353 aVOrient.SetVertOrient(
354 static_cast<const SfxInt16Item*>(pVertOrient)->GetValue());
355 if(pVertRelation)
356 aVOrient.SetRelationOrient(
357 static_cast<const SfxInt16Item*>(pVertRelation)->GetValue());
358 if(pVertPosition)
359 aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue());
360 aFrmAttrSet.Put( aVOrient );
361 }
362 const SfxPoolItem* pFollowItem = 0;
363 pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, sal_False, &pFollowItem);
364 if(pFollowItem)
365 aFrmAttrSet.Put(*pFollowItem);
366
367 if(aFrmAttrSet.Count())
368 pSh->SetDrawingAttr(aFrmAttrSet);
369
370 rBind.InvalidateAll(sal_False);
371
372 // --> OD 2004-07-14 #i30451#
373 pSh->EndUndo( UNDO_INSFMTATTR );
374
375 pSh->EndAllAction();
376 }
377 delete pDlg;
378
379 }
380 }
381 else
382 {
383 pSdrView->SetGeoAttrToMarked( *pArgs );
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(sal_False, "wrong 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 ---------------------------------------------------------------------------*/
IMPL_LINK(SwDrawBaseShell,CheckGroupShapeNameHdl,AbstractSvxNameDialog *,pNameDialog)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 SwDrawModel* 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 --------------------------------------------------------------------*/
GetState(SfxItemSet & rSet)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
GetDrawAttrStateForIFBX(SfxItemSet & rSet)774 void SwDrawBaseShell::GetDrawAttrStateForIFBX( SfxItemSet& rSet )
775 {
776 SwWrtShell *pSh = &GetShell();
777 SdrView* pSdrView = pSh->GetDrawView();
778 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
779 if( rMarkList.GetMark(0) != 0 )
780 {
781 // SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();//OST_IFBX@WL2
782 SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
783 rSet.Put(aNewAttr,false);
784 }
785 }
786
787
Disable(SfxItemSet & rSet,sal_uInt16 nWhich)788 sal_Bool SwDrawBaseShell::Disable(SfxItemSet& rSet, sal_uInt16 nWhich)
789 {
790 sal_Bool bDisable = GetShell().IsSelObjProtected(FLYPROTECT_CONTENT);
791
792 if (bDisable)
793 {
794 if (nWhich)
795 rSet.DisableItem( nWhich );
796 else
797 {
798 SfxWhichIter aIter( rSet );
799 nWhich = aIter.FirstWhich();
800 while (nWhich)
801 {
802 rSet.DisableItem( nWhich );
803 nWhich = aIter.NextWhich();
804 }
805 }
806 }
807
808 return bDisable;
809 }
810
811 /*-- 09.03.2004 13:15:03---------------------------------------------------
812 Validate of drawing positions
813 -----------------------------------------------------------------------*/
IMPL_LINK(SwDrawBaseShell,ValidatePosition,SvxSwFrameValidation *,pValidation)814 IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation )
815 {
816 SwWrtShell *pSh = &GetShell();
817 pValidation->nMinHeight = MINFLY;
818 pValidation->nMinWidth = MINFLY;
819
820 SwRect aBoundRect;
821
822 // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
823 // aligned to page for fly frame anchored to paragraph or to character.
824 const RndStdIds eAnchorType = static_cast<RndStdIds >(pValidation->nAnchorType);
825 const SwPosition* pCntntPos = 0;
826 SdrView* pSdrView = pSh->GetDrawView();
827 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
828 if( rMarkList.GetMarkCount() == 1 )
829 {
830 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
831 SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
832 pCntntPos = pFrmFmt->GetAnchor().GetCntntAnchor();
833 }
834
835 pSh->CalcBoundRect( aBoundRect, eAnchorType,
836 pValidation->nHRelOrient,
837 pValidation->nVRelOrient,
838 pCntntPos,
839 pValidation->bFollowTextFlow,
840 pValidation->bMirror, NULL, &pValidation->aPercentSize);
841
842 sal_Bool bIsInVertical( sal_False );
843 {
844 sal_Bool bRTL;
845 sal_Bool bVertL2R;
846 bIsInVertical = pSh->IsFrmVertical(sal_True, bRTL, bVertL2R);
847 }
848 if(bIsInVertical)
849 {
850 Point aPos(aBoundRect.Pos());
851 long nTmp = aPos.X();
852 aPos.X() = aPos.Y();
853 aPos.Y() = nTmp;
854 Size aSize(aBoundRect.SSize());
855 nTmp = aSize.Width();
856 aSize.Width() = aSize.Height();
857 aSize.Height() = nTmp;
858 aBoundRect.Chg( aPos, aSize );
859 //exchange width/height to enable correct values
860 nTmp = pValidation->nWidth;
861 pValidation->nWidth = pValidation->nHeight;
862 pValidation->nHeight = nTmp;
863 }
864 if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY))
865 {
866 // MinimalPosition
867 pValidation->nMinHPos = aBoundRect.Left();
868 pValidation->nMinVPos = aBoundRect.Top();
869 SwTwips nH = pValidation->nHPos;
870 SwTwips nV = pValidation->nVPos;
871
872 if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
873 {
874 if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
875 {
876 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
877 nH = pValidation->nHPos;
878 }
879 else
880 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
881 }
882
883 if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
884 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
885
886 if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
887 {
888 if (pValidation->nVertOrient == text::VertOrientation::NONE)
889 {
890 pValidation->nVPos -= ((pValidation->nVPos + pValidation->nHeight) - aBoundRect.Bottom());
891 nV = pValidation->nVPos;
892 }
893 else
894 pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
895 }
896
897 if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
898 pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
899
900 if ( pValidation->nVertOrient != text::VertOrientation::NONE )
901 nV = aBoundRect.Top();
902
903 if ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
904 nH = aBoundRect.Left();
905
906 pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth;
907 pValidation->nMaxHeight = aBoundRect.Bottom() - nV;
908
909 pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight;
910 pValidation->nMaxWidth = aBoundRect.Right() - nH;
911 }
912 else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR))
913 {
914 if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
915 {
916 if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
917 {
918 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
919 }
920 else
921 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
922 }
923
924 // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
925 // and alignment at page areas.
926 const bool bMaxVPosAtBottom = !pValidation->bFollowTextFlow ||
927 pValidation->nVRelOrient == text::RelOrientation::PAGE_FRAME ||
928 pValidation->nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
929 {
930 SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
931 ? aBoundRect.Bottom()
932 : aBoundRect.Height() ) -
933 pValidation->nHeight;
934 if ( pValidation->nVPos > nTmpMaxVPos )
935 {
936 if (pValidation->nVertOrient == text::VertOrientation::NONE)
937 {
938 pValidation->nVPos = nTmpMaxVPos;
939 }
940 else
941 {
942 pValidation->nHeight = ( bMaxVPosAtBottom
943 ? aBoundRect.Bottom()
944 : aBoundRect.Height() ) - pValidation->nVPos;
945 }
946 }
947 }
948
949 pValidation->nMinHPos = aBoundRect.Left();
950 pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth;
951
952 pValidation->nMinVPos = aBoundRect.Top();
953 // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
954 if ( bMaxVPosAtBottom )
955 {
956 pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight;
957 }
958 else
959 {
960 pValidation->nMaxVPos = aBoundRect.Height() - pValidation->nHeight;
961 }
962
963 // Maximale Breite Hoehe
964 const SwTwips nH = ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
965 ? aBoundRect.Left()
966 : pValidation->nHPos;
967 const SwTwips nV = ( pValidation->nVertOrient != text::VertOrientation::NONE )
968 ? aBoundRect.Top()
969 : pValidation->nVPos;
970 pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV;
971 pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH;
972 }
973 else if (eAnchorType == FLY_AS_CHAR)
974 {
975 pValidation->nMinHPos = 0;
976 pValidation->nMaxHPos = 0;
977
978 pValidation->nMaxHeight = aBoundRect.Height();
979 pValidation->nMaxWidth = aBoundRect.Width();
980
981 pValidation->nMaxVPos = aBoundRect.Height();
982 pValidation->nMinVPos = -aBoundRect.Height() + pValidation->nHeight;
983 if (pValidation->nMaxVPos < pValidation->nMinVPos)
984 {
985 pValidation->nMinVPos = pValidation->nMaxVPos;
986 pValidation->nMaxVPos = -aBoundRect.Height();
987 }
988 }
989 if(bIsInVertical)
990 {
991 //restore width/height exchange
992 long nTmp = pValidation->nWidth;
993 pValidation->nWidth = pValidation->nHeight;
994 pValidation->nHeight = nTmp;
995 }
996
997 if (pValidation->nMaxWidth < pValidation->nWidth)
998 pValidation->nWidth = pValidation->nMaxWidth;
999 if (pValidation->nMaxHeight < pValidation->nHeight)
1000 pValidation->nHeight = pValidation->nMaxHeight;
1001 return 0;
1002 }
1003