xref: /aoo42x/main/sw/source/ui/ribbar/drawbase.cxx (revision 5f22f2ef)
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_sw.hxx"
26 
27 #include <hintids.hxx>
28 #include <tools/list.hxx>
29 #include <svx/svdview.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svl/ptitem.hxx>
32 #include <editeng/sizeitem.hxx>
33 #include <sfx2/request.hxx>
34 #include <sfx2/bindings.hxx>
35 #include <fmtclds.hxx>
36 #include <frmfmt.hxx>
37 #include "cmdid.h"
38 #include "basesh.hxx"
39 #include "view.hxx"
40 #include "wrtsh.hxx"
41 #include "drawbase.hxx"
42 #include "edtwin.hxx"
43 #include "caption.hxx"
44 #include "swundo.hxx"
45 #include <SwRewriter.hxx>
46 #include "comcore.hrc"
47 
48 using namespace ::com::sun::star;
49 
50 extern sal_Bool bNoInterrupt;		// in mainwn.cxx
51 
52 #define MINMOVE ((sal_uInt16)m_pSh->GetOut()->PixelToLogic(Size(m_pSh->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width())
53 
54 
55 /*************************************************************************
56 |*
57 |* Konstruktor
58 |*
59 \************************************************************************/
60 
61 
SwDrawBase(SwWrtShell * pSwWrtShell,SwEditWin * pWindow,SwView * pSwView)62 SwDrawBase::SwDrawBase(SwWrtShell* pSwWrtShell, SwEditWin* pWindow, SwView* pSwView) :
63     m_pView(pSwView),
64     m_pSh(pSwWrtShell),
65     m_pWin(pWindow),
66     m_nSlotId(USHRT_MAX),
67     m_bCreateObj(sal_True),
68     m_bInsForm(sal_False)
69 {
70     if ( !m_pSh->HasDrawView() )
71         m_pSh->MakeDrawView();
72 }
73 
74 /*************************************************************************
75 |*
76 |* Destruktor
77 |*
78 \************************************************************************/
79 
~SwDrawBase()80 __EXPORT SwDrawBase::~SwDrawBase()
81 {
82     if (m_pView->GetWrtShellPtr()) // Im view-Dtor koennte die wrtsh bereits geloescht worden sein...
83         m_pSh->GetDrawView()->SetEditMode(sal_True);
84 }
85 
86 /*************************************************************************
87 |*
88 |* MouseButtonDown-event
89 |*
90 \************************************************************************/
91 
92 
MouseButtonDown(const MouseEvent & rMEvt)93 sal_Bool SwDrawBase::MouseButtonDown(const MouseEvent& rMEvt)
94 {
95 	sal_Bool bReturn = sal_False;
96 
97     SdrView *pSdrView = m_pSh->GetDrawView();
98 
99 	// #i33136#
100 	// pSdrView->SetOrtho(rMEvt.IsShift());
101 	pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
102 	pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
103 
104 	if (rMEvt.IsMod2())
105 	{
106 		pSdrView->SetCreate1stPointAsCenter(sal_True);
107 		pSdrView->SetResizeAtCenter(sal_True);
108 	}
109 	else
110 	{
111 		pSdrView->SetCreate1stPointAsCenter(sal_False);
112 		pSdrView->SetResizeAtCenter(sal_False);
113 	}
114 
115 	SdrViewEvent aVEvt;
116 	SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
117 
118 	// Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode)
119     if (rMEvt.IsLeft() && !m_pWin->IsDrawAction())
120 	{
121         if (IsCreateObj() && (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
122 		{
123 			bNoInterrupt = sal_True;
124             m_pWin->CaptureMouse();
125 
126             m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
127 
128             bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), m_aStartPos);
129 
130 			SetDrawPointer();
131 
132 			if ( bReturn )
133                 m_pWin->SetDrawAction(sal_True);
134 		}
135 		else if (!pSdrView->IsAction())
136 		{
137 			/**********************************************************************
138 			* BEZIER-EDITOR
139 			**********************************************************************/
140             m_pWin->CaptureMouse();
141             m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
142             sal_uInt16 nEditMode = m_pWin->GetBezierMode();
143 
144 			if (eHit == SDRHIT_HANDLE && aVEvt.pHdl->GetKind() == HDL_BWGT)
145 			{
146 				/******************************************************************
147 				* Handle draggen
148 				******************************************************************/
149 				bNoInterrupt = sal_True;
150                 bReturn = pSdrView->BegDragObj(m_aStartPos, (OutputDevice*) NULL, aVEvt.pHdl);
151                 m_pWin->SetDrawAction(sal_True);
152 			}
153 			else if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
154 			{
155 				/******************************************************************
156 				* Klebepunkt einfuegen
157 				******************************************************************/
158 				bNoInterrupt = sal_True;
159                 bReturn = pSdrView->BegInsObjPoint(m_aStartPos, rMEvt.IsMod1());
160                 m_pWin->SetDrawAction(sal_True);
161 			}
162 			else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
163 			{
164 				/******************************************************************
165 				* Klebepunkt selektieren
166 				******************************************************************/
167 				if (!rMEvt.IsShift())
168 					pSdrView->UnmarkAllPoints();
169 
170                 bReturn = pSdrView->BegMarkPoints(m_aStartPos);
171                 m_pWin->SetDrawAction(sal_True);
172 			}
173 			else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
174 			{
175 				/******************************************************************
176 				* Objekt verschieben
177 				******************************************************************/
178 				return sal_False;
179 			}
180 			else if (eHit == SDRHIT_HANDLE)
181 			{
182 				/******************************************************************
183 				* Klebepunkt selektieren
184 				******************************************************************/
185 				if (pSdrView->HasMarkablePoints() && (!pSdrView->IsPointMarked(aVEvt.pHdl) || rMEvt.IsShift()))
186 				{
187 					SdrHdl*	pHdl = NULL;
188 
189 					if (!rMEvt.IsShift())
190 					{
191 						pSdrView->UnmarkAllPoints();
192                         pHdl = pSdrView->PickHandle(m_aStartPos);
193 					}
194 					else
195 					{
196 						if (pSdrView->IsPointMarked(aVEvt.pHdl))
197 						{
198 							bReturn = pSdrView->UnmarkPoint(*aVEvt.pHdl);
199 							pHdl = NULL;
200 						}
201 						else
202 						{
203                             pHdl = pSdrView->PickHandle(m_aStartPos);
204 						}
205 					}
206 
207 					if (pHdl)
208 					{
209 						bNoInterrupt = sal_True;
210 						pSdrView->MarkPoint(*pHdl);
211 //                      bReturn = pSdrView->BegDragObj(m_aStartPos, (OutputDevice*) NULL, pHdl);
212 //                      m_pWin->SetDrawAction(sal_True);
213 					}
214 				}
215 			}
216 			else
217 			{
218 				/******************************************************************
219 				* Objekt selektieren oder draggen
220 				******************************************************************/
221                 if (m_pSh->IsObjSelectable(m_aStartPos) && eHit == SDRHIT_UNMARKEDOBJECT)
222 				{
223 					if (pSdrView->HasMarkablePoints())
224 						pSdrView->UnmarkAllPoints();
225 
226 					bNoInterrupt = sal_False;
227 					// Drag im edtwin verwenden
228 					return sal_False;
229 				}
230 
231 				bNoInterrupt = sal_True;
232 
233                 if (m_pSh->IsObjSelected())
234 				{
235 					if (!rMEvt.IsShift())
236 					{
237 						if (!pSdrView->HasMarkablePoints())
238 						{
239 							//JP 10.10.2001: Bug 89619 - don't scroll the
240 							//				cursor into the visible area
241                             sal_Bool bUnlockView = !m_pSh->IsViewLocked();
242                             m_pSh->LockView( sal_True ); //lock visible section
243                             m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX)); // Alles deselektieren
244 							if( bUnlockView )
245                                 m_pSh->LockView( sal_False );
246 						}
247 						else
248 							pSdrView->UnmarkAllPoints();
249 					}
250 				}
251                 if (!m_pSh->IsSelFrmMode())
252                     m_pSh->EnterSelFrmMode(NULL);
253 
254                 if( 0 != (bReturn = m_pSh->BeginMark(m_aStartPos)) )
255                     m_pWin->SetDrawAction(sal_True);
256 
257 				SetDrawPointer();
258 			}
259 		}
260 	}
261 	return bReturn;
262 }
263 
264 /*************************************************************************
265 |*
266 |* MouseMove-event
267 |*
268 \************************************************************************/
269 
270 
MouseMove(const MouseEvent & rMEvt)271 sal_Bool SwDrawBase::MouseMove(const MouseEvent& rMEvt)
272 {
273     SdrView *pSdrView = m_pSh->GetDrawView();
274     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
275 	sal_Bool bRet = sal_False;
276 
277     if (IsCreateObj() && !m_pWin->IsDrawSelMode() && pSdrView->IsCreateObj())
278 	{
279 		// #i33136#
280 		// pSdrView->SetOrtho(rMEvt.IsShift());
281 		pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
282 		pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
283 
284         m_pSh->MoveCreate(aPnt);
285 		bRet = sal_True;
286 	}
287 	else if (pSdrView->IsAction() || pSdrView->IsInsObjPoint() || pSdrView->IsMarkPoints())
288 	{
289         m_pSh->MoveMark(aPnt);
290 		bRet = sal_True;
291 	}
292 
293 	return (bRet);
294 }
295 
296 /*************************************************************************
297 |*
298 |* MouseButtonUp-event
299 |*
300 \************************************************************************/
301 
302 
MouseButtonUp(const MouseEvent & rMEvt)303 sal_Bool SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt)
304 {
305 	sal_Bool bReturn = sal_False;
306 	sal_Bool bCheckShell = sal_False;
307 	sal_Bool bAutoCap = sal_False;
308 
309     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
310 
311     if (IsCreateObj() && m_pSh->IsDrawCreate() && !m_pWin->IsDrawSelMode())
312 	{
313         const SdrObjKind nDrawMode = m_pWin->GetSdrDrawMode();
314 		//objects with multiple point may end at the start position
315 		sal_Bool bMultiPoint = OBJ_PLIN == nDrawMode ||
316                                 OBJ_PATHLINE == nDrawMode ||
317 								OBJ_FREELINE == nDrawMode;
318         if(rMEvt.IsRight() || (aPnt == m_aStartPos && !bMultiPoint))
319 		{
320             m_pSh->BreakCreate();
321             m_pView->LeaveDrawCreate();
322 		}
323 		else
324 		{
325             if (OBJ_NONE == nDrawMode)
326             {
327                 SwRewriter aRewriter;
328 
329                 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_FRAME));
330                 m_pSh->StartUndo(UNDO_INSERT, &aRewriter);
331             }
332 
333             m_pSh->EndCreate(SDRCREATE_FORCEEND);
334             if (OBJ_NONE == nDrawMode)   // Textrahmen eingefuegt
335 			{
336                uno::Reference< frame::XDispatchRecorder > xRecorder =
337                     m_pSh->GetView().GetViewFrame()->GetBindings().GetRecorder();
338                 if ( xRecorder.is() )
339                 {
340                     SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME);
341                         aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME,
342                                 static_cast<sal_uInt16>(FLY_AT_PARA) ));
343                         aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff()));
344                         aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize()));
345 					aReq.Done();
346 				}
347                 bAutoCap = sal_True;
348                 if(m_pWin->GetFrmColCount() > 1)
349 				{
350                     SfxItemSet aSet(m_pView->GetPool(),RES_COL,RES_COL);
351 					SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL));
352                     aCol.Init(m_pWin->GetFrmColCount(), aCol.GetGutterWidth(), aCol.GetWishWidth());
353 					aSet.Put(aCol);
354 					// Vorlagen-AutoUpdate
355                     SwFrmFmt* pFmt = m_pSh->GetCurFrmFmt();
356 					if(pFmt && pFmt->IsAutoUpdateFmt())
357                         m_pSh->AutoUpdateFrame(pFmt, aSet);
358 					else
359                         m_pSh->SetFlyFrmAttr( aSet );
360 				}
361 			}
362             if (m_pWin->GetSdrDrawMode() == OBJ_NONE)
363             {
364                 m_pSh->EndUndo();
365             }
366 		}
367 
368 		bReturn = sal_True;
369 
370 		EnterSelectMode(rMEvt);
371 	}
372 	else
373 	{
374         SdrView *pSdrView = m_pSh->GetDrawView();
375 
376 		if (!pSdrView->HasMarkablePoints())
377 		{
378 			/**********************************************************************
379 			* KEIN BEZIER_EDITOR
380 			**********************************************************************/
381             if ((m_pSh->GetDrawView()->IsMarkObj() || m_pSh->GetDrawView()->IsMarkPoints())
382 				 && rMEvt.IsLeft())
383 			{
384                 bReturn = m_pSh->EndMark();
385 
386                 m_pWin->SetDrawAction(sal_False);
387 
388                 if (aPnt == m_aStartPos && m_pSh->IsObjSelectable(aPnt))
389 				{
390                     m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
391                                    m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT : 0);
392 
393                     if (!m_pSh->IsObjSelected())
394 					{
395                         m_pView->LeaveDrawCreate();    // In Selektionsmode wechseln
396 
397                         m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
398 
399                         if (m_pSh->IsSelFrmMode())
400                             m_pSh->LeaveSelFrmMode();
401 					}
402                     m_pView->NoRotate();
403 
404 					bCheckShell = sal_True;	// ggf BezierShell anwerfen
405 				}
406                 else if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
407 				{
408                     if (m_pSh->IsObjSelectable(aPnt))
409                         m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
410                             m_pSh->IsSelFrmMode() ) ? SW_ADD_SELECT : 0 );
411 					else
412 					{
413                         m_pView->LeaveDrawCreate();
414                         if (m_pSh->IsSelFrmMode())
415                             m_pSh->LeaveSelFrmMode();
416 					}
417                     m_pView->NoRotate();
418 
419 					bReturn = sal_True;
420 				}
421 			}
422 		}
423 		else
424 		{
425 			/**********************************************************************
426 			* BEZIER_EDITOR
427 			**********************************************************************/
428 			if ( pSdrView->IsAction() )
429 			{
430 				if ( pSdrView->IsInsObjPoint() )
431 					bReturn = pSdrView->EndInsObjPoint(SDRCREATE_FORCEEND);
432 				else if (pSdrView->IsMarkPoints() )
433 					bReturn = pSdrView->EndMarkPoints();
434 				else
435 				{
436 					pSdrView->EndAction();
437 					bReturn = sal_True;
438 				}
439                 m_pWin->SetDrawAction(sal_False);
440 
441                 if (aPnt == m_aStartPos)
442 				{
443                     if (!m_pSh->IsObjSelectable(aPnt))
444                         m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX));
445 					else if (!bReturn)
446 					{
447 						if (!rMEvt.IsShift())
448 							pSdrView->UnmarkAllPoints();
449                         m_pSh->SelectObj(aPnt, (rMEvt.IsShift() &&
450                                        m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT :0);
451 					}
452 
453                     if (!m_pSh->IsObjSelected())
454 					{
455                         m_pView->LeaveDrawCreate();    // In Selektionsmode wechseln
456 
457                         m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
458 
459                         if (m_pSh->IsSelFrmMode())
460                             m_pSh->LeaveSelFrmMode();
461 					}
462                     m_pView->NoRotate();
463 
464 					bCheckShell = sal_True;	// ggf BezierShell anwerfen
465 				}
466 			}
467 
468 			SetDrawPointer();
469 
470             if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
471 			{
472                 m_pView->LeaveDrawCreate();
473                 if (m_pSh->IsSelFrmMode())
474                     m_pSh->LeaveSelFrmMode();
475 
476                 m_pView->NoRotate();
477 				bReturn = sal_True;
478 			}
479 		}
480 	}
481 
482 	if (bCheckShell)
483         m_pView->AttrChangedNotify( m_pSh ); // ggf BezierShell anwerfen
484 
485 	//!!!!!!!!!! Achtung Suizid !!!!!!!!!!! Sollte alles mal erneuert werden
486 	if ( bAutoCap )
487         m_pView->AutoCaption(FRAME_CAP);   //Kann derzeit nur FRAME sein, sonst auf
488 										//enums umstellen
489 	return (bReturn);
490 }
491 
492 /*************************************************************************
493 |*
494 |* Function aktivieren
495 |*
496 \************************************************************************/
497 
498 
Activate(const sal_uInt16 nSlot)499 void SwDrawBase::Activate(const sal_uInt16 nSlot)
500 {
501     SetSlotId(nSlot);
502     SdrView *pSdrView = m_pSh->GetDrawView();
503 
504     pSdrView->SetCurrentObj( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()) );
505 	pSdrView->SetEditMode(sal_False);
506 
507 	SetDrawPointer();
508     m_pSh->NoEdit();
509 }
510 
511 /*************************************************************************
512 |*
513 |* Function deaktivieren
514 |*
515 \************************************************************************/
516 
517 
Deactivate()518 void __EXPORT SwDrawBase::Deactivate()
519 {
520     SdrView *pSdrView = m_pSh->GetDrawView();
521 	pSdrView->SetOrtho(sal_False);
522 	pSdrView->SetAngleSnapEnabled(sal_False);
523 
524     if (m_pWin->IsDrawAction() && m_pSh->IsDrawCreate())
525         m_pSh->BreakCreate();
526 
527     m_pWin->SetDrawAction(sal_False);
528 
529     m_pWin->ReleaseMouse();
530 	bNoInterrupt = sal_False;
531 
532 //  if(!m_pSh->IsObjSelected())
533 //      m_pSh->Edit();
534 
535     if(m_pWin->GetApplyTemplate())
536         m_pWin->SetApplyTemplate(SwApplyTemplate());
537     m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
538 }
539 
540 /*************************************************************************
541 |*
542 |* Tastaturereignisse bearbeiten
543 |*
544 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
545 |* sal_False.
546 |*
547 \************************************************************************/
548 
549 
KeyInput(const KeyEvent & rKEvt)550 sal_Bool SwDrawBase::KeyInput(const KeyEvent& rKEvt)
551 {
552 	sal_Bool bReturn = sal_False;
553 	sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
554 
555 	switch (nCode)
556 	{
557 		case KEY_ESCAPE:
558 		{
559             if (m_pWin->IsDrawAction())
560 			{
561 				BreakCreate();
562                 m_pView->LeaveDrawCreate();
563 			}
564 
565 			bReturn = sal_True;
566 		}
567 		break;
568 
569 		case KEY_DELETE:
570 		{
571             m_pSh->DelSelectedObj();
572 			bReturn = sal_True;
573 		}
574 		break;
575 
576 		case KEY_UP:
577 		case KEY_DOWN:
578 		case KEY_LEFT:
579 		case KEY_RIGHT:
580 		{
581             SdrView *pSdrView = m_pSh->GetDrawView();
582 
583 			if (!pSdrView->IsTextEdit())
584 			{
585 				long nX = 0;
586 				long nY = 0;
587 
588 				if (nCode == KEY_UP)
589 				{
590 					// Scroll nach oben
591 					nX = 0;
592 					nY =-1;
593 				}
594 				else if (nCode == KEY_DOWN)
595 				{
596 					// Scroll nach unten
597 					nX = 0;
598 					nY = 1;
599 				}
600 				else if (nCode == KEY_LEFT)
601 				{
602 					// Scroll nach links
603 					nX =-1;
604 					nY = 0;
605 				}
606 				else if (nCode == KEY_RIGHT)
607 				{
608 					// Scroll nach rechts
609 					nX = 1;
610 					nY = 0;
611 				}
612 
613 				if (pSdrView->AreObjectsMarked() && rKEvt.GetKeyCode().IsMod2())
614 				{
615 					// Objekte verschieben
616 					nX *= 100;
617 					nY *= 100;
618 					pSdrView->MoveAllMarked(Size(nX, nY));
619 				}
620 
621 				bReturn = sal_True;
622 			}
623 		}
624 		break;
625 	}
626 
627 	return (bReturn);
628 }
629 
630 
631 /*************************************************************************
632 |*
633 |* Tastaturereignisse bearbeiten
634 |*
635 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
636 |* sal_False.
637 |*
638 \************************************************************************/
639 
640 
BreakCreate()641 void SwDrawBase::BreakCreate()
642 {
643     m_pSh->BreakCreate();
644     m_pWin->SetDrawAction(sal_False);
645     m_pWin->ReleaseMouse();
646 
647 	Deactivate();
648 //  m_pView->LeaveDrawCreate();
649 }
650 
651 /*************************************************************************
652 |*
653 |* Mauspointer umschalten
654 |*
655 \************************************************************************/
656 
657 
SetDrawPointer()658 void SwDrawBase::SetDrawPointer()
659 {
660     SdrView *pSdrView = m_pSh->GetDrawView();
661         Point aPnt(m_pWin->OutputToScreenPixel(m_pWin->GetPointerPosPixel()));
662     aPnt = m_pWin->PixelToLogic(m_pWin->ScreenToOutputPixel(aPnt));
663     const Pointer aPointTyp = pSdrView->GetPreferedPointer(aPnt, m_pSh->GetOut());
664 	const Pointer aDrawPt(aPointTyp);
665     m_pWin->SetPointer(aDrawPt);
666 }
667 
668 /*************************************************************************
669 |*
670 |* Ggf in Selektionsmode wechseln
671 |*
672 \************************************************************************/
673 
EnterSelectMode(const MouseEvent & rMEvt)674 void SwDrawBase::EnterSelectMode(const MouseEvent& rMEvt)
675 {
676     m_pWin->SetDrawAction(sal_False);
677 
678     if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
679 	{
680         Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
681 
682         if (m_pSh->IsObjSelectable(aPnt))
683 		{
684             m_pSh->SelectObj(aPnt);
685             if (rMEvt.GetModifier() == KEY_SHIFT || !m_pSh->IsObjSelected())
686 			{
687                 m_pView->LeaveDrawCreate();    // In Selektionsmode wechseln
688 
689                 m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
690 			}
691 		}
692 		else
693 		{
694             m_pView->LeaveDrawCreate();
695             if (m_pSh->IsSelFrmMode())
696                 m_pSh->LeaveSelFrmMode();
697 		}
698         m_pView->NoRotate();
699 	}
700 }
701 /* -----------------------------03.04.2002 10:52------------------------------
702 
703  ---------------------------------------------------------------------------*/
CreateDefaultObject()704 void SwDrawBase::CreateDefaultObject()
705 {
706     Point aStartPos = GetDefaultCenterPos();
707     Point aEndPos(aStartPos);
708     aStartPos.X() -= 8 * MM50;
709     aStartPos.Y() -= 4 * MM50;
710     aEndPos.X() += 8 * MM50;
711     aEndPos.Y() += 4 * MM50;
712     Rectangle aRect(aStartPos, aEndPos);
713     m_pSh->CreateDefaultShape( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), aRect, m_nSlotId);
714 }
715 /* -----------------25.10.2002 14:14-----------------
716  *
717  * --------------------------------------------------*/
GetDefaultCenterPos()718 Point  SwDrawBase::GetDefaultCenterPos()
719 {
720     Size aDocSz(m_pSh->GetDocSize());
721     const SwRect& rVisArea = m_pSh->VisArea();
722     Point aStartPos = rVisArea.Center();
723     if(rVisArea.Width() > aDocSz.Width())
724         aStartPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
725     if(rVisArea.Height() > aDocSz.Height())
726         aStartPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
727     return aStartPos;
728 }
729 
730 // #i33136#
doConstructOrthogonal() const731 bool SwDrawBase::doConstructOrthogonal() const
732 {
733 	return false;
734 }
735 
736 // eof
737