1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fuconrec.hxx"
21 #include <svx/svdpagv.hxx>
23 #include <svx/svxids.hrc>
24 #include <svx/dialogs.hrc>
25 #include <svx/dialmgr.hxx>
28 #include <svl/aeitem.hxx>
29 #include <svx/xlnstwit.hxx>
30 #include <svx/xlnedwit.hxx>
31 #include <svx/xlnedit.hxx>
32 #include <svx/xlnstit.hxx>
33 #include <svx/xlnwtit.hxx>
34 #include <sfx2/viewfrm.hxx>
35 #include <svx/sdtmfitm.hxx>
36 #include <svx/sxekitm.hxx>
37 #include <svx/sderitm.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <svx/svdopath.hxx>
40 #include <svx/svdocirc.hxx>
41 #include <svl/intitem.hxx>
42 #include <sfx2/request.hxx>
43 #include <editeng/adjustitem.hxx>
44 #include <svx/xtable.hxx>
46 #include <svx/svdocapt.hxx>
48 #include <svx/svdomeas.hxx>
49 #include "ViewShell.hxx"
50 #include "ViewShellBase.hxx"
51 #include "ToolBarManager.hxx"
52 #include <editeng/writingmodeitem.hxx>
53 #include <basegfx/polygon/b2dpolygontools.hxx>
54 #include <basegfx/polygon/b2dpolygon.hxx>
56 #include "sdresid.hxx"
60 #include "stlpool.hxx"
61 #include "drawdoc.hxx"
62 #include "res_bmp.hrc"
67 TYPEINIT1( FuConstructRectangle
, FuConstruct
);
69 FuConstructRectangle::FuConstructRectangle (
75 : FuConstruct(pViewSh
, pWin
, pView
, pDoc
, rReq
)
79 rtl::Reference
<FuPoor
> FuConstructRectangle::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
, bool bPermanent
)
81 FuConstructRectangle
* pFunc
;
82 rtl::Reference
<FuPoor
> xFunc( pFunc
= new FuConstructRectangle( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
83 xFunc
->DoExecute(rReq
);
84 pFunc
->SetPermanent(bPermanent
);
88 void FuConstructRectangle::DoExecute( SfxRequest
& rReq
)
90 FuConstruct::DoExecute( rReq
);
92 mpViewShell
->GetViewShellBase().GetToolBarManager()->SetToolBar(
93 ToolBarManager::TBG_FUNCTION
,
94 ToolBarManager::msDrawingObjectToolBar
);
96 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
102 case SID_DRAW_ELLIPSE
:
104 SFX_REQUEST_ARG (rReq
, pCenterX
, SfxUInt32Item
, ID_VAL_CENTER_X
, false);
105 SFX_REQUEST_ARG (rReq
, pCenterY
, SfxUInt32Item
, ID_VAL_CENTER_Y
, false);
106 SFX_REQUEST_ARG (rReq
, pAxisX
, SfxUInt32Item
, ID_VAL_AXIS_X
, false);
107 SFX_REQUEST_ARG (rReq
, pAxisY
, SfxUInt32Item
, ID_VAL_AXIS_Y
, false);
109 Rectangle
aNewRectangle (pCenterX
->GetValue () - pAxisX
->GetValue () / 2,
110 pCenterY
->GetValue () - pAxisY
->GetValue () / 2,
111 pCenterX
->GetValue () + pAxisX
->GetValue () / 2,
112 pCenterY
->GetValue () + pAxisY
->GetValue () / 2);
113 SdrCircObj
*pNewCircle
= new SdrCircObj (OBJ_CIRC
, aNewRectangle
);
114 SdrPageView
*pPV
= mpView
->GetSdrPageView();
116 mpView
->InsertObjectAtView(pNewCircle
, *pPV
, SdrInsertFlags::SETDEFLAYER
| SdrInsertFlags::SETDEFATTR
);
122 SFX_REQUEST_ARG (rReq
, pMouseStartX
, SfxUInt32Item
, ID_VAL_MOUSESTART_X
, false);
123 SFX_REQUEST_ARG (rReq
, pMouseStartY
, SfxUInt32Item
, ID_VAL_MOUSESTART_Y
, false);
124 SFX_REQUEST_ARG (rReq
, pMouseEndX
, SfxUInt32Item
, ID_VAL_MOUSEEND_X
, false);
125 SFX_REQUEST_ARG (rReq
, pMouseEndY
, SfxUInt32Item
, ID_VAL_MOUSEEND_Y
, false);
127 Rectangle
aNewRectangle (pMouseStartX
->GetValue (),
128 pMouseStartY
->GetValue (),
129 pMouseEndX
->GetValue (),
130 pMouseEndY
->GetValue ());
131 SdrRectObj
*pNewRect
= new SdrRectObj (aNewRectangle
);
132 SdrPageView
*pPV
= mpView
->GetSdrPageView();
134 mpView
->InsertObjectAtView(pNewRect
, *pPV
, SdrInsertFlags::SETDEFLAYER
| SdrInsertFlags::SETDEFATTR
);
140 if (nSlotId
== SID_TOOL_CONNECTOR
||
141 nSlotId
== SID_CONNECTOR_ARROW_START
||
142 nSlotId
== SID_CONNECTOR_ARROW_END
||
143 nSlotId
== SID_CONNECTOR_ARROWS
||
144 nSlotId
== SID_CONNECTOR_CIRCLE_START
||
145 nSlotId
== SID_CONNECTOR_CIRCLE_END
||
146 nSlotId
== SID_CONNECTOR_CIRCLES
||
147 nSlotId
== SID_CONNECTOR_LINE
||
148 nSlotId
== SID_CONNECTOR_LINE_ARROW_START
||
149 nSlotId
== SID_CONNECTOR_LINE_ARROW_END
||
150 nSlotId
== SID_CONNECTOR_LINE_ARROWS
||
151 nSlotId
== SID_CONNECTOR_LINE_CIRCLE_START
||
152 nSlotId
== SID_CONNECTOR_LINE_CIRCLE_END
||
153 nSlotId
== SID_CONNECTOR_LINE_CIRCLES
||
154 nSlotId
== SID_CONNECTOR_CURVE
||
155 nSlotId
== SID_CONNECTOR_CURVE_ARROW_START
||
156 nSlotId
== SID_CONNECTOR_CURVE_ARROW_END
||
157 nSlotId
== SID_CONNECTOR_CURVE_ARROWS
||
158 nSlotId
== SID_CONNECTOR_CURVE_CIRCLE_START
||
159 nSlotId
== SID_CONNECTOR_CURVE_CIRCLE_END
||
160 nSlotId
== SID_CONNECTOR_CURVE_CIRCLES
||
161 nSlotId
== SID_CONNECTOR_LINES
||
162 nSlotId
== SID_CONNECTOR_LINES_ARROW_START
||
163 nSlotId
== SID_CONNECTOR_LINES_ARROW_END
||
164 nSlotId
== SID_CONNECTOR_LINES_ARROWS
||
165 nSlotId
== SID_CONNECTOR_LINES_CIRCLE_START
||
166 nSlotId
== SID_CONNECTOR_LINES_CIRCLE_END
||
167 nSlotId
== SID_CONNECTOR_LINES_CIRCLES
||
168 nSlotId
== SID_LINE_ARROW_START
||
169 nSlotId
== SID_LINE_ARROW_END
||
170 nSlotId
== SID_LINE_ARROWS
||
171 nSlotId
== SID_LINE_ARROW_CIRCLE
||
172 nSlotId
== SID_LINE_CIRCLE_ARROW
||
173 nSlotId
== SID_LINE_ARROW_SQUARE
||
174 nSlotId
== SID_LINE_SQUARE_ARROW
)
180 bool FuConstructRectangle::MouseButtonDown(const MouseEvent
& rMEvt
)
182 bool bReturn
= FuConstruct::MouseButtonDown(rMEvt
);
184 if ( rMEvt
.IsLeft() && !mpView
->IsAction() )
186 Point
aPnt( mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
188 mpWindow
->CaptureMouse();
189 sal_uInt16 nDrgLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
191 if (mpView
->GetCurrentObjIdentifier() == OBJ_CAPTION
)
193 Size
aCaptionSize(846, 846); // (4x2)cm
194 bReturn
= mpView
->BegCreateCaptionObj(aPnt
, aCaptionSize
,
195 (OutputDevice
*) NULL
, nDrgLog
);
199 mpView
->BegCreateObj(aPnt
, (OutputDevice
*) NULL
, nDrgLog
);
202 SdrObject
* pObj
= mpView
->GetCreateObj();
206 SfxItemSet
aAttr(mpDoc
->GetPool());
207 SetStyleSheet(aAttr
, pObj
);
208 SetAttributes(aAttr
, pObj
);
209 SetLineEnds(aAttr
, pObj
);
210 pObj
->SetMergedItemSet(aAttr
);
212 if( nSlotId
== SID_DRAW_CAPTION_VERTICAL
)
213 static_cast<SdrTextObj
*>(pObj
)->SetVerticalWriting( true );
219 bool FuConstructRectangle::MouseMove(const MouseEvent
& rMEvt
)
221 return FuConstruct::MouseMove(rMEvt
);
224 bool FuConstructRectangle::MouseButtonUp(const MouseEvent
& rMEvt
)
228 if(mpView
->IsCreateObj() && rMEvt
.IsLeft())
230 SdrObject
* pObj
= mpView
->GetCreateObj();
232 if(pObj
&& mpView
->EndCreateObj(SDRCREATE_FORCEEND
))
234 if(SID_DRAW_MEASURELINE
== nSlotId
)
236 SdrLayerAdmin
& rAdmin
= mpDoc
->GetLayerAdmin();
237 OUString
aStr(SD_RESSTR(STR_LAYER_MEASURELINES
));
238 pObj
->SetLayer(rAdmin
.GetLayerID(aStr
, false));
241 // init text position when vertical caption object is created
242 if(pObj
->ISA(SdrCaptionObj
) && SID_DRAW_CAPTION_VERTICAL
== nSlotId
)
244 // draw text object, needs to be initialized when vertical text is used
245 SfxItemSet
aSet(pObj
->GetMergedItemSet());
247 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER
));
248 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
250 // Correct the value of SDRATTR_TEXTDIRECTION to avoid SetItemSet
251 // calling SetVerticalWriting() again since this item may not yet
252 // be set at the object and thus may differ from vertical state of
254 aSet
.Put(SvxWritingModeItem(com::sun::star::text::WritingMode_TB_RL
, SDRATTR_TEXTDIRECTION
));
255 pObj
->SetMergedItemSet(aSet
);
262 bReturn
= FuConstruct::MouseButtonUp (rMEvt
) || bReturn
;
265 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
271 * Process keyboard input
272 * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
274 bool FuConstructRectangle::KeyInput(const KeyEvent
& rKEvt
)
276 return FuConstruct::KeyInput(rKEvt
);
279 void FuConstructRectangle::Activate()
285 case SID_LINE_ARROW_START
:
286 case SID_LINE_ARROW_END
:
287 case SID_LINE_ARROWS
:
288 case SID_LINE_ARROW_CIRCLE
:
289 case SID_LINE_CIRCLE_ARROW
:
290 case SID_LINE_ARROW_SQUARE
:
291 case SID_LINE_SQUARE_ARROW
:
292 mpView
->SetGlueVisible();
299 case SID_DRAW_MEASURELINE
:
301 aObjKind
= OBJ_MEASURE
;
306 case SID_DRAW_RECT_NOFILL
:
307 case SID_DRAW_RECT_ROUND
:
308 case SID_DRAW_RECT_ROUND_NOFILL
:
309 case SID_DRAW_SQUARE
:
310 case SID_DRAW_SQUARE_NOFILL
:
311 case SID_DRAW_SQUARE_ROUND
:
312 case SID_DRAW_SQUARE_ROUND_NOFILL
:
318 case SID_DRAW_ELLIPSE
:
319 case SID_DRAW_ELLIPSE_NOFILL
:
320 case SID_DRAW_CIRCLE
:
321 case SID_DRAW_CIRCLE_NOFILL
:
327 case SID_DRAW_CAPTION
:
328 case SID_DRAW_CAPTION_VERTICAL
:
330 aObjKind
= OBJ_CAPTION
;
334 case SID_TOOL_CONNECTOR
:
335 case SID_CONNECTOR_ARROW_START
:
336 case SID_CONNECTOR_ARROW_END
:
337 case SID_CONNECTOR_ARROWS
:
338 case SID_CONNECTOR_CIRCLE_START
:
339 case SID_CONNECTOR_CIRCLE_END
:
340 case SID_CONNECTOR_CIRCLES
:
341 case SID_CONNECTOR_LINE
:
342 case SID_CONNECTOR_LINE_ARROW_START
:
343 case SID_CONNECTOR_LINE_ARROW_END
:
344 case SID_CONNECTOR_LINE_ARROWS
:
345 case SID_CONNECTOR_LINE_CIRCLE_START
:
346 case SID_CONNECTOR_LINE_CIRCLE_END
:
347 case SID_CONNECTOR_LINE_CIRCLES
:
348 case SID_CONNECTOR_CURVE
:
349 case SID_CONNECTOR_CURVE_ARROW_START
:
350 case SID_CONNECTOR_CURVE_ARROW_END
:
351 case SID_CONNECTOR_CURVE_ARROWS
:
352 case SID_CONNECTOR_CURVE_CIRCLE_START
:
353 case SID_CONNECTOR_CURVE_CIRCLE_END
:
354 case SID_CONNECTOR_CURVE_CIRCLES
:
355 case SID_CONNECTOR_LINES
:
356 case SID_CONNECTOR_LINES_ARROW_START
:
357 case SID_CONNECTOR_LINES_ARROW_END
:
358 case SID_CONNECTOR_LINES_ARROWS
:
359 case SID_CONNECTOR_LINES_CIRCLE_START
:
360 case SID_CONNECTOR_LINES_CIRCLE_END
:
361 case SID_CONNECTOR_LINES_CIRCLES
:
364 mpView
->SetGlueVisible();
375 mpView
->SetCurrentObj((sal_uInt16
)aObjKind
);
377 FuConstruct::Activate();
380 void FuConstructRectangle::Deactivate()
382 if( nSlotId
== SID_TOOL_CONNECTOR
||
383 nSlotId
== SID_CONNECTOR_ARROW_START
||
384 nSlotId
== SID_CONNECTOR_ARROW_END
||
385 nSlotId
== SID_CONNECTOR_ARROWS
||
386 nSlotId
== SID_CONNECTOR_CIRCLE_START
||
387 nSlotId
== SID_CONNECTOR_CIRCLE_END
||
388 nSlotId
== SID_CONNECTOR_CIRCLES
||
389 nSlotId
== SID_CONNECTOR_LINE
||
390 nSlotId
== SID_CONNECTOR_LINE_ARROW_START
||
391 nSlotId
== SID_CONNECTOR_LINE_ARROW_END
||
392 nSlotId
== SID_CONNECTOR_LINE_ARROWS
||
393 nSlotId
== SID_CONNECTOR_LINE_CIRCLE_START
||
394 nSlotId
== SID_CONNECTOR_LINE_CIRCLE_END
||
395 nSlotId
== SID_CONNECTOR_LINE_CIRCLES
||
396 nSlotId
== SID_CONNECTOR_CURVE
||
397 nSlotId
== SID_CONNECTOR_CURVE_ARROW_START
||
398 nSlotId
== SID_CONNECTOR_CURVE_ARROW_END
||
399 nSlotId
== SID_CONNECTOR_CURVE_ARROWS
||
400 nSlotId
== SID_CONNECTOR_CURVE_CIRCLE_START
||
401 nSlotId
== SID_CONNECTOR_CURVE_CIRCLE_END
||
402 nSlotId
== SID_CONNECTOR_CURVE_CIRCLES
||
403 nSlotId
== SID_CONNECTOR_LINES
||
404 nSlotId
== SID_CONNECTOR_LINES_ARROW_START
||
405 nSlotId
== SID_CONNECTOR_LINES_ARROW_END
||
406 nSlotId
== SID_CONNECTOR_LINES_ARROWS
||
407 nSlotId
== SID_CONNECTOR_LINES_CIRCLE_START
||
408 nSlotId
== SID_CONNECTOR_LINES_CIRCLE_END
||
409 nSlotId
== SID_CONNECTOR_LINES_CIRCLES
||
410 nSlotId
== SID_LINE_ARROW_START
||
411 nSlotId
== SID_LINE_ARROW_END
||
412 nSlotId
== SID_LINE_ARROWS
||
413 nSlotId
== SID_LINE_ARROW_CIRCLE
||
414 nSlotId
== SID_LINE_CIRCLE_ARROW
||
415 nSlotId
== SID_LINE_ARROW_SQUARE
||
416 nSlotId
== SID_LINE_SQUARE_ARROW
)
418 mpView
->SetGlueVisible( false );
420 FuConstruct::Deactivate();
424 * set attribute for the object to be created
426 void FuConstructRectangle::SetAttributes(SfxItemSet
& rAttr
, SdrObject
* pObj
)
428 if (nSlotId
== SID_DRAW_RECT_ROUND
||
429 nSlotId
== SID_DRAW_RECT_ROUND_NOFILL
||
430 nSlotId
== SID_DRAW_SQUARE_ROUND
||
431 nSlotId
== SID_DRAW_SQUARE_ROUND_NOFILL
)
434 rAttr
.Put(makeSdrEckenradiusItem(500));
436 else if (nSlotId
== SID_CONNECTOR_LINE
||
437 nSlotId
== SID_CONNECTOR_LINE_ARROW_START
||
438 nSlotId
== SID_CONNECTOR_LINE_ARROW_END
||
439 nSlotId
== SID_CONNECTOR_LINE_ARROWS
||
440 nSlotId
== SID_CONNECTOR_LINE_CIRCLE_START
||
441 nSlotId
== SID_CONNECTOR_LINE_CIRCLE_END
||
442 nSlotId
== SID_CONNECTOR_LINE_CIRCLES
)
445 rAttr
.Put(SdrEdgeKindItem(SDREDGE_ONELINE
));
447 else if (nSlotId
== SID_CONNECTOR_LINES
||
448 nSlotId
== SID_CONNECTOR_LINES_ARROW_START
||
449 nSlotId
== SID_CONNECTOR_LINES_ARROW_END
||
450 nSlotId
== SID_CONNECTOR_LINES_ARROWS
||
451 nSlotId
== SID_CONNECTOR_LINES_CIRCLE_START
||
452 nSlotId
== SID_CONNECTOR_LINES_CIRCLE_END
||
453 nSlotId
== SID_CONNECTOR_LINES_CIRCLES
)
456 rAttr
.Put(SdrEdgeKindItem(SDREDGE_THREELINES
));
458 else if (nSlotId
== SID_CONNECTOR_CURVE
||
459 nSlotId
== SID_CONNECTOR_CURVE_ARROW_START
||
460 nSlotId
== SID_CONNECTOR_CURVE_ARROW_END
||
461 nSlotId
== SID_CONNECTOR_CURVE_ARROWS
||
462 nSlotId
== SID_CONNECTOR_CURVE_CIRCLE_START
||
463 nSlotId
== SID_CONNECTOR_CURVE_CIRCLE_END
||
464 nSlotId
== SID_CONNECTOR_CURVE_CIRCLES
)
467 rAttr
.Put(SdrEdgeKindItem(SDREDGE_BEZIER
));
469 else if ( nSlotId
== SID_DRAW_CAPTION
|| nSlotId
== SID_DRAW_CAPTION_VERTICAL
)
472 Size
aSize(pObj
->GetLogicRect().GetSize());
473 rAttr
.Put( makeSdrTextMinFrameHeightItem( aSize
.Height() ) );
474 rAttr
.Put( makeSdrTextMinFrameWidthItem( aSize
.Width() ) );
475 rAttr
.Put( makeSdrTextAutoGrowHeightItem( true ) );
476 rAttr
.Put( makeSdrTextAutoGrowWidthItem( true ) );
478 // Support full with for vertical caption objects, too
479 if(SID_DRAW_CAPTION
== nSlotId
)
480 rAttr
.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK
) );
482 rAttr
.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_BLOCK
) );
484 rAttr
.Put( SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
) );
485 rAttr
.Put( makeSdrTextLeftDistItem( 100 ) );
486 rAttr
.Put( makeSdrTextRightDistItem( 100 ) );
487 rAttr
.Put( makeSdrTextUpperDistItem( 100 ) );
488 rAttr
.Put( makeSdrTextLowerDistItem( 100 ) );
490 else if (nSlotId
== SID_DRAW_MEASURELINE
)
493 SdPage
* pPage
= static_cast<SdPage
*>( mpView
->GetSdrPageView()->GetPage() );
494 OUString
aName(SD_RESSTR(STR_POOLSHEET_MEASURE
));
495 SfxStyleSheet
* pSheet
= static_cast<SfxStyleSheet
*>( pPage
->GetModel()->
496 GetStyleSheetPool()->
497 Find(aName
, SD_STYLE_FAMILY_GRAPHICS
));
498 DBG_ASSERT(pSheet
, "StyleSheet missing");
502 pObj
->SetStyleSheet(pSheet
, false);
505 SdrLayerAdmin
& rAdmin
= mpDoc
->GetLayerAdmin();
506 OUString
aStr(SD_RESSTR(STR_LAYER_MEASURELINES
));
507 pObj
->SetLayer(rAdmin
.GetLayerID(aStr
, false));
509 else if (nSlotId
== OBJ_CUSTOMSHAPE
)
515 * set line starts and ends for the object to be created
517 ::basegfx::B2DPolyPolygon
getPolygon( sal_uInt16 nResId
, SdrModel
* pDoc
)
519 ::basegfx::B2DPolyPolygon aRetval
;
520 XLineEndListRef pLineEndList
= pDoc
->GetLineEndList();
522 if( pLineEndList
.is() )
524 OUString
aArrowName( SVX_RES(nResId
) );
525 long nCount
= pLineEndList
->Count();
527 for( nIndex
= 0L; nIndex
< nCount
; nIndex
++ )
529 XLineEndEntry
* pEntry
= pLineEndList
->GetLineEnd(nIndex
);
530 if( pEntry
->GetName() == aArrowName
)
532 aRetval
= pEntry
->GetLineEnd();
541 void FuConstructRectangle::SetLineEnds(SfxItemSet
& rAttr
, SdrObject
* pObj
)
543 if ( (pObj
->GetObjIdentifier() == OBJ_EDGE
&&
544 nSlotId
!= SID_TOOL_CONNECTOR
&&
545 nSlotId
!= SID_CONNECTOR_LINE
&&
546 nSlotId
!= SID_CONNECTOR_LINES
&&
547 nSlotId
!= SID_CONNECTOR_CURVE
) ||
548 nSlotId
== SID_LINE_ARROW_START
||
549 nSlotId
== SID_LINE_ARROW_END
||
550 nSlotId
== SID_LINE_ARROWS
||
551 nSlotId
== SID_LINE_ARROW_CIRCLE
||
552 nSlotId
== SID_LINE_CIRCLE_ARROW
||
553 nSlotId
== SID_LINE_ARROW_SQUARE
||
554 nSlotId
== SID_LINE_SQUARE_ARROW
)
556 // set attributes of line start and ends
559 ::basegfx::B2DPolyPolygon
aArrow( getPolygon( RID_SVXSTR_ARROW
, mpDoc
) );
560 if( !aArrow
.count() )
562 ::basegfx::B2DPolygon aNewArrow
;
563 aNewArrow
.append(::basegfx::B2DPoint(10.0, 0.0));
564 aNewArrow
.append(::basegfx::B2DPoint(0.0, 30.0));
565 aNewArrow
.append(::basegfx::B2DPoint(20.0, 30.0));
566 aNewArrow
.setClosed(true);
567 aArrow
.append(aNewArrow
);
571 ::basegfx::B2DPolyPolygon
aCircle( getPolygon( RID_SVXSTR_CIRCLE
, mpDoc
) );
572 if( !aCircle
.count() )
574 ::basegfx::B2DPolygon aNewCircle
;
575 aNewCircle
= ::basegfx::tools::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0);
576 aNewCircle
.setClosed(true);
577 aCircle
.append(aNewCircle
);
581 ::basegfx::B2DPolyPolygon
aSquare( getPolygon( RID_SVXSTR_SQUARE
, mpDoc
) );
582 if( !aSquare
.count() )
584 ::basegfx::B2DPolygon aNewSquare
;
585 aNewSquare
.append(::basegfx::B2DPoint(0.0, 0.0));
586 aNewSquare
.append(::basegfx::B2DPoint(10.0, 0.0));
587 aNewSquare
.append(::basegfx::B2DPoint(10.0, 10.0));
588 aNewSquare
.append(::basegfx::B2DPoint(0.0, 10.0));
589 aNewSquare
.setClosed(true);
590 aSquare
.append(aNewSquare
);
593 SfxItemSet
aSet( mpDoc
->GetPool() );
594 mpView
->GetAttributes( aSet
);
596 // #i3908# Here, the default Line Start/End width for arrow construction is
597 // set. To have the same value in all situations (construction) in i3908
598 // it was decided to change the default to 0.03 cm for all situations.
599 long nWidth
= 300; // (1/100th mm)
601 // determine line width and calculate with it the line end width
602 if( aSet
.GetItemState( XATTR_LINEWIDTH
) != SfxItemState::DONTCARE
)
604 long nValue
= static_cast<const XLineWidthItem
&>( aSet
.Get( XATTR_LINEWIDTH
) ).GetValue();
611 case SID_CONNECTOR_ARROWS
:
612 case SID_CONNECTOR_LINE_ARROWS
:
613 case SID_CONNECTOR_LINES_ARROWS
:
614 case SID_CONNECTOR_CURVE_ARROWS
:
615 case SID_LINE_ARROWS
:
617 // connector with arrow ends
618 rAttr
.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW
), aArrow
));
619 rAttr
.Put(XLineStartWidthItem(nWidth
));
620 rAttr
.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW
), aArrow
));
621 rAttr
.Put(XLineEndWidthItem(nWidth
));
625 case SID_CONNECTOR_ARROW_START
:
626 case SID_CONNECTOR_LINE_ARROW_START
:
627 case SID_CONNECTOR_LINES_ARROW_START
:
628 case SID_CONNECTOR_CURVE_ARROW_START
:
629 case SID_LINE_ARROW_START
:
630 case SID_LINE_ARROW_CIRCLE
:
631 case SID_LINE_ARROW_SQUARE
:
633 // connector with arrow start
634 rAttr
.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW
), aArrow
));
635 rAttr
.Put(XLineStartWidthItem(nWidth
));
639 case SID_CONNECTOR_ARROW_END
:
640 case SID_CONNECTOR_LINE_ARROW_END
:
641 case SID_CONNECTOR_LINES_ARROW_END
:
642 case SID_CONNECTOR_CURVE_ARROW_END
:
643 case SID_LINE_ARROW_END
:
644 case SID_LINE_CIRCLE_ARROW
:
645 case SID_LINE_SQUARE_ARROW
:
647 // connector with arrow end
648 rAttr
.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW
), aArrow
));
649 rAttr
.Put(XLineEndWidthItem(nWidth
));
653 case SID_CONNECTOR_CIRCLES
:
654 case SID_CONNECTOR_LINE_CIRCLES
:
655 case SID_CONNECTOR_LINES_CIRCLES
:
656 case SID_CONNECTOR_CURVE_CIRCLES
:
658 // connector with circle ends
659 rAttr
.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE
), aCircle
));
660 rAttr
.Put(XLineStartWidthItem(nWidth
));
661 rAttr
.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE
), aCircle
));
662 rAttr
.Put(XLineEndWidthItem(nWidth
));
666 case SID_CONNECTOR_CIRCLE_START
:
667 case SID_CONNECTOR_LINE_CIRCLE_START
:
668 case SID_CONNECTOR_LINES_CIRCLE_START
:
669 case SID_CONNECTOR_CURVE_CIRCLE_START
:
671 // connector with circle start
672 rAttr
.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE
), aCircle
));
673 rAttr
.Put(XLineStartWidthItem(nWidth
));
677 case SID_CONNECTOR_CIRCLE_END
:
678 case SID_CONNECTOR_LINE_CIRCLE_END
:
679 case SID_CONNECTOR_LINES_CIRCLE_END
:
680 case SID_CONNECTOR_CURVE_CIRCLE_END
:
682 // connector with circle ends
683 rAttr
.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE
), aCircle
));
684 rAttr
.Put(XLineEndWidthItem(nWidth
));
689 // and again, for the still missing ends
692 case SID_LINE_ARROW_CIRCLE
:
695 rAttr
.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE
), aCircle
));
696 rAttr
.Put(XLineEndWidthItem(nWidth
));
700 case SID_LINE_CIRCLE_ARROW
:
703 rAttr
.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE
), aCircle
));
704 rAttr
.Put(XLineStartWidthItem(nWidth
));
708 case SID_LINE_ARROW_SQUARE
:
711 rAttr
.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_SQUARE
), aSquare
));
712 rAttr
.Put(XLineEndWidthItem(nWidth
));
716 case SID_LINE_SQUARE_ARROW
:
719 rAttr
.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_SQUARE
), aSquare
));
720 rAttr
.Put(XLineStartWidthItem(nWidth
));
727 SdrObject
* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID
, const Rectangle
& rRectangle
)
729 DBG_ASSERT( (nID
!= SID_DRAW_FONTWORK
) && (nID
!= SID_DRAW_FONTWORK_VERTICAL
), "FuConstRectangle::CreateDefaultObject can not create Fontwork shapes!" );
731 // case SID_DRAW_LINE:
732 // case SID_DRAW_XLINE:
733 // case SID_DRAW_MEASURELINE:
734 // case SID_LINE_ARROW_START:
735 // case SID_LINE_ARROW_END:
736 // case SID_LINE_ARROWS:
737 // case SID_LINE_ARROW_CIRCLE:
738 // case SID_LINE_CIRCLE_ARROW:
739 // case SID_LINE_ARROW_SQUARE:
740 // case SID_LINE_SQUARE_ARROW:
741 // case SID_DRAW_RECT:
742 // case SID_DRAW_RECT_NOFILL:
743 // case SID_DRAW_RECT_ROUND:
744 // case SID_DRAW_RECT_ROUND_NOFILL:
745 // case SID_DRAW_SQUARE:
746 // case SID_DRAW_SQUARE_NOFILL:
747 // case SID_DRAW_SQUARE_ROUND:
748 // case SID_DRAW_SQUARE_ROUND_NOFILL:
749 // case SID_DRAW_ELLIPSE:
750 // case SID_DRAW_ELLIPSE_NOFILL:
751 // case SID_DRAW_CIRCLE:
752 // case SID_DRAW_CIRCLE_NOFILL:
753 // case SID_DRAW_CAPTION:
754 // case SID_DRAW_CAPTION_VERTICAL:
755 // case SID_TOOL_CONNECTOR:
756 // case SID_CONNECTOR_ARROW_START:
757 // case SID_CONNECTOR_ARROW_END:
758 // case SID_CONNECTOR_ARROWS:
759 // case SID_CONNECTOR_CIRCLE_START:
760 // case SID_CONNECTOR_CIRCLE_END:
761 // case SID_CONNECTOR_CIRCLES:
762 // case SID_CONNECTOR_LINE:
763 // case SID_CONNECTOR_LINE_ARROW_START:
764 // case SID_CONNECTOR_LINE_ARROW_END:
765 // case SID_CONNECTOR_LINE_ARROWS:
766 // case SID_CONNECTOR_LINE_CIRCLE_START:
767 // case SID_CONNECTOR_LINE_CIRCLE_END:
768 // case SID_CONNECTOR_LINE_CIRCLES:
769 // case SID_CONNECTOR_CURVE:
770 // case SID_CONNECTOR_CURVE_ARROW_START:
771 // case SID_CONNECTOR_CURVE_ARROW_END:
772 // case SID_CONNECTOR_CURVE_ARROWS:
773 // case SID_CONNECTOR_CURVE_CIRCLE_START:
774 // case SID_CONNECTOR_CURVE_CIRCLE_END:
775 // case SID_CONNECTOR_CURVE_CIRCLES:
776 // case SID_CONNECTOR_LINES:
777 // case SID_CONNECTOR_LINES_ARROW_START:
778 // case SID_CONNECTOR_LINES_ARROW_END:
779 // case SID_CONNECTOR_LINES_ARROWS:
780 // case SID_CONNECTOR_LINES_CIRCLE_START:
781 // case SID_CONNECTOR_LINES_CIRCLE_END:
782 // case SID_CONNECTOR_LINES_CIRCLES:
784 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
785 mpView
->GetCurrentObjInventor(), mpView
->GetCurrentObjIdentifier(),
790 Rectangle
aRect(rRectangle
);
792 if(SID_DRAW_SQUARE
== nID
||
793 SID_DRAW_SQUARE_NOFILL
== nID
||
794 SID_DRAW_SQUARE_ROUND
== nID
||
795 SID_DRAW_SQUARE_ROUND_NOFILL
== nID
||
796 SID_DRAW_CIRCLE
== nID
||
797 SID_DRAW_CIRCLE_NOFILL
== nID
)
800 ImpForceQuadratic(aRect
);
803 Point aStart
= aRect
.TopLeft();
804 Point aEnd
= aRect
.BottomRight();
810 case SID_LINE_ARROW_START
:
811 case SID_LINE_ARROW_END
:
812 case SID_LINE_ARROWS
:
813 case SID_LINE_ARROW_CIRCLE
:
814 case SID_LINE_CIRCLE_ARROW
:
815 case SID_LINE_ARROW_SQUARE
:
816 case SID_LINE_SQUARE_ARROW
:
818 if(pObj
->ISA(SdrPathObj
))
820 sal_Int32
nYMiddle((aRect
.Top() + aRect
.Bottom()) / 2);
822 ::basegfx::B2DPolygon aB2DPolygon
;
823 aB2DPolygon
.append(::basegfx::B2DPoint(aStart
.X(), nYMiddle
));
824 aB2DPolygon
.append(::basegfx::B2DPoint(aEnd
.X(), nYMiddle
));
825 static_cast<SdrPathObj
*>(pObj
)->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon
));
829 OSL_FAIL("Object is NO line object");
835 case SID_DRAW_MEASURELINE
:
837 if(pObj
->ISA(SdrMeasureObj
))
839 sal_Int32
nYMiddle((aRect
.Top() + aRect
.Bottom()) / 2);
840 static_cast<SdrMeasureObj
*>(pObj
)->SetPoint(Point(aStart
.X(), nYMiddle
), 0);
841 static_cast<SdrMeasureObj
*>(pObj
)->SetPoint(Point(aEnd
.X(), nYMiddle
), 1);
845 OSL_FAIL("Object is NO measure object");
851 case SID_TOOL_CONNECTOR
:
852 case SID_CONNECTOR_ARROW_START
:
853 case SID_CONNECTOR_ARROW_END
:
854 case SID_CONNECTOR_ARROWS
:
855 case SID_CONNECTOR_CIRCLE_START
:
856 case SID_CONNECTOR_CIRCLE_END
:
857 case SID_CONNECTOR_CIRCLES
:
858 case SID_CONNECTOR_LINE
:
859 case SID_CONNECTOR_LINE_ARROW_START
:
860 case SID_CONNECTOR_LINE_ARROW_END
:
861 case SID_CONNECTOR_LINE_ARROWS
:
862 case SID_CONNECTOR_LINE_CIRCLE_START
:
863 case SID_CONNECTOR_LINE_CIRCLE_END
:
864 case SID_CONNECTOR_LINE_CIRCLES
:
865 case SID_CONNECTOR_CURVE
:
866 case SID_CONNECTOR_CURVE_ARROW_START
:
867 case SID_CONNECTOR_CURVE_ARROW_END
:
868 case SID_CONNECTOR_CURVE_ARROWS
:
869 case SID_CONNECTOR_CURVE_CIRCLE_START
:
870 case SID_CONNECTOR_CURVE_CIRCLE_END
:
871 case SID_CONNECTOR_CURVE_CIRCLES
:
872 case SID_CONNECTOR_LINES
:
873 case SID_CONNECTOR_LINES_ARROW_START
:
874 case SID_CONNECTOR_LINES_ARROW_END
:
875 case SID_CONNECTOR_LINES_ARROWS
:
876 case SID_CONNECTOR_LINES_CIRCLE_START
:
877 case SID_CONNECTOR_LINES_CIRCLE_END
:
878 case SID_CONNECTOR_LINES_CIRCLES
:
880 if(pObj
->ISA(SdrEdgeObj
))
882 static_cast<SdrEdgeObj
*>(pObj
)->SetTailPoint(false, aStart
);
883 static_cast<SdrEdgeObj
*>(pObj
)->SetTailPoint(true, aEnd
);
887 OSL_FAIL("Object is NO connector object");
892 case SID_DRAW_CAPTION
:
893 case SID_DRAW_CAPTION_VERTICAL
:
895 if(pObj
->ISA(SdrCaptionObj
))
897 bool bIsVertical(SID_DRAW_CAPTION_VERTICAL
== nID
);
899 static_cast<SdrTextObj
*>(pObj
)->SetVerticalWriting(bIsVertical
);
903 SfxItemSet
aSet(pObj
->GetMergedItemSet());
904 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER
));
905 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
906 pObj
->SetMergedItemSet(aSet
);
909 // The default text is not inserted anymore.
910 // String aText(SdResId(STR_POOLSHEET_TEXT));
911 // ((SdrCaptionObj*)pObj)->SetText(aText);
913 static_cast<SdrCaptionObj
*>(pObj
)->SetLogicRect(aRect
);
914 static_cast<SdrCaptionObj
*>(pObj
)->SetTailPos(
915 aRect
.TopLeft() - Point(aRect
.GetWidth() / 2, aRect
.GetHeight() / 2));
919 OSL_FAIL("Object is NO caption object");
927 pObj
->SetLogicRect(aRect
);
933 SfxItemSet
aAttr(mpDoc
->GetPool());
934 SetStyleSheet(aAttr
, pObj
);
935 SetAttributes(aAttr
, pObj
);
936 SetLineEnds(aAttr
, pObj
);
937 pObj
->SetMergedItemSet(aAttr
);
943 } // end of namespace sd
945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */