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