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_sd.hxx" 30 31 #include "fuconrec.hxx" 32 #include <svx/svdpagv.hxx> 33 34 35 #include <svx/svxids.hrc> 36 #include <svx/dialogs.hrc> 37 #include <svx/dialmgr.hxx> 38 39 #include "app.hrc" 40 #include <svl/aeitem.hxx> 41 #include <svx/xlnstwit.hxx> 42 #include <svx/xlnedwit.hxx> 43 #include <svx/xlnedit.hxx> 44 #include <svx/xlnstit.hxx> 45 #include <svx/xlnwtit.hxx> 46 #include <sfx2/viewfrm.hxx> 47 #include <svx/sdtmfitm.hxx> 48 #include <svx/sxekitm.hxx> 49 #include <svx/sderitm.hxx> 50 #include <sfx2/dispatch.hxx> 51 #include <svx/svdopath.hxx> 52 #include <svx/svdocirc.hxx> 53 #include <svl/intitem.hxx> 54 #include <sfx2/request.hxx> 55 #include <editeng/adjitem.hxx> 56 #include <svx/xtable.hxx> 57 58 // #88751# 59 #include <svx/svdocapt.hxx> 60 61 // #97016# 62 #include <svx/svdomeas.hxx> 63 #include "ViewShell.hxx" 64 #include "ViewShellBase.hxx" 65 #include "ToolBarManager.hxx" 66 // #109583# 67 #include <editeng/writingmodeitem.hxx> 68 #include <basegfx/polygon/b2dpolygontools.hxx> 69 #include <basegfx/polygon/b2dpolygon.hxx> 70 71 #include "sdresid.hxx" 72 #include "View.hxx" 73 #include "sdpage.hxx" 74 #include "Window.hxx" 75 #include "stlpool.hxx" 76 #include "drawdoc.hxx" 77 #include "res_bmp.hrc" 78 #include "glob.hrc" 79 80 namespace sd { 81 82 TYPEINIT1( FuConstructRectangle, FuConstruct ); 83 84 /************************************************************************* 85 |* 86 |* Konstruktor 87 |* 88 \************************************************************************/ 89 90 FuConstructRectangle::FuConstructRectangle ( 91 ViewShell* pViewSh, 92 ::sd::Window* pWin, 93 ::sd::View* pView, 94 SdDrawDocument* pDoc, 95 SfxRequest& rReq) 96 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq) 97 { 98 } 99 100 FunctionReference FuConstructRectangle::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent ) 101 { 102 FuConstructRectangle* pFunc; 103 FunctionReference xFunc( pFunc = new FuConstructRectangle( pViewSh, pWin, pView, pDoc, rReq ) ); 104 xFunc->DoExecute(rReq); 105 pFunc->SetPermanent(bPermanent); 106 return xFunc; 107 } 108 109 void FuConstructRectangle::DoExecute( SfxRequest& rReq ) 110 { 111 FuConstruct::DoExecute( rReq ); 112 113 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar( 114 ToolBarManager::TBG_FUNCTION, 115 ToolBarManager::msDrawingObjectToolBar); 116 117 const SfxItemSet *pArgs = rReq.GetArgs (); 118 119 if (pArgs) 120 { 121 switch (nSlotId) 122 { 123 case SID_DRAW_ELLIPSE : 124 { 125 SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, sal_False); 126 SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, sal_False); 127 SFX_REQUEST_ARG (rReq, pAxisX, SfxUInt32Item, ID_VAL_AXIS_X, sal_False); 128 SFX_REQUEST_ARG (rReq, pAxisY, SfxUInt32Item, ID_VAL_AXIS_Y, sal_False); 129 130 Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2, 131 pCenterY->GetValue () - pAxisY->GetValue () / 2, 132 pCenterX->GetValue () + pAxisX->GetValue () / 2, 133 pCenterY->GetValue () + pAxisY->GetValue () / 2); 134 SdrCircObj *pNewCircle = new SdrCircObj (OBJ_CIRC, aNewRectangle); 135 SdrPageView *pPV = mpView->GetSdrPageView(); 136 137 mpView->InsertObjectAtView(pNewCircle, *pPV, SDRINSERT_SETDEFLAYER | SDRINSERT_SETDEFATTR); 138 } 139 break; 140 141 case SID_DRAW_RECT : 142 { 143 SFX_REQUEST_ARG (rReq, pMouseStartX, SfxUInt32Item, ID_VAL_MOUSESTART_X, sal_False); 144 SFX_REQUEST_ARG (rReq, pMouseStartY, SfxUInt32Item, ID_VAL_MOUSESTART_Y, sal_False); 145 SFX_REQUEST_ARG (rReq, pMouseEndX, SfxUInt32Item, ID_VAL_MOUSEEND_X, sal_False); 146 SFX_REQUEST_ARG (rReq, pMouseEndY, SfxUInt32Item, ID_VAL_MOUSEEND_Y, sal_False); 147 148 Rectangle aNewRectangle (pMouseStartX->GetValue (), 149 pMouseStartY->GetValue (), 150 pMouseEndX->GetValue (), 151 pMouseEndY->GetValue ()); 152 SdrRectObj *pNewRect = new SdrRectObj (aNewRectangle); 153 SdrPageView *pPV = mpView->GetSdrPageView(); 154 155 mpView->InsertObjectAtView(pNewRect, *pPV, SDRINSERT_SETDEFLAYER | SDRINSERT_SETDEFATTR); 156 } 157 break; 158 } 159 } 160 161 if (nSlotId == SID_TOOL_CONNECTOR || 162 nSlotId == SID_CONNECTOR_ARROW_START || 163 nSlotId == SID_CONNECTOR_ARROW_END || 164 nSlotId == SID_CONNECTOR_ARROWS || 165 nSlotId == SID_CONNECTOR_CIRCLE_START || 166 nSlotId == SID_CONNECTOR_CIRCLE_END || 167 nSlotId == SID_CONNECTOR_CIRCLES || 168 nSlotId == SID_CONNECTOR_LINE || 169 nSlotId == SID_CONNECTOR_LINE_ARROW_START || 170 nSlotId == SID_CONNECTOR_LINE_ARROW_END || 171 nSlotId == SID_CONNECTOR_LINE_ARROWS || 172 nSlotId == SID_CONNECTOR_LINE_CIRCLE_START || 173 nSlotId == SID_CONNECTOR_LINE_CIRCLE_END || 174 nSlotId == SID_CONNECTOR_LINE_CIRCLES || 175 nSlotId == SID_CONNECTOR_CURVE || 176 nSlotId == SID_CONNECTOR_CURVE_ARROW_START || 177 nSlotId == SID_CONNECTOR_CURVE_ARROW_END || 178 nSlotId == SID_CONNECTOR_CURVE_ARROWS || 179 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START || 180 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END || 181 nSlotId == SID_CONNECTOR_CURVE_CIRCLES || 182 nSlotId == SID_CONNECTOR_LINES || 183 nSlotId == SID_CONNECTOR_LINES_ARROW_START || 184 nSlotId == SID_CONNECTOR_LINES_ARROW_END || 185 nSlotId == SID_CONNECTOR_LINES_ARROWS || 186 nSlotId == SID_CONNECTOR_LINES_CIRCLE_START || 187 nSlotId == SID_CONNECTOR_LINES_CIRCLE_END || 188 nSlotId == SID_CONNECTOR_LINES_CIRCLES || 189 nSlotId == SID_LINE_ARROW_START || 190 nSlotId == SID_LINE_ARROW_END || 191 nSlotId == SID_LINE_ARROWS || 192 nSlotId == SID_LINE_ARROW_CIRCLE || 193 nSlotId == SID_LINE_CIRCLE_ARROW || 194 nSlotId == SID_LINE_ARROW_SQUARE || 195 nSlotId == SID_LINE_SQUARE_ARROW ) 196 { 197 mpView->UnmarkAll(); 198 } 199 } 200 201 /************************************************************************* 202 |* 203 |* MouseButtonDown-event 204 |* 205 \************************************************************************/ 206 207 sal_Bool FuConstructRectangle::MouseButtonDown(const MouseEvent& rMEvt) 208 { 209 sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt); 210 211 if ( rMEvt.IsLeft() && !mpView->IsAction() ) 212 { 213 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 214 215 mpWindow->CaptureMouse(); 216 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() ); 217 218 if (mpView->GetCurrentObjIdentifier() == OBJ_CAPTION) 219 { 220 Size aCaptionSize(846, 846); // (4x2)cm 221 bReturn = mpView->BegCreateCaptionObj(aPnt, aCaptionSize, 222 (OutputDevice*) NULL, nDrgLog); 223 } 224 else 225 { 226 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog); 227 } 228 229 SdrObject* pObj = mpView->GetCreateObj(); 230 231 if (pObj) 232 { 233 SfxItemSet aAttr(mpDoc->GetPool()); 234 SetStyleSheet(aAttr, pObj); 235 SetAttributes(aAttr, pObj); 236 SetLineEnds(aAttr, pObj); 237 pObj->SetMergedItemSet(aAttr); 238 239 if( nSlotId == SID_DRAW_CAPTION_VERTICAL ) 240 ( (SdrTextObj*) pObj)->SetVerticalWriting( sal_True ); 241 } 242 } 243 return bReturn; 244 } 245 246 /************************************************************************* 247 |* 248 |* MouseMove-event 249 |* 250 \************************************************************************/ 251 252 sal_Bool FuConstructRectangle::MouseMove(const MouseEvent& rMEvt) 253 { 254 return FuConstruct::MouseMove(rMEvt); 255 } 256 257 /************************************************************************* 258 |* 259 |* MouseButtonUp-event 260 |* 261 \************************************************************************/ 262 263 sal_Bool FuConstructRectangle::MouseButtonUp(const MouseEvent& rMEvt) 264 { 265 sal_Bool bReturn(sal_False); 266 267 if(mpView->IsCreateObj() && rMEvt.IsLeft()) 268 { 269 SdrObject* pObj = mpView->GetCreateObj(); 270 271 if(pObj && mpView->EndCreateObj(SDRCREATE_FORCEEND)) 272 { 273 if(SID_DRAW_MEASURELINE == nSlotId) 274 { 275 SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin(); 276 String aStr(SdResId(STR_LAYER_MEASURELINES)); 277 pObj->SetLayer(rAdmin.GetLayerID(aStr, sal_False)); 278 } 279 280 // #88751# init text position when vertica caption object is created 281 if(pObj->ISA(SdrCaptionObj) && SID_DRAW_CAPTION_VERTICAL == nSlotId) 282 { 283 // draw text object, needs to be initialized when vertical text is used 284 SfxItemSet aSet(pObj->GetMergedItemSet()); 285 286 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); 287 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); 288 289 // #109583# 290 // Correct the value of SDRATTR_TEXTDIRECTION to avoid SetItemSet 291 // calling SetVerticalWriting() again since this item may not yet 292 // be set at the object and thus may differ from verical state of 293 // the object. 294 aSet.Put(SvxWritingModeItem(com::sun::star::text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION)); 295 pObj->SetMergedItemSet(aSet); 296 } 297 298 bReturn = sal_True; 299 } 300 } 301 302 bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn; 303 304 if (!bPermanent) 305 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 306 307 return bReturn; 308 } 309 310 /************************************************************************* 311 |* 312 |* Tastaturereignisse bearbeiten 313 |* 314 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 315 |* sal_False. 316 |* 317 \************************************************************************/ 318 319 sal_Bool FuConstructRectangle::KeyInput(const KeyEvent& rKEvt) 320 { 321 sal_Bool bReturn = FuConstruct::KeyInput(rKEvt); 322 return(bReturn); 323 } 324 325 /************************************************************************* 326 |* 327 |* Function aktivieren 328 |* 329 \************************************************************************/ 330 331 void FuConstructRectangle::Activate() 332 { 333 SdrObjKind aObjKind; 334 335 switch (nSlotId) 336 { 337 case SID_LINE_ARROW_START: 338 case SID_LINE_ARROW_END: 339 case SID_LINE_ARROWS: 340 case SID_LINE_ARROW_CIRCLE: 341 case SID_LINE_CIRCLE_ARROW: 342 case SID_LINE_ARROW_SQUARE: 343 case SID_LINE_SQUARE_ARROW: 344 mpView->SetGlueVisible(); 345 // keine break ! 346 case SID_DRAW_LINE : 347 case SID_DRAW_XLINE: 348 aObjKind = OBJ_LINE; 349 break; 350 351 case SID_DRAW_MEASURELINE: 352 { 353 aObjKind = OBJ_MEASURE; 354 } 355 break; 356 357 case SID_DRAW_RECT : 358 case SID_DRAW_RECT_NOFILL : 359 case SID_DRAW_RECT_ROUND : 360 case SID_DRAW_RECT_ROUND_NOFILL: 361 case SID_DRAW_SQUARE : 362 case SID_DRAW_SQUARE_NOFILL : 363 case SID_DRAW_SQUARE_ROUND : 364 case SID_DRAW_SQUARE_ROUND_NOFILL: 365 { 366 aObjKind = OBJ_RECT; 367 } 368 break; 369 370 case SID_DRAW_ELLIPSE : 371 case SID_DRAW_ELLIPSE_NOFILL: 372 case SID_DRAW_CIRCLE : 373 case SID_DRAW_CIRCLE_NOFILL : 374 { 375 aObjKind = OBJ_CIRC; 376 } 377 break; 378 379 case SID_DRAW_CAPTION: 380 case SID_DRAW_CAPTION_VERTICAL: 381 { 382 aObjKind = OBJ_CAPTION; 383 } 384 break; 385 386 case SID_TOOL_CONNECTOR: 387 case SID_CONNECTOR_ARROW_START: 388 case SID_CONNECTOR_ARROW_END: 389 case SID_CONNECTOR_ARROWS: 390 case SID_CONNECTOR_CIRCLE_START: 391 case SID_CONNECTOR_CIRCLE_END: 392 case SID_CONNECTOR_CIRCLES: 393 case SID_CONNECTOR_LINE: 394 case SID_CONNECTOR_LINE_ARROW_START: 395 case SID_CONNECTOR_LINE_ARROW_END: 396 case SID_CONNECTOR_LINE_ARROWS: 397 case SID_CONNECTOR_LINE_CIRCLE_START: 398 case SID_CONNECTOR_LINE_CIRCLE_END: 399 case SID_CONNECTOR_LINE_CIRCLES: 400 case SID_CONNECTOR_CURVE: 401 case SID_CONNECTOR_CURVE_ARROW_START: 402 case SID_CONNECTOR_CURVE_ARROW_END: 403 case SID_CONNECTOR_CURVE_ARROWS: 404 case SID_CONNECTOR_CURVE_CIRCLE_START: 405 case SID_CONNECTOR_CURVE_CIRCLE_END: 406 case SID_CONNECTOR_CURVE_CIRCLES: 407 case SID_CONNECTOR_LINES: 408 case SID_CONNECTOR_LINES_ARROW_START: 409 case SID_CONNECTOR_LINES_ARROW_END: 410 case SID_CONNECTOR_LINES_ARROWS: 411 case SID_CONNECTOR_LINES_CIRCLE_START: 412 case SID_CONNECTOR_LINES_CIRCLE_END: 413 case SID_CONNECTOR_LINES_CIRCLES: 414 { 415 aObjKind = OBJ_EDGE; 416 mpView->SetGlueVisible(); 417 } 418 break; 419 420 default: 421 { 422 aObjKind = OBJ_RECT; 423 } 424 break; 425 } 426 427 mpView->SetCurrentObj((sal_uInt16)aObjKind); 428 429 FuConstruct::Activate(); 430 } 431 432 /************************************************************************* 433 |* 434 |* Function deaktivieren 435 |* 436 \************************************************************************/ 437 438 void FuConstructRectangle::Deactivate() 439 { 440 if( nSlotId == SID_TOOL_CONNECTOR || 441 nSlotId == SID_CONNECTOR_ARROW_START || 442 nSlotId == SID_CONNECTOR_ARROW_END || 443 nSlotId == SID_CONNECTOR_ARROWS || 444 nSlotId == SID_CONNECTOR_CIRCLE_START || 445 nSlotId == SID_CONNECTOR_CIRCLE_END || 446 nSlotId == SID_CONNECTOR_CIRCLES || 447 nSlotId == SID_CONNECTOR_LINE || 448 nSlotId == SID_CONNECTOR_LINE_ARROW_START || 449 nSlotId == SID_CONNECTOR_LINE_ARROW_END || 450 nSlotId == SID_CONNECTOR_LINE_ARROWS || 451 nSlotId == SID_CONNECTOR_LINE_CIRCLE_START || 452 nSlotId == SID_CONNECTOR_LINE_CIRCLE_END || 453 nSlotId == SID_CONNECTOR_LINE_CIRCLES || 454 nSlotId == SID_CONNECTOR_CURVE || 455 nSlotId == SID_CONNECTOR_CURVE_ARROW_START || 456 nSlotId == SID_CONNECTOR_CURVE_ARROW_END || 457 nSlotId == SID_CONNECTOR_CURVE_ARROWS || 458 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START || 459 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END || 460 nSlotId == SID_CONNECTOR_CURVE_CIRCLES || 461 nSlotId == SID_CONNECTOR_LINES || 462 nSlotId == SID_CONNECTOR_LINES_ARROW_START || 463 nSlotId == SID_CONNECTOR_LINES_ARROW_END || 464 nSlotId == SID_CONNECTOR_LINES_ARROWS || 465 nSlotId == SID_CONNECTOR_LINES_CIRCLE_START || 466 nSlotId == SID_CONNECTOR_LINES_CIRCLE_END || 467 nSlotId == SID_CONNECTOR_LINES_CIRCLES || 468 nSlotId == SID_LINE_ARROW_START || 469 nSlotId == SID_LINE_ARROW_END || 470 nSlotId == SID_LINE_ARROWS || 471 nSlotId == SID_LINE_ARROW_CIRCLE || 472 nSlotId == SID_LINE_CIRCLE_ARROW || 473 nSlotId == SID_LINE_ARROW_SQUARE || 474 nSlotId == SID_LINE_SQUARE_ARROW ) 475 { 476 mpView->SetGlueVisible( sal_False ); 477 } 478 FuConstruct::Deactivate(); 479 } 480 481 482 /************************************************************************* 483 |* 484 |* Attribute fuer das zu erzeugende Objekt setzen 485 |* 486 \************************************************************************/ 487 488 void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj) 489 { 490 if (nSlotId == SID_DRAW_RECT_ROUND || 491 nSlotId == SID_DRAW_RECT_ROUND_NOFILL || 492 nSlotId == SID_DRAW_SQUARE_ROUND || 493 nSlotId == SID_DRAW_SQUARE_ROUND_NOFILL) 494 { 495 /********************************************************************** 496 * Abgerundete Ecken 497 **********************************************************************/ 498 rAttr.Put(SdrEckenradiusItem(500)); 499 } 500 else if (nSlotId == SID_CONNECTOR_LINE || 501 nSlotId == SID_CONNECTOR_LINE_ARROW_START || 502 nSlotId == SID_CONNECTOR_LINE_ARROW_END || 503 nSlotId == SID_CONNECTOR_LINE_ARROWS || 504 nSlotId == SID_CONNECTOR_LINE_CIRCLE_START || 505 nSlotId == SID_CONNECTOR_LINE_CIRCLE_END || 506 nSlotId == SID_CONNECTOR_LINE_CIRCLES) 507 { 508 /********************************************************************** 509 * Direkt-Verbinder 510 **********************************************************************/ 511 rAttr.Put(SdrEdgeKindItem(SDREDGE_ONELINE)); 512 } 513 else if (nSlotId == SID_CONNECTOR_LINES || 514 nSlotId == SID_CONNECTOR_LINES_ARROW_START || 515 nSlotId == SID_CONNECTOR_LINES_ARROW_END || 516 nSlotId == SID_CONNECTOR_LINES_ARROWS || 517 nSlotId == SID_CONNECTOR_LINES_CIRCLE_START || 518 nSlotId == SID_CONNECTOR_LINES_CIRCLE_END || 519 nSlotId == SID_CONNECTOR_LINES_CIRCLES) 520 { 521 /********************************************************************** 522 * Linien-Verbinder 523 **********************************************************************/ 524 rAttr.Put(SdrEdgeKindItem(SDREDGE_THREELINES)); 525 } 526 else if (nSlotId == SID_CONNECTOR_CURVE || 527 nSlotId == SID_CONNECTOR_CURVE_ARROW_START || 528 nSlotId == SID_CONNECTOR_CURVE_ARROW_END || 529 nSlotId == SID_CONNECTOR_CURVE_ARROWS || 530 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START || 531 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END || 532 nSlotId == SID_CONNECTOR_CURVE_CIRCLES) 533 { 534 /********************************************************************** 535 * Kurven-Verbinder 536 **********************************************************************/ 537 rAttr.Put(SdrEdgeKindItem(SDREDGE_BEZIER)); 538 } 539 else if ( nSlotId == SID_DRAW_CAPTION || nSlotId == SID_DRAW_CAPTION_VERTICAL ) 540 { 541 /********************************************************************** 542 * Legendenobjekt 543 **********************************************************************/ 544 Size aSize(pObj->GetLogicRect().GetSize()); 545 rAttr.Put( SdrTextMinFrameHeightItem( aSize.Height() ) ); 546 rAttr.Put( SdrTextMinFrameWidthItem( aSize.Width() ) ); 547 rAttr.Put( SdrTextAutoGrowHeightItem( sal_True ) ); 548 rAttr.Put( SdrTextAutoGrowWidthItem( sal_True ) ); 549 550 // #103516# Support full with for vertical caption objects, too 551 if(SID_DRAW_CAPTION == nSlotId) 552 rAttr.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); 553 else 554 rAttr.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_BLOCK ) ); 555 556 rAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); 557 rAttr.Put( SdrTextLeftDistItem( 100 ) ); 558 rAttr.Put( SdrTextRightDistItem( 100 ) ); 559 rAttr.Put( SdrTextUpperDistItem( 100 ) ); 560 rAttr.Put( SdrTextLowerDistItem( 100 ) ); 561 } 562 else if (nSlotId == SID_DRAW_MEASURELINE) 563 { 564 /********************************************************************** 565 * Masslinie 566 **********************************************************************/ 567 SdPage* pPage = (SdPage*) mpView->GetSdrPageView()->GetPage(); 568 String aName(SdResId(STR_POOLSHEET_MEASURE)); 569 SfxStyleSheet* pSheet = (SfxStyleSheet*) pPage->GetModel()-> 570 GetStyleSheetPool()-> 571 Find(aName, SD_STYLE_FAMILY_GRAPHICS); 572 DBG_ASSERT(pSheet, "Objektvorlage nicht gefunden"); 573 574 if (pSheet) 575 { 576 pObj->SetStyleSheet(pSheet, sal_False); 577 } 578 579 SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin(); 580 String aStr(SdResId(STR_LAYER_MEASURELINES)); 581 pObj->SetLayer(rAdmin.GetLayerID(aStr, sal_False)); 582 } 583 else if (nSlotId == OBJ_CUSTOMSHAPE ) 584 { 585 } 586 } 587 588 589 /************************************************************************* 590 |* 591 |* Linienanfaenge und -enden fuer das zu erzeugende Objekt setzen 592 |* 593 \************************************************************************/ 594 595 ::basegfx::B2DPolyPolygon getPolygon( sal_uInt16 nResId, SdrModel* pDoc ) 596 { 597 ::basegfx::B2DPolyPolygon aRetval; 598 XLineEndList* pLineEndList = pDoc->GetLineEndList(); 599 600 if( pLineEndList ) 601 { 602 String aArrowName( SVX_RES(nResId) ); 603 long nCount = pLineEndList->Count(); 604 long nIndex; 605 for( nIndex = 0L; nIndex < nCount; nIndex++ ) 606 { 607 XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nIndex); 608 if( pEntry->GetName() == aArrowName ) 609 { 610 aRetval = pEntry->GetLineEnd(); 611 break; 612 } 613 } 614 } 615 616 return aRetval; 617 } 618 619 void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject* pObj) 620 { 621 if ( (pObj->GetObjIdentifier() == OBJ_EDGE && 622 nSlotId != SID_TOOL_CONNECTOR && 623 nSlotId != SID_CONNECTOR_LINE && 624 nSlotId != SID_CONNECTOR_LINES && 625 nSlotId != SID_CONNECTOR_CURVE) || 626 nSlotId == SID_LINE_ARROW_START || 627 nSlotId == SID_LINE_ARROW_END || 628 nSlotId == SID_LINE_ARROWS || 629 nSlotId == SID_LINE_ARROW_CIRCLE || 630 nSlotId == SID_LINE_CIRCLE_ARROW || 631 nSlotId == SID_LINE_ARROW_SQUARE || 632 nSlotId == SID_LINE_SQUARE_ARROW ) 633 { 634 /************************************************************** 635 * Linienanfaenge und -enden attributieren 636 **************************************************************/ 637 638 // Pfeilspitze 639 ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, mpDoc ) ); 640 if( !aArrow.count() ) 641 { 642 ::basegfx::B2DPolygon aNewArrow; 643 aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0)); 644 aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0)); 645 aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0)); 646 aNewArrow.setClosed(true); 647 aArrow.append(aNewArrow); 648 } 649 650 // Kreis 651 ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, mpDoc ) ); 652 if( !aCircle.count() ) 653 { 654 ::basegfx::B2DPolygon aNewCircle; 655 aNewCircle = ::basegfx::tools::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0); 656 aNewCircle.setClosed(true); 657 aCircle.append(aNewCircle); 658 } 659 660 // Quadrat 661 ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, mpDoc ) ); 662 if( !aSquare.count() ) 663 { 664 ::basegfx::B2DPolygon aNewSquare; 665 aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0)); 666 aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0)); 667 aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0)); 668 aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0)); 669 aNewSquare.setClosed(true); 670 aSquare.append(aNewSquare); 671 } 672 673 SfxItemSet aSet( mpDoc->GetPool() ); 674 mpView->GetAttributes( aSet ); 675 676 // #i3908# Here, the default Line Start/End width for arrow construction is 677 // set. To have the same value in all situations (construction) in i3908 678 // it was decided to change the default to 0.03 cm for all situations. 679 long nWidth = 300; // (1/100th mm) 680 681 // Linienstaerke ermitteln und daraus die Linienendenstaerke berechnen 682 if( aSet.GetItemState( XATTR_LINEWIDTH ) != SFX_ITEM_DONTCARE ) 683 { 684 long nValue = ( ( const XLineWidthItem& ) aSet.Get( XATTR_LINEWIDTH ) ).GetValue(); 685 if( nValue > 0 ) 686 nWidth = nValue * 3; 687 } 688 689 switch (nSlotId) 690 { 691 case SID_CONNECTOR_ARROWS: 692 case SID_CONNECTOR_LINE_ARROWS: 693 case SID_CONNECTOR_LINES_ARROWS: 694 case SID_CONNECTOR_CURVE_ARROWS: 695 case SID_LINE_ARROWS: 696 { 697 // Verbinder mit Pfeil-Enden 698 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); 699 rAttr.Put(XLineStartWidthItem(nWidth)); 700 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); 701 rAttr.Put(XLineEndWidthItem(nWidth)); 702 } 703 break; 704 705 case SID_CONNECTOR_ARROW_START: 706 case SID_CONNECTOR_LINE_ARROW_START: 707 case SID_CONNECTOR_LINES_ARROW_START: 708 case SID_CONNECTOR_CURVE_ARROW_START: 709 case SID_LINE_ARROW_START: 710 case SID_LINE_ARROW_CIRCLE: 711 case SID_LINE_ARROW_SQUARE: 712 { 713 // Verbinder mit Pfeil-Anfang 714 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); 715 rAttr.Put(XLineStartWidthItem(nWidth)); 716 } 717 break; 718 719 case SID_CONNECTOR_ARROW_END: 720 case SID_CONNECTOR_LINE_ARROW_END: 721 case SID_CONNECTOR_LINES_ARROW_END: 722 case SID_CONNECTOR_CURVE_ARROW_END: 723 case SID_LINE_ARROW_END: 724 case SID_LINE_CIRCLE_ARROW: 725 case SID_LINE_SQUARE_ARROW: 726 { 727 // Verbinder mit Pfeil-Ende 728 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); 729 rAttr.Put(XLineEndWidthItem(nWidth)); 730 } 731 break; 732 733 case SID_CONNECTOR_CIRCLES: 734 case SID_CONNECTOR_LINE_CIRCLES: 735 case SID_CONNECTOR_LINES_CIRCLES: 736 case SID_CONNECTOR_CURVE_CIRCLES: 737 { 738 // Verbinder mit Kreis-Enden 739 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); 740 rAttr.Put(XLineStartWidthItem(nWidth)); 741 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); 742 rAttr.Put(XLineEndWidthItem(nWidth)); 743 } 744 break; 745 746 case SID_CONNECTOR_CIRCLE_START: 747 case SID_CONNECTOR_LINE_CIRCLE_START: 748 case SID_CONNECTOR_LINES_CIRCLE_START: 749 case SID_CONNECTOR_CURVE_CIRCLE_START: 750 { 751 // Verbinder mit Kreis-Anfang 752 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); 753 rAttr.Put(XLineStartWidthItem(nWidth)); 754 } 755 break; 756 757 case SID_CONNECTOR_CIRCLE_END: 758 case SID_CONNECTOR_LINE_CIRCLE_END: 759 case SID_CONNECTOR_LINES_CIRCLE_END: 760 case SID_CONNECTOR_CURVE_CIRCLE_END: 761 { 762 // Verbinder mit Kreis-Ende 763 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); 764 rAttr.Put(XLineEndWidthItem(nWidth)); 765 } 766 break; 767 }; 768 769 // Und nochmal fuer die noch fehlenden Enden 770 switch (nSlotId) 771 { 772 case SID_LINE_ARROW_CIRCLE: 773 { 774 // Kreis-Ende 775 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); 776 rAttr.Put(XLineEndWidthItem(nWidth)); 777 } 778 break; 779 780 case SID_LINE_CIRCLE_ARROW: 781 { 782 // Kreis-Anfang 783 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); 784 rAttr.Put(XLineStartWidthItem(nWidth)); 785 } 786 break; 787 788 case SID_LINE_ARROW_SQUARE: 789 { 790 // Quadrat-Ende 791 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_SQUARE), aSquare)); 792 rAttr.Put(XLineEndWidthItem(nWidth)); 793 } 794 break; 795 796 case SID_LINE_SQUARE_ARROW: 797 { 798 // Quadrat-Anfang 799 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_SQUARE), aSquare)); 800 rAttr.Put(XLineStartWidthItem(nWidth)); 801 } 802 break; 803 } 804 } 805 } 806 807 // #97016# 808 SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) 809 { 810 DBG_ASSERT( (nID != SID_DRAW_FONTWORK) && (nID != SID_DRAW_FONTWORK_VERTICAL ), "FuConstRectangle::CreateDefaultObject can not create Fontwork shapes!" ); 811 812 // case SID_DRAW_LINE: 813 // case SID_DRAW_XLINE: 814 // case SID_DRAW_MEASURELINE: 815 // case SID_LINE_ARROW_START: 816 // case SID_LINE_ARROW_END: 817 // case SID_LINE_ARROWS: 818 // case SID_LINE_ARROW_CIRCLE: 819 // case SID_LINE_CIRCLE_ARROW: 820 // case SID_LINE_ARROW_SQUARE: 821 // case SID_LINE_SQUARE_ARROW: 822 // case SID_DRAW_RECT: 823 // case SID_DRAW_RECT_NOFILL: 824 // case SID_DRAW_RECT_ROUND: 825 // case SID_DRAW_RECT_ROUND_NOFILL: 826 // case SID_DRAW_SQUARE: 827 // case SID_DRAW_SQUARE_NOFILL: 828 // case SID_DRAW_SQUARE_ROUND: 829 // case SID_DRAW_SQUARE_ROUND_NOFILL: 830 // case SID_DRAW_ELLIPSE: 831 // case SID_DRAW_ELLIPSE_NOFILL: 832 // case SID_DRAW_CIRCLE: 833 // case SID_DRAW_CIRCLE_NOFILL: 834 // case SID_DRAW_CAPTION: 835 // case SID_DRAW_CAPTION_VERTICAL: 836 // case SID_TOOL_CONNECTOR: 837 // case SID_CONNECTOR_ARROW_START: 838 // case SID_CONNECTOR_ARROW_END: 839 // case SID_CONNECTOR_ARROWS: 840 // case SID_CONNECTOR_CIRCLE_START: 841 // case SID_CONNECTOR_CIRCLE_END: 842 // case SID_CONNECTOR_CIRCLES: 843 // case SID_CONNECTOR_LINE: 844 // case SID_CONNECTOR_LINE_ARROW_START: 845 // case SID_CONNECTOR_LINE_ARROW_END: 846 // case SID_CONNECTOR_LINE_ARROWS: 847 // case SID_CONNECTOR_LINE_CIRCLE_START: 848 // case SID_CONNECTOR_LINE_CIRCLE_END: 849 // case SID_CONNECTOR_LINE_CIRCLES: 850 // case SID_CONNECTOR_CURVE: 851 // case SID_CONNECTOR_CURVE_ARROW_START: 852 // case SID_CONNECTOR_CURVE_ARROW_END: 853 // case SID_CONNECTOR_CURVE_ARROWS: 854 // case SID_CONNECTOR_CURVE_CIRCLE_START: 855 // case SID_CONNECTOR_CURVE_CIRCLE_END: 856 // case SID_CONNECTOR_CURVE_CIRCLES: 857 // case SID_CONNECTOR_LINES: 858 // case SID_CONNECTOR_LINES_ARROW_START: 859 // case SID_CONNECTOR_LINES_ARROW_END: 860 // case SID_CONNECTOR_LINES_ARROWS: 861 // case SID_CONNECTOR_LINES_CIRCLE_START: 862 // case SID_CONNECTOR_LINES_CIRCLE_END: 863 // case SID_CONNECTOR_LINES_CIRCLES: 864 865 SdrObject* pObj = SdrObjFactory::MakeNewObject( 866 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(), 867 0L, mpDoc); 868 869 if(pObj) 870 { 871 Rectangle aRect(rRectangle); 872 873 if(SID_DRAW_SQUARE == nID || 874 SID_DRAW_SQUARE_NOFILL == nID || 875 SID_DRAW_SQUARE_ROUND == nID || 876 SID_DRAW_SQUARE_ROUND_NOFILL == nID || 877 SID_DRAW_CIRCLE == nID || 878 SID_DRAW_CIRCLE_NOFILL == nID) 879 { 880 // force quadratic 881 ImpForceQuadratic(aRect); 882 } 883 884 Point aStart = aRect.TopLeft(); 885 Point aEnd = aRect.BottomRight(); 886 887 switch(nID) 888 { 889 case SID_DRAW_LINE: 890 case SID_DRAW_XLINE: 891 case SID_LINE_ARROW_START: 892 case SID_LINE_ARROW_END: 893 case SID_LINE_ARROWS: 894 case SID_LINE_ARROW_CIRCLE: 895 case SID_LINE_CIRCLE_ARROW: 896 case SID_LINE_ARROW_SQUARE: 897 case SID_LINE_SQUARE_ARROW: 898 { 899 if(pObj->ISA(SdrPathObj)) 900 { 901 sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2); 902 903 ::basegfx::B2DPolygon aB2DPolygon; 904 aB2DPolygon.append(::basegfx::B2DPoint(aStart.X(), nYMiddle)); 905 aB2DPolygon.append(::basegfx::B2DPoint(aEnd.X(), nYMiddle)); 906 ((SdrPathObj*)pObj)->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon)); 907 } 908 else 909 { 910 DBG_ERROR("Object is NO line object"); 911 } 912 913 break; 914 } 915 916 case SID_DRAW_MEASURELINE: 917 { 918 if(pObj->ISA(SdrMeasureObj)) 919 { 920 sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2); 921 ((SdrMeasureObj*)pObj)->SetPoint(Point(aStart.X(), nYMiddle), 0); 922 ((SdrMeasureObj*)pObj)->SetPoint(Point(aEnd.X(), nYMiddle), 1); 923 } 924 else 925 { 926 DBG_ERROR("Object is NO measure object"); 927 } 928 929 break; 930 } 931 932 case SID_TOOL_CONNECTOR: 933 case SID_CONNECTOR_ARROW_START: 934 case SID_CONNECTOR_ARROW_END: 935 case SID_CONNECTOR_ARROWS: 936 case SID_CONNECTOR_CIRCLE_START: 937 case SID_CONNECTOR_CIRCLE_END: 938 case SID_CONNECTOR_CIRCLES: 939 case SID_CONNECTOR_LINE: 940 case SID_CONNECTOR_LINE_ARROW_START: 941 case SID_CONNECTOR_LINE_ARROW_END: 942 case SID_CONNECTOR_LINE_ARROWS: 943 case SID_CONNECTOR_LINE_CIRCLE_START: 944 case SID_CONNECTOR_LINE_CIRCLE_END: 945 case SID_CONNECTOR_LINE_CIRCLES: 946 case SID_CONNECTOR_CURVE: 947 case SID_CONNECTOR_CURVE_ARROW_START: 948 case SID_CONNECTOR_CURVE_ARROW_END: 949 case SID_CONNECTOR_CURVE_ARROWS: 950 case SID_CONNECTOR_CURVE_CIRCLE_START: 951 case SID_CONNECTOR_CURVE_CIRCLE_END: 952 case SID_CONNECTOR_CURVE_CIRCLES: 953 case SID_CONNECTOR_LINES: 954 case SID_CONNECTOR_LINES_ARROW_START: 955 case SID_CONNECTOR_LINES_ARROW_END: 956 case SID_CONNECTOR_LINES_ARROWS: 957 case SID_CONNECTOR_LINES_CIRCLE_START: 958 case SID_CONNECTOR_LINES_CIRCLE_END: 959 case SID_CONNECTOR_LINES_CIRCLES: 960 { 961 if(pObj->ISA(SdrEdgeObj)) 962 { 963 ((SdrEdgeObj*)pObj)->SetTailPoint(sal_False, aStart); 964 ((SdrEdgeObj*)pObj)->SetTailPoint(sal_True, aEnd); 965 } 966 else 967 { 968 DBG_ERROR("Object is NO connector object"); 969 } 970 971 break; 972 } 973 case SID_DRAW_CAPTION: 974 case SID_DRAW_CAPTION_VERTICAL: 975 { 976 if(pObj->ISA(SdrCaptionObj)) 977 { 978 sal_Bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID); 979 980 ((SdrTextObj*)pObj)->SetVerticalWriting(bIsVertical); 981 982 if(bIsVertical) 983 { 984 SfxItemSet aSet(pObj->GetMergedItemSet()); 985 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); 986 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); 987 pObj->SetMergedItemSet(aSet); 988 } 989 990 // For task #105815# the default text is not inserted anymore. 991 // String aText(SdResId(STR_POOLSHEET_TEXT)); 992 // ((SdrCaptionObj*)pObj)->SetText(aText); 993 994 ((SdrCaptionObj*)pObj)->SetLogicRect(aRect); 995 ((SdrCaptionObj*)pObj)->SetTailPos( 996 aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2)); 997 } 998 else 999 { 1000 DBG_ERROR("Object is NO caption object"); 1001 } 1002 1003 break; 1004 } 1005 1006 default: 1007 { 1008 pObj->SetLogicRect(aRect); 1009 1010 break; 1011 } 1012 } 1013 1014 SfxItemSet aAttr(mpDoc->GetPool()); 1015 SetStyleSheet(aAttr, pObj); 1016 SetAttributes(aAttr, pObj); 1017 SetLineEnds(aAttr, pObj); 1018 pObj->SetMergedItemSet(aAttr); 1019 } 1020 1021 return pObj; 1022 } 1023 1024 } // end of namespace sd 1025