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