merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / fuconrec.cxx
blob07a538264e56a03cef1a4ec32dcf87b656dcf6a4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuconrec.cxx,v $
10 * $Revision: 1.33 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "fuconrec.hxx"
35 #include <svx/svdpagv.hxx>
38 #include <svx/svxids.hrc>
39 #include <svx/dialogs.hrc>
40 #include <svx/dialmgr.hxx>
42 #include "app.hrc"
43 #include <svtools/aeitem.hxx>
44 #include <svx/xlnstwit.hxx>
45 #include <svx/xlnedwit.hxx>
46 #include <svx/xlnedit.hxx>
47 #include <svx/xlnstit.hxx>
48 #include <svx/xlnwtit.hxx>
49 #include <sfx2/viewfrm.hxx>
50 #include <svx/sdtmfitm.hxx>
51 #include <svx/sxekitm.hxx>
52 #include <svx/sderitm.hxx>
53 #include <sfx2/dispatch.hxx>
54 #include <svx/svdopath.hxx>
55 #include <svx/svdocirc.hxx>
56 #include <svtools/intitem.hxx>
57 #include <sfx2/request.hxx>
58 #include <svx/adjitem.hxx>
59 #include <svx/xtable.hxx>
61 // #88751#
62 #include <svx/svdocapt.hxx>
64 // #97016#
65 #include <svx/svdomeas.hxx>
66 #include "ViewShell.hxx"
67 #include "ViewShellBase.hxx"
68 #include "ToolBarManager.hxx"
69 // #109583#
70 #include <svx/writingmodeitem.hxx>
71 #include <basegfx/polygon/b2dpolygontools.hxx>
72 #include <basegfx/polygon/b2dpolygon.hxx>
74 #include "sdresid.hxx"
75 #include "View.hxx"
76 #include "sdpage.hxx"
77 #include "Window.hxx"
78 #include "stlpool.hxx"
79 #include "drawdoc.hxx"
80 #include "res_bmp.hrc"
81 #include "glob.hrc"
83 namespace sd {
85 TYPEINIT1( FuConstructRectangle, FuConstruct );
87 /*************************************************************************
89 |* Konstruktor
91 \************************************************************************/
93 FuConstructRectangle::FuConstructRectangle (
94 ViewShell* pViewSh,
95 ::sd::Window* pWin,
96 ::sd::View* pView,
97 SdDrawDocument* pDoc,
98 SfxRequest& rReq)
99 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
103 FunctionReference FuConstructRectangle::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
105 FuConstructRectangle* pFunc;
106 FunctionReference xFunc( pFunc = new FuConstructRectangle( pViewSh, pWin, pView, pDoc, rReq ) );
107 xFunc->DoExecute(rReq);
108 pFunc->SetPermanent(bPermanent);
109 return xFunc;
112 void FuConstructRectangle::DoExecute( SfxRequest& rReq )
114 FuConstruct::DoExecute( rReq );
116 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
117 ToolBarManager::TBG_FUNCTION,
118 ToolBarManager::msDrawingObjectToolBar);
120 const SfxItemSet *pArgs = rReq.GetArgs ();
122 if (pArgs)
124 switch (nSlotId)
126 case SID_DRAW_ELLIPSE :
128 SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, FALSE);
129 SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, FALSE);
130 SFX_REQUEST_ARG (rReq, pAxisX, SfxUInt32Item, ID_VAL_AXIS_X, FALSE);
131 SFX_REQUEST_ARG (rReq, pAxisY, SfxUInt32Item, ID_VAL_AXIS_Y, FALSE);
133 Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
134 pCenterY->GetValue () - pAxisY->GetValue () / 2,
135 pCenterX->GetValue () + pAxisX->GetValue () / 2,
136 pCenterY->GetValue () + pAxisY->GetValue () / 2);
137 SdrCircObj *pNewCircle = new SdrCircObj (OBJ_CIRC, aNewRectangle);
138 SdrPageView *pPV = mpView->GetSdrPageView();
140 mpView->InsertObjectAtView(pNewCircle, *pPV, SDRINSERT_SETDEFLAYER | SDRINSERT_SETDEFATTR);
142 break;
144 case SID_DRAW_RECT :
146 SFX_REQUEST_ARG (rReq, pMouseStartX, SfxUInt32Item, ID_VAL_MOUSESTART_X, FALSE);
147 SFX_REQUEST_ARG (rReq, pMouseStartY, SfxUInt32Item, ID_VAL_MOUSESTART_Y, FALSE);
148 SFX_REQUEST_ARG (rReq, pMouseEndX, SfxUInt32Item, ID_VAL_MOUSEEND_X, FALSE);
149 SFX_REQUEST_ARG (rReq, pMouseEndY, SfxUInt32Item, ID_VAL_MOUSEEND_Y, FALSE);
151 Rectangle aNewRectangle (pMouseStartX->GetValue (),
152 pMouseStartY->GetValue (),
153 pMouseEndX->GetValue (),
154 pMouseEndY->GetValue ());
155 SdrRectObj *pNewRect = new SdrRectObj (aNewRectangle);
156 SdrPageView *pPV = mpView->GetSdrPageView();
158 mpView->InsertObjectAtView(pNewRect, *pPV, SDRINSERT_SETDEFLAYER | SDRINSERT_SETDEFATTR);
160 break;
164 if (nSlotId == SID_TOOL_CONNECTOR ||
165 nSlotId == SID_CONNECTOR_ARROW_START ||
166 nSlotId == SID_CONNECTOR_ARROW_END ||
167 nSlotId == SID_CONNECTOR_ARROWS ||
168 nSlotId == SID_CONNECTOR_CIRCLE_START ||
169 nSlotId == SID_CONNECTOR_CIRCLE_END ||
170 nSlotId == SID_CONNECTOR_CIRCLES ||
171 nSlotId == SID_CONNECTOR_LINE ||
172 nSlotId == SID_CONNECTOR_LINE_ARROW_START ||
173 nSlotId == SID_CONNECTOR_LINE_ARROW_END ||
174 nSlotId == SID_CONNECTOR_LINE_ARROWS ||
175 nSlotId == SID_CONNECTOR_LINE_CIRCLE_START ||
176 nSlotId == SID_CONNECTOR_LINE_CIRCLE_END ||
177 nSlotId == SID_CONNECTOR_LINE_CIRCLES ||
178 nSlotId == SID_CONNECTOR_CURVE ||
179 nSlotId == SID_CONNECTOR_CURVE_ARROW_START ||
180 nSlotId == SID_CONNECTOR_CURVE_ARROW_END ||
181 nSlotId == SID_CONNECTOR_CURVE_ARROWS ||
182 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START ||
183 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END ||
184 nSlotId == SID_CONNECTOR_CURVE_CIRCLES ||
185 nSlotId == SID_CONNECTOR_LINES ||
186 nSlotId == SID_CONNECTOR_LINES_ARROW_START ||
187 nSlotId == SID_CONNECTOR_LINES_ARROW_END ||
188 nSlotId == SID_CONNECTOR_LINES_ARROWS ||
189 nSlotId == SID_CONNECTOR_LINES_CIRCLE_START ||
190 nSlotId == SID_CONNECTOR_LINES_CIRCLE_END ||
191 nSlotId == SID_CONNECTOR_LINES_CIRCLES ||
192 nSlotId == SID_LINE_ARROW_START ||
193 nSlotId == SID_LINE_ARROW_END ||
194 nSlotId == SID_LINE_ARROWS ||
195 nSlotId == SID_LINE_ARROW_CIRCLE ||
196 nSlotId == SID_LINE_CIRCLE_ARROW ||
197 nSlotId == SID_LINE_ARROW_SQUARE ||
198 nSlotId == SID_LINE_SQUARE_ARROW )
200 mpView->UnmarkAll();
204 /*************************************************************************
206 |* MouseButtonDown-event
208 \************************************************************************/
210 BOOL FuConstructRectangle::MouseButtonDown(const MouseEvent& rMEvt)
212 BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt);
214 if ( rMEvt.IsLeft() && !mpView->IsAction() )
216 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
218 mpWindow->CaptureMouse();
219 USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
221 if (mpView->GetCurrentObjIdentifier() == OBJ_CAPTION)
223 Size aCaptionSize(846, 846); // (4x2)cm
224 bReturn = mpView->BegCreateCaptionObj(aPnt, aCaptionSize,
225 (OutputDevice*) NULL, nDrgLog);
227 else
229 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
232 SdrObject* pObj = mpView->GetCreateObj();
234 if (pObj)
236 SfxItemSet aAttr(mpDoc->GetPool());
237 SetStyleSheet(aAttr, pObj);
238 SetAttributes(aAttr, pObj);
239 SetLineEnds(aAttr, pObj);
240 pObj->SetMergedItemSet(aAttr);
242 if( nSlotId == SID_DRAW_CAPTION_VERTICAL )
243 ( (SdrTextObj*) pObj)->SetVerticalWriting( TRUE );
246 return bReturn;
249 /*************************************************************************
251 |* MouseMove-event
253 \************************************************************************/
255 BOOL FuConstructRectangle::MouseMove(const MouseEvent& rMEvt)
257 return FuConstruct::MouseMove(rMEvt);
260 /*************************************************************************
262 |* MouseButtonUp-event
264 \************************************************************************/
266 BOOL FuConstructRectangle::MouseButtonUp(const MouseEvent& rMEvt)
268 sal_Bool bReturn(sal_False);
270 if(mpView->IsCreateObj() && rMEvt.IsLeft())
272 SdrObject* pObj = mpView->GetCreateObj();
274 if(pObj && mpView->EndCreateObj(SDRCREATE_FORCEEND))
276 if(SID_DRAW_MEASURELINE == nSlotId)
278 SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
279 String aStr(SdResId(STR_LAYER_MEASURELINES));
280 pObj->SetLayer(rAdmin.GetLayerID(aStr, FALSE));
283 // #88751# init text position when vertica caption object is created
284 if(pObj->ISA(SdrCaptionObj) && SID_DRAW_CAPTION_VERTICAL == nSlotId)
286 // draw text object, needs to be initialized when vertical text is used
287 SfxItemSet aSet(pObj->GetMergedItemSet());
289 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
290 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
292 // #109583#
293 // Correct the value of SDRATTR_TEXTDIRECTION to avoid SetItemSet
294 // calling SetVerticalWriting() again since this item may not yet
295 // be set at the object and thus may differ from verical state of
296 // the object.
297 aSet.Put(SvxWritingModeItem(com::sun::star::text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION));
298 pObj->SetMergedItemSet(aSet);
301 bReturn = sal_True;
305 bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
307 if (!bPermanent)
308 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
310 return bReturn;
313 /*************************************************************************
315 |* Tastaturereignisse bearbeiten
317 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
318 |* FALSE.
320 \************************************************************************/
322 BOOL FuConstructRectangle::KeyInput(const KeyEvent& rKEvt)
324 BOOL bReturn = FuConstruct::KeyInput(rKEvt);
325 return(bReturn);
328 /*************************************************************************
330 |* Function aktivieren
332 \************************************************************************/
334 void FuConstructRectangle::Activate()
336 SdrObjKind aObjKind;
338 switch (nSlotId)
340 case SID_LINE_ARROW_START:
341 case SID_LINE_ARROW_END:
342 case SID_LINE_ARROWS:
343 case SID_LINE_ARROW_CIRCLE:
344 case SID_LINE_CIRCLE_ARROW:
345 case SID_LINE_ARROW_SQUARE:
346 case SID_LINE_SQUARE_ARROW:
347 mpView->SetGlueVisible();
348 // keine break !
349 case SID_DRAW_LINE :
350 case SID_DRAW_XLINE:
351 aObjKind = OBJ_LINE;
352 break;
354 case SID_DRAW_MEASURELINE:
356 aObjKind = OBJ_MEASURE;
358 break;
360 case SID_DRAW_RECT :
361 case SID_DRAW_RECT_NOFILL :
362 case SID_DRAW_RECT_ROUND :
363 case SID_DRAW_RECT_ROUND_NOFILL:
364 case SID_DRAW_SQUARE :
365 case SID_DRAW_SQUARE_NOFILL :
366 case SID_DRAW_SQUARE_ROUND :
367 case SID_DRAW_SQUARE_ROUND_NOFILL:
369 aObjKind = OBJ_RECT;
371 break;
373 case SID_DRAW_ELLIPSE :
374 case SID_DRAW_ELLIPSE_NOFILL:
375 case SID_DRAW_CIRCLE :
376 case SID_DRAW_CIRCLE_NOFILL :
378 aObjKind = OBJ_CIRC;
380 break;
382 case SID_DRAW_CAPTION:
383 case SID_DRAW_CAPTION_VERTICAL:
385 aObjKind = OBJ_CAPTION;
387 break;
389 case SID_TOOL_CONNECTOR:
390 case SID_CONNECTOR_ARROW_START:
391 case SID_CONNECTOR_ARROW_END:
392 case SID_CONNECTOR_ARROWS:
393 case SID_CONNECTOR_CIRCLE_START:
394 case SID_CONNECTOR_CIRCLE_END:
395 case SID_CONNECTOR_CIRCLES:
396 case SID_CONNECTOR_LINE:
397 case SID_CONNECTOR_LINE_ARROW_START:
398 case SID_CONNECTOR_LINE_ARROW_END:
399 case SID_CONNECTOR_LINE_ARROWS:
400 case SID_CONNECTOR_LINE_CIRCLE_START:
401 case SID_CONNECTOR_LINE_CIRCLE_END:
402 case SID_CONNECTOR_LINE_CIRCLES:
403 case SID_CONNECTOR_CURVE:
404 case SID_CONNECTOR_CURVE_ARROW_START:
405 case SID_CONNECTOR_CURVE_ARROW_END:
406 case SID_CONNECTOR_CURVE_ARROWS:
407 case SID_CONNECTOR_CURVE_CIRCLE_START:
408 case SID_CONNECTOR_CURVE_CIRCLE_END:
409 case SID_CONNECTOR_CURVE_CIRCLES:
410 case SID_CONNECTOR_LINES:
411 case SID_CONNECTOR_LINES_ARROW_START:
412 case SID_CONNECTOR_LINES_ARROW_END:
413 case SID_CONNECTOR_LINES_ARROWS:
414 case SID_CONNECTOR_LINES_CIRCLE_START:
415 case SID_CONNECTOR_LINES_CIRCLE_END:
416 case SID_CONNECTOR_LINES_CIRCLES:
418 aObjKind = OBJ_EDGE;
419 mpView->SetGlueVisible();
421 break;
423 default:
425 aObjKind = OBJ_RECT;
427 break;
430 mpView->SetCurrentObj((UINT16)aObjKind);
432 FuConstruct::Activate();
435 /*************************************************************************
437 |* Function deaktivieren
439 \************************************************************************/
441 void FuConstructRectangle::Deactivate()
443 if( nSlotId == SID_TOOL_CONNECTOR ||
444 nSlotId == SID_CONNECTOR_ARROW_START ||
445 nSlotId == SID_CONNECTOR_ARROW_END ||
446 nSlotId == SID_CONNECTOR_ARROWS ||
447 nSlotId == SID_CONNECTOR_CIRCLE_START ||
448 nSlotId == SID_CONNECTOR_CIRCLE_END ||
449 nSlotId == SID_CONNECTOR_CIRCLES ||
450 nSlotId == SID_CONNECTOR_LINE ||
451 nSlotId == SID_CONNECTOR_LINE_ARROW_START ||
452 nSlotId == SID_CONNECTOR_LINE_ARROW_END ||
453 nSlotId == SID_CONNECTOR_LINE_ARROWS ||
454 nSlotId == SID_CONNECTOR_LINE_CIRCLE_START ||
455 nSlotId == SID_CONNECTOR_LINE_CIRCLE_END ||
456 nSlotId == SID_CONNECTOR_LINE_CIRCLES ||
457 nSlotId == SID_CONNECTOR_CURVE ||
458 nSlotId == SID_CONNECTOR_CURVE_ARROW_START ||
459 nSlotId == SID_CONNECTOR_CURVE_ARROW_END ||
460 nSlotId == SID_CONNECTOR_CURVE_ARROWS ||
461 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START ||
462 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END ||
463 nSlotId == SID_CONNECTOR_CURVE_CIRCLES ||
464 nSlotId == SID_CONNECTOR_LINES ||
465 nSlotId == SID_CONNECTOR_LINES_ARROW_START ||
466 nSlotId == SID_CONNECTOR_LINES_ARROW_END ||
467 nSlotId == SID_CONNECTOR_LINES_ARROWS ||
468 nSlotId == SID_CONNECTOR_LINES_CIRCLE_START ||
469 nSlotId == SID_CONNECTOR_LINES_CIRCLE_END ||
470 nSlotId == SID_CONNECTOR_LINES_CIRCLES ||
471 nSlotId == SID_LINE_ARROW_START ||
472 nSlotId == SID_LINE_ARROW_END ||
473 nSlotId == SID_LINE_ARROWS ||
474 nSlotId == SID_LINE_ARROW_CIRCLE ||
475 nSlotId == SID_LINE_CIRCLE_ARROW ||
476 nSlotId == SID_LINE_ARROW_SQUARE ||
477 nSlotId == SID_LINE_SQUARE_ARROW )
479 mpView->SetGlueVisible( FALSE );
481 FuConstruct::Deactivate();
485 /*************************************************************************
487 |* Attribute fuer das zu erzeugende Objekt setzen
489 \************************************************************************/
491 void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj)
493 if (nSlotId == SID_DRAW_RECT_ROUND ||
494 nSlotId == SID_DRAW_RECT_ROUND_NOFILL ||
495 nSlotId == SID_DRAW_SQUARE_ROUND ||
496 nSlotId == SID_DRAW_SQUARE_ROUND_NOFILL)
498 /**********************************************************************
499 * Abgerundete Ecken
500 **********************************************************************/
501 rAttr.Put(SdrEckenradiusItem(500));
503 else if (nSlotId == SID_CONNECTOR_LINE ||
504 nSlotId == SID_CONNECTOR_LINE_ARROW_START ||
505 nSlotId == SID_CONNECTOR_LINE_ARROW_END ||
506 nSlotId == SID_CONNECTOR_LINE_ARROWS ||
507 nSlotId == SID_CONNECTOR_LINE_CIRCLE_START ||
508 nSlotId == SID_CONNECTOR_LINE_CIRCLE_END ||
509 nSlotId == SID_CONNECTOR_LINE_CIRCLES)
511 /**********************************************************************
512 * Direkt-Verbinder
513 **********************************************************************/
514 rAttr.Put(SdrEdgeKindItem(SDREDGE_ONELINE));
516 else if (nSlotId == SID_CONNECTOR_LINES ||
517 nSlotId == SID_CONNECTOR_LINES_ARROW_START ||
518 nSlotId == SID_CONNECTOR_LINES_ARROW_END ||
519 nSlotId == SID_CONNECTOR_LINES_ARROWS ||
520 nSlotId == SID_CONNECTOR_LINES_CIRCLE_START ||
521 nSlotId == SID_CONNECTOR_LINES_CIRCLE_END ||
522 nSlotId == SID_CONNECTOR_LINES_CIRCLES)
524 /**********************************************************************
525 * Linien-Verbinder
526 **********************************************************************/
527 rAttr.Put(SdrEdgeKindItem(SDREDGE_THREELINES));
529 else if (nSlotId == SID_CONNECTOR_CURVE ||
530 nSlotId == SID_CONNECTOR_CURVE_ARROW_START ||
531 nSlotId == SID_CONNECTOR_CURVE_ARROW_END ||
532 nSlotId == SID_CONNECTOR_CURVE_ARROWS ||
533 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START ||
534 nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END ||
535 nSlotId == SID_CONNECTOR_CURVE_CIRCLES)
537 /**********************************************************************
538 * Kurven-Verbinder
539 **********************************************************************/
540 rAttr.Put(SdrEdgeKindItem(SDREDGE_BEZIER));
542 else if ( nSlotId == SID_DRAW_CAPTION || nSlotId == SID_DRAW_CAPTION_VERTICAL )
544 /**********************************************************************
545 * Legendenobjekt
546 **********************************************************************/
547 Size aSize(pObj->GetLogicRect().GetSize());
548 rAttr.Put( SdrTextMinFrameHeightItem( aSize.Height() ) );
549 rAttr.Put( SdrTextMinFrameWidthItem( aSize.Width() ) );
550 rAttr.Put( SdrTextAutoGrowHeightItem( TRUE ) );
551 rAttr.Put( SdrTextAutoGrowWidthItem( TRUE ) );
553 // #103516# Support full with for vertical caption objects, too
554 if(SID_DRAW_CAPTION == nSlotId)
555 rAttr.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
556 else
557 rAttr.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_BLOCK ) );
559 rAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
560 rAttr.Put( SdrTextLeftDistItem( 100 ) );
561 rAttr.Put( SdrTextRightDistItem( 100 ) );
562 rAttr.Put( SdrTextUpperDistItem( 100 ) );
563 rAttr.Put( SdrTextLowerDistItem( 100 ) );
565 else if (nSlotId == SID_DRAW_MEASURELINE)
567 /**********************************************************************
568 * Masslinie
569 **********************************************************************/
570 SdPage* pPage = (SdPage*) mpView->GetSdrPageView()->GetPage();
571 String aName(SdResId(STR_POOLSHEET_MEASURE));
572 SfxStyleSheet* pSheet = (SfxStyleSheet*) pPage->GetModel()->
573 GetStyleSheetPool()->
574 Find(aName, SD_STYLE_FAMILY_GRAPHICS);
575 DBG_ASSERT(pSheet, "Objektvorlage nicht gefunden");
577 if (pSheet)
579 pObj->SetStyleSheet(pSheet, FALSE);
582 SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
583 String aStr(SdResId(STR_LAYER_MEASURELINES));
584 pObj->SetLayer(rAdmin.GetLayerID(aStr, FALSE));
586 else if (nSlotId == OBJ_CUSTOMSHAPE )
592 /*************************************************************************
594 |* Linienanfaenge und -enden fuer das zu erzeugende Objekt setzen
596 \************************************************************************/
598 ::basegfx::B2DPolyPolygon getPolygon( sal_uInt16 nResId, SdrModel* pDoc )
600 ::basegfx::B2DPolyPolygon aRetval;
601 XLineEndList* pLineEndList = pDoc->GetLineEndList();
603 if( pLineEndList )
605 String aArrowName( SVX_RES(nResId) );
606 long nCount = pLineEndList->Count();
607 long nIndex;
608 for( nIndex = 0L; nIndex < nCount; nIndex++ )
610 XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nIndex);
611 if( pEntry->GetName() == aArrowName )
613 aRetval = pEntry->GetLineEnd();
614 break;
619 return aRetval;
622 void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject* pObj)
624 if ( (pObj->GetObjIdentifier() == OBJ_EDGE &&
625 nSlotId != SID_TOOL_CONNECTOR &&
626 nSlotId != SID_CONNECTOR_LINE &&
627 nSlotId != SID_CONNECTOR_LINES &&
628 nSlotId != SID_CONNECTOR_CURVE) ||
629 nSlotId == SID_LINE_ARROW_START ||
630 nSlotId == SID_LINE_ARROW_END ||
631 nSlotId == SID_LINE_ARROWS ||
632 nSlotId == SID_LINE_ARROW_CIRCLE ||
633 nSlotId == SID_LINE_CIRCLE_ARROW ||
634 nSlotId == SID_LINE_ARROW_SQUARE ||
635 nSlotId == SID_LINE_SQUARE_ARROW )
637 /**************************************************************
638 * Linienanfaenge und -enden attributieren
639 **************************************************************/
641 // Pfeilspitze
642 ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, mpDoc ) );
643 if( !aArrow.count() )
645 ::basegfx::B2DPolygon aNewArrow;
646 aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0));
647 aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0));
648 aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0));
649 aNewArrow.setClosed(true);
650 aArrow.append(aNewArrow);
653 // Kreis
654 ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, mpDoc ) );
655 if( !aCircle.count() )
657 ::basegfx::B2DPolygon aNewCircle;
658 aNewCircle = ::basegfx::tools::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0);
659 aNewCircle.setClosed(true);
660 aCircle.append(aNewCircle);
663 // Quadrat
664 ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, mpDoc ) );
665 if( !aSquare.count() )
667 ::basegfx::B2DPolygon aNewSquare;
668 aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0));
669 aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0));
670 aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0));
671 aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0));
672 aNewSquare.setClosed(true);
673 aSquare.append(aNewSquare);
676 SfxItemSet aSet( mpDoc->GetPool() );
677 mpView->GetAttributes( aSet );
679 // #i3908# Here, the default Line Start/End width for arrow construction is
680 // set. To have the same value in all situations (construction) in i3908
681 // it was decided to change the default to 0.03 cm for all situations.
682 long nWidth = 300; // (1/100th mm)
684 // Linienstaerke ermitteln und daraus die Linienendenstaerke berechnen
685 if( aSet.GetItemState( XATTR_LINEWIDTH ) != SFX_ITEM_DONTCARE )
687 long nValue = ( ( const XLineWidthItem& ) aSet.Get( XATTR_LINEWIDTH ) ).GetValue();
688 if( nValue > 0 )
689 nWidth = nValue * 3;
692 switch (nSlotId)
694 case SID_CONNECTOR_ARROWS:
695 case SID_CONNECTOR_LINE_ARROWS:
696 case SID_CONNECTOR_LINES_ARROWS:
697 case SID_CONNECTOR_CURVE_ARROWS:
698 case SID_LINE_ARROWS:
700 // Verbinder mit Pfeil-Enden
701 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow));
702 rAttr.Put(XLineStartWidthItem(nWidth));
703 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow));
704 rAttr.Put(XLineEndWidthItem(nWidth));
706 break;
708 case SID_CONNECTOR_ARROW_START:
709 case SID_CONNECTOR_LINE_ARROW_START:
710 case SID_CONNECTOR_LINES_ARROW_START:
711 case SID_CONNECTOR_CURVE_ARROW_START:
712 case SID_LINE_ARROW_START:
713 case SID_LINE_ARROW_CIRCLE:
714 case SID_LINE_ARROW_SQUARE:
716 // Verbinder mit Pfeil-Anfang
717 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow));
718 rAttr.Put(XLineStartWidthItem(nWidth));
720 break;
722 case SID_CONNECTOR_ARROW_END:
723 case SID_CONNECTOR_LINE_ARROW_END:
724 case SID_CONNECTOR_LINES_ARROW_END:
725 case SID_CONNECTOR_CURVE_ARROW_END:
726 case SID_LINE_ARROW_END:
727 case SID_LINE_CIRCLE_ARROW:
728 case SID_LINE_SQUARE_ARROW:
730 // Verbinder mit Pfeil-Ende
731 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow));
732 rAttr.Put(XLineEndWidthItem(nWidth));
734 break;
736 case SID_CONNECTOR_CIRCLES:
737 case SID_CONNECTOR_LINE_CIRCLES:
738 case SID_CONNECTOR_LINES_CIRCLES:
739 case SID_CONNECTOR_CURVE_CIRCLES:
741 // Verbinder mit Kreis-Enden
742 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle));
743 rAttr.Put(XLineStartWidthItem(nWidth));
744 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle));
745 rAttr.Put(XLineEndWidthItem(nWidth));
747 break;
749 case SID_CONNECTOR_CIRCLE_START:
750 case SID_CONNECTOR_LINE_CIRCLE_START:
751 case SID_CONNECTOR_LINES_CIRCLE_START:
752 case SID_CONNECTOR_CURVE_CIRCLE_START:
754 // Verbinder mit Kreis-Anfang
755 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle));
756 rAttr.Put(XLineStartWidthItem(nWidth));
758 break;
760 case SID_CONNECTOR_CIRCLE_END:
761 case SID_CONNECTOR_LINE_CIRCLE_END:
762 case SID_CONNECTOR_LINES_CIRCLE_END:
763 case SID_CONNECTOR_CURVE_CIRCLE_END:
765 // Verbinder mit Kreis-Ende
766 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle));
767 rAttr.Put(XLineEndWidthItem(nWidth));
769 break;
772 // Und nochmal fuer die noch fehlenden Enden
773 switch (nSlotId)
775 case SID_LINE_ARROW_CIRCLE:
777 // Kreis-Ende
778 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle));
779 rAttr.Put(XLineEndWidthItem(nWidth));
781 break;
783 case SID_LINE_CIRCLE_ARROW:
785 // Kreis-Anfang
786 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle));
787 rAttr.Put(XLineStartWidthItem(nWidth));
789 break;
791 case SID_LINE_ARROW_SQUARE:
793 // Quadrat-Ende
794 rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_SQUARE), aSquare));
795 rAttr.Put(XLineEndWidthItem(nWidth));
797 break;
799 case SID_LINE_SQUARE_ARROW:
801 // Quadrat-Anfang
802 rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_SQUARE), aSquare));
803 rAttr.Put(XLineStartWidthItem(nWidth));
805 break;
810 // #97016#
811 SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
813 DBG_ASSERT( (nID != SID_DRAW_FONTWORK) && (nID != SID_DRAW_FONTWORK_VERTICAL ), "FuConstRectangle::CreateDefaultObject can not create Fontwork shapes!" );
815 // case SID_DRAW_LINE:
816 // case SID_DRAW_XLINE:
817 // case SID_DRAW_MEASURELINE:
818 // case SID_LINE_ARROW_START:
819 // case SID_LINE_ARROW_END:
820 // case SID_LINE_ARROWS:
821 // case SID_LINE_ARROW_CIRCLE:
822 // case SID_LINE_CIRCLE_ARROW:
823 // case SID_LINE_ARROW_SQUARE:
824 // case SID_LINE_SQUARE_ARROW:
825 // case SID_DRAW_RECT:
826 // case SID_DRAW_RECT_NOFILL:
827 // case SID_DRAW_RECT_ROUND:
828 // case SID_DRAW_RECT_ROUND_NOFILL:
829 // case SID_DRAW_SQUARE:
830 // case SID_DRAW_SQUARE_NOFILL:
831 // case SID_DRAW_SQUARE_ROUND:
832 // case SID_DRAW_SQUARE_ROUND_NOFILL:
833 // case SID_DRAW_ELLIPSE:
834 // case SID_DRAW_ELLIPSE_NOFILL:
835 // case SID_DRAW_CIRCLE:
836 // case SID_DRAW_CIRCLE_NOFILL:
837 // case SID_DRAW_CAPTION:
838 // case SID_DRAW_CAPTION_VERTICAL:
839 // case SID_TOOL_CONNECTOR:
840 // case SID_CONNECTOR_ARROW_START:
841 // case SID_CONNECTOR_ARROW_END:
842 // case SID_CONNECTOR_ARROWS:
843 // case SID_CONNECTOR_CIRCLE_START:
844 // case SID_CONNECTOR_CIRCLE_END:
845 // case SID_CONNECTOR_CIRCLES:
846 // case SID_CONNECTOR_LINE:
847 // case SID_CONNECTOR_LINE_ARROW_START:
848 // case SID_CONNECTOR_LINE_ARROW_END:
849 // case SID_CONNECTOR_LINE_ARROWS:
850 // case SID_CONNECTOR_LINE_CIRCLE_START:
851 // case SID_CONNECTOR_LINE_CIRCLE_END:
852 // case SID_CONNECTOR_LINE_CIRCLES:
853 // case SID_CONNECTOR_CURVE:
854 // case SID_CONNECTOR_CURVE_ARROW_START:
855 // case SID_CONNECTOR_CURVE_ARROW_END:
856 // case SID_CONNECTOR_CURVE_ARROWS:
857 // case SID_CONNECTOR_CURVE_CIRCLE_START:
858 // case SID_CONNECTOR_CURVE_CIRCLE_END:
859 // case SID_CONNECTOR_CURVE_CIRCLES:
860 // case SID_CONNECTOR_LINES:
861 // case SID_CONNECTOR_LINES_ARROW_START:
862 // case SID_CONNECTOR_LINES_ARROW_END:
863 // case SID_CONNECTOR_LINES_ARROWS:
864 // case SID_CONNECTOR_LINES_CIRCLE_START:
865 // case SID_CONNECTOR_LINES_CIRCLE_END:
866 // case SID_CONNECTOR_LINES_CIRCLES:
868 SdrObject* pObj = SdrObjFactory::MakeNewObject(
869 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
870 0L, mpDoc);
872 if(pObj)
874 Rectangle aRect(rRectangle);
876 if(SID_DRAW_SQUARE == nID ||
877 SID_DRAW_SQUARE_NOFILL == nID ||
878 SID_DRAW_SQUARE_ROUND == nID ||
879 SID_DRAW_SQUARE_ROUND_NOFILL == nID ||
880 SID_DRAW_CIRCLE == nID ||
881 SID_DRAW_CIRCLE_NOFILL == nID)
883 // force quadratic
884 ImpForceQuadratic(aRect);
887 Point aStart = aRect.TopLeft();
888 Point aEnd = aRect.BottomRight();
890 switch(nID)
892 case SID_DRAW_LINE:
893 case SID_DRAW_XLINE:
894 case SID_LINE_ARROW_START:
895 case SID_LINE_ARROW_END:
896 case SID_LINE_ARROWS:
897 case SID_LINE_ARROW_CIRCLE:
898 case SID_LINE_CIRCLE_ARROW:
899 case SID_LINE_ARROW_SQUARE:
900 case SID_LINE_SQUARE_ARROW:
902 if(pObj->ISA(SdrPathObj))
904 sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
906 ::basegfx::B2DPolygon aB2DPolygon;
907 aB2DPolygon.append(::basegfx::B2DPoint(aStart.X(), nYMiddle));
908 aB2DPolygon.append(::basegfx::B2DPoint(aEnd.X(), nYMiddle));
909 ((SdrPathObj*)pObj)->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon));
911 else
913 DBG_ERROR("Object is NO line object");
916 break;
919 case SID_DRAW_MEASURELINE:
921 if(pObj->ISA(SdrMeasureObj))
923 sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
924 ((SdrMeasureObj*)pObj)->SetPoint(Point(aStart.X(), nYMiddle), 0);
925 ((SdrMeasureObj*)pObj)->SetPoint(Point(aEnd.X(), nYMiddle), 1);
927 else
929 DBG_ERROR("Object is NO measure object");
932 break;
935 case SID_TOOL_CONNECTOR:
936 case SID_CONNECTOR_ARROW_START:
937 case SID_CONNECTOR_ARROW_END:
938 case SID_CONNECTOR_ARROWS:
939 case SID_CONNECTOR_CIRCLE_START:
940 case SID_CONNECTOR_CIRCLE_END:
941 case SID_CONNECTOR_CIRCLES:
942 case SID_CONNECTOR_LINE:
943 case SID_CONNECTOR_LINE_ARROW_START:
944 case SID_CONNECTOR_LINE_ARROW_END:
945 case SID_CONNECTOR_LINE_ARROWS:
946 case SID_CONNECTOR_LINE_CIRCLE_START:
947 case SID_CONNECTOR_LINE_CIRCLE_END:
948 case SID_CONNECTOR_LINE_CIRCLES:
949 case SID_CONNECTOR_CURVE:
950 case SID_CONNECTOR_CURVE_ARROW_START:
951 case SID_CONNECTOR_CURVE_ARROW_END:
952 case SID_CONNECTOR_CURVE_ARROWS:
953 case SID_CONNECTOR_CURVE_CIRCLE_START:
954 case SID_CONNECTOR_CURVE_CIRCLE_END:
955 case SID_CONNECTOR_CURVE_CIRCLES:
956 case SID_CONNECTOR_LINES:
957 case SID_CONNECTOR_LINES_ARROW_START:
958 case SID_CONNECTOR_LINES_ARROW_END:
959 case SID_CONNECTOR_LINES_ARROWS:
960 case SID_CONNECTOR_LINES_CIRCLE_START:
961 case SID_CONNECTOR_LINES_CIRCLE_END:
962 case SID_CONNECTOR_LINES_CIRCLES:
964 if(pObj->ISA(SdrEdgeObj))
966 ((SdrEdgeObj*)pObj)->SetTailPoint(FALSE, aStart);
967 ((SdrEdgeObj*)pObj)->SetTailPoint(TRUE, aEnd);
969 else
971 DBG_ERROR("Object is NO connector object");
974 break;
976 case SID_DRAW_CAPTION:
977 case SID_DRAW_CAPTION_VERTICAL:
979 if(pObj->ISA(SdrCaptionObj))
981 sal_Bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
983 ((SdrTextObj*)pObj)->SetVerticalWriting(bIsVertical);
985 if(bIsVertical)
987 SfxItemSet aSet(pObj->GetMergedItemSet());
988 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
989 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
990 pObj->SetMergedItemSet(aSet);
993 // For task #105815# the default text is not inserted anymore.
994 // String aText(SdResId(STR_POOLSHEET_TEXT));
995 // ((SdrCaptionObj*)pObj)->SetText(aText);
997 ((SdrCaptionObj*)pObj)->SetLogicRect(aRect);
998 ((SdrCaptionObj*)pObj)->SetTailPos(
999 aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
1001 else
1003 DBG_ERROR("Object is NO caption object");
1006 break;
1009 default:
1011 pObj->SetLogicRect(aRect);
1013 break;
1017 SfxItemSet aAttr(mpDoc->GetPool());
1018 SetStyleSheet(aAttr, pObj);
1019 SetAttributes(aAttr, pObj);
1020 SetLineEnds(aAttr, pObj);
1021 pObj->SetMergedItemSet(aAttr);
1024 return pObj;
1027 } // end of namespace sd