xref: /aoo42x/main/sc/source/ui/drawfunc/futext.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 #include <svx/svddef.hxx>
32 #include <svx/svdoutl.hxx>
33 #include <editeng/outlobj.hxx>
34 #include <svx/sdtaaitm.hxx>
35 #include <svx/sdtacitm.hxx>
36 #include <svx/svdotext.hxx>
37 #include <editeng/unolingu.hxx>
38 #include <svx/svdocapt.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <svx/svxids.hrc>
43 #include <editeng/eeitem.hxx>
44 #include <svl/itemset.hxx>
45 
46 #include "futext.hxx"
47 #include "drwlayer.hxx"
48 #include "sc.hrc"
49 #include "tabvwsh.hxx"
50 #include "drawview.hxx"
51 
52 // #98185# Create default drawing objects via keyboard
53 #include "scresid.hxx"
54 
55 //	Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
56 //!	fusel,fuconstr,futext - zusammenfassen!
57 #define SC_MAXDRAGMOVE	3
58 
59 //------------------------------------------------------------------
60 
61 void lcl_InvalidateAttribs( SfxBindings& rBindings )
62 {
63 	rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
64 	rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
65 	rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
66 	rBindings.Invalidate( SID_ULINE_VAL_NONE );
67 	rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
68 	rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
69 	rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
70 	rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
71 	rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
72 	rBindings.Invalidate( SID_ATTR_CHAR_FONT );
73 	rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
74 	rBindings.Invalidate( SID_ALIGNLEFT );
75 	rBindings.Invalidate( SID_ALIGNCENTERHOR );
76 	rBindings.Invalidate( SID_ALIGNRIGHT );
77 	rBindings.Invalidate( SID_ALIGNBLOCK );
78 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
79 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
80 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
81 	rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
82 	rBindings.Invalidate( SID_SET_SUB_SCRIPT );
83 	rBindings.Invalidate( SID_HYPERLINK_GETLINK );
84 	rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
85 	rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
86     rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
87     rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
88     // pseudo slots for Format menu
89     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
90     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
91     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
92     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
93 }
94 
95 void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj )
96 {
97 	// use hyphenator only if hyphenation attribute is set
98 	if ( pObj && ((const SfxBoolItem&)pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) {
99             com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() );
100     		rOutliner.SetHyphenator( xHyphenator );
101     }
102 }
103 
104 /*************************************************************************
105 |*
106 |* Basisklasse fuer Textfunktionen
107 |*
108 \************************************************************************/
109 
110 FuText::FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
111 				   SdrModel* pDoc, SfxRequest& rReq) :
112     FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq),
113 	pTextObj(NULL)
114 {
115 }
116 
117 /*************************************************************************
118 |*
119 |* Destruktor
120 |*
121 \************************************************************************/
122 
123 FuText::~FuText()
124 {
125 //	StopEditMode();					// in Deactivate !
126 }
127 
128 /*************************************************************************
129 |*
130 |* MouseButtonDown-event
131 |*
132 \************************************************************************/
133 
134 sal_Bool __EXPORT FuText::MouseButtonDown(const MouseEvent& rMEvt)
135 {
136 	// #95491# remember button state for creation of own MouseEvents
137 	SetMouseButtonCode(rMEvt.GetButtons());
138 
139 	if ( pView->MouseButtonDown(rMEvt, pWindow) )
140 		return (sal_True);				   // Event von der SdrView ausgewertet
141 
142 	if ( pView->IsTextEdit() )
143 	{
144         if( !IsSizingOrMovingNote(rMEvt) )
145 		    StopEditMode();			   // Danebengeklickt, Ende mit Edit
146 		pView->SetCreateMode();
147 	}
148 
149 	aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
150 
151 	if ( rMEvt.IsLeft() )
152 	{
153 		SdrHdl* pHdl = pView->PickHandle(aMDPos);
154 
155 		sal_uLong nHdlNum = pView->GetHdlNum(pHdl);
156 
157 		if (pHdl != NULL)
158 		{
159 			if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl))
160 			{
161 				sal_Bool bPointMarked=pView->IsPointMarked(*pHdl);
162 
163 				if ( rMEvt.IsShift() )
164 				{
165 					if (!bPointMarked)
166 					{
167 						pView->MarkPoint(*pHdl);
168 					}
169 					else
170 					{
171 						pView->UnmarkPoint(*pHdl);
172 					}
173 				}
174 				else
175 				{
176 					if (!bPointMarked)
177 					{
178 						pView->UnmarkAllPoints();
179 						pView->MarkPoint(*pHdl);
180 					}
181 				}
182 				pHdl=pView->GetHdl(nHdlNum);
183 			}
184 		}
185 
186 		SdrObject* pObj;
187 		SdrPageView* pPV;
188 
189 		if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
190 		{
191 			if (pHdl == NULL &&
192 //				pView->TakeTextEditObject(aMDPos, pObj, pPV) )
193 				pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT) )
194 			{
195 				SdrOutliner* pO = MakeOutliner();
196 				lcl_UpdateHyphenator( *pO, pObj );
197 
198 				//	vertical flag:
199 				//	deduced from slot ids only if text object has no content
200 
201 				sal_uInt16 nSlotID = aSfxRequest.GetSlot();
202 				sal_Bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
203 				OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
204 				if ( pOPO )
205 				    bVertical = pOPO->IsVertical();		// content wins
206 				pO->SetVertical( bVertical );
207 
208 				//!??	ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
209 				if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
210 				{
211 					//	EditEngine-UndoManager anmelden
212 					pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
213 
214 					OutlinerView* pOLV = pView->GetTextEditOutlinerView();
215 					if ( pOLV->MouseButtonDown(rMEvt) )
216 						return (sal_True); // Event an den Outliner
217 				}
218 			}
219 			else
220 			{
221 			    // disable tail & circular move for caption objects.
222                 bool bDrag = false;
223 			    const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
224 			    if( rMarkList.GetMarkCount() == 1 )
225 			    {
226                     SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
227                     if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
228 			        {
229                         if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)
230                             bDrag = true;
231 			        }
232 			        else
233                         bDrag = true;   // different object
234 			    }
235                 else
236                     bDrag = true;       // several objects
237 
238                 if ( bDrag )
239                 {
240                     aDragTimer.Start();
241                     pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
242                 }
243 			}
244 		}
245 		else
246 		{
247 			sal_Bool bMacro = sal_False;
248 
249 //			if (bMacro && pView->TakeMacroObject(aMDPos,pObj,pPV))
250 			if (bMacro && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
251 
252 			{
253 				pView->BegMacroObj(aMDPos,pObj,pPV,pWindow);
254 			}
255 			else
256 			{
257 				if (pView->IsEditMode())
258 				{
259 					sal_Bool bPointMode=pView->HasMarkablePoints();
260 
261 					if (!rMEvt.IsShift())
262 					{
263 						if (bPointMode)
264 						{
265 							pView->UnmarkAllPoints();
266 						}
267 						else
268 						{
269 							pView->UnmarkAll();
270 						}
271 
272 						pView->SetDragMode(SDRDRAG_MOVE);
273 						SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
274 						rBindings.Invalidate( SID_OBJECT_ROTATE );
275 						rBindings.Invalidate( SID_OBJECT_MIRROR );
276 						pHdl=pView->GetHdl(nHdlNum);
277 					}
278 
279 					if ( pView->MarkObj(aMDPos, -2, sal_False, rMEvt.IsMod1()) )
280 					{
281 						aDragTimer.Start();
282 
283 						pHdl=pView->PickHandle(aMDPos);
284 
285 						if (pHdl!=NULL)
286 						{
287 							pView->MarkPoint(*pHdl);
288 							pHdl=pView->GetHdl(nHdlNum);
289 						}
290 
291 						pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
292 					}
293 					else
294 					{
295 						if (bPointMode)
296 						{
297 							pView->BegMarkPoints(aMDPos);
298 						}
299 						else
300 						{
301 							pView->BegMarkObj(aMDPos);
302 						}
303 					}
304 				}
305 				else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
306 				{
307 					//	Notizen editieren -> keine neuen Textobjekte erzeugen,
308 					//	stattdessen Textmodus verlassen
309 
310 					pViewShell->GetViewData()->GetDispatcher().
311 						Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
312 				}
313 				else
314 				{
315 					/**********************************************************
316 					* Objekt erzeugen
317 					**********************************************************/
318 					pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
319 				}
320 			}
321 		}
322 	}
323 
324 
325 	if (!bIsInDragMode)
326 	{
327 		pWindow->CaptureMouse();
328 //		ForcePointer(&rMEvt);
329 		lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
330 	}
331 
332 	pViewShell->SetActivePointer(pView->GetPreferedPointer(
333 					pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
334 
335 //	return (bReturn);
336 	return sal_True;
337 }
338 
339 /*************************************************************************
340 |*
341 |* MouseMove-event
342 |*
343 \************************************************************************/
344 
345 sal_Bool __EXPORT FuText::MouseMove(const MouseEvent& rMEvt)
346 {
347 	sal_Bool bReturn = sal_False;
348 
349 //	pViewShell->SetActivePointer(aNewPointer);
350 
351 	pViewShell->SetActivePointer(pView->GetPreferedPointer(
352 					pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
353 
354 	if (aDragTimer.IsActive() )
355 	{
356 		Point aOldPixel = pWindow->LogicToPixel( aMDPos );
357 		Point aNewPixel = rMEvt.GetPosPixel();
358 		if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
359 			 Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
360 			aDragTimer.Stop();
361 	}
362 
363 	if ( pView->MouseMove(rMEvt, pWindow) )
364 		return (sal_True); // Event von der SdrView ausgewertet
365 
366 	if ( pView->IsAction() )
367 	{
368 /*		aNewPointer = Pointer(POINTER_TEXT);
369 		pViewShell->SetActivePointer(aNewPointer);
370 */
371 		Point aPix(rMEvt.GetPosPixel());
372 		Point aPnt(pWindow->PixelToLogic(aPix));
373 
374 		ForceScroll(aPix);
375 		pView->MovAction(aPnt);
376 	}
377 
378 //	ForcePointer(&rMEvt);
379 
380 	return (bReturn);
381 }
382 
383 /*************************************************************************
384 |*
385 |* MouseButtonUp-event
386 |*
387 \************************************************************************/
388 
389 sal_Bool __EXPORT FuText::MouseButtonUp(const MouseEvent& rMEvt)
390 {
391 	// #95491# remember button state for creation of own MouseEvents
392 	SetMouseButtonCode(rMEvt.GetButtons());
393 
394 	sal_Bool bReturn = sal_False;
395 
396 	if (aDragTimer.IsActive() )
397 	{
398 		aDragTimer.Stop();
399 	}
400 
401 	lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
402 
403 	Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
404 
405 	if ( pView->MouseButtonUp(rMEvt, pWindow) )
406 		return (sal_True); // Event von der SdrView ausgewertet
407 
408 	if ( pView->IsDragObj() )
409 	{
410 		pView->EndDragObj( rMEvt.IsShift() );
411 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
412 		if (rMarkList.GetMarkCount() == 1)
413 		{
414 		  	SdrMark* pMark = rMarkList.GetMark(0);
415 		  	SdrObject* pObj = pMark->GetMarkedSdrObj();
416 		  	FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
417 		  	FuText* pText = static_cast<FuText*>(pPoor);
418 			pText->StopDragMode(pObj );
419 		}
420 		pView->ForceMarkedToAnotherPage();
421 	}
422 	else if ( pView->IsCreateObj() )
423 	{
424 		if (rMEvt.IsLeft())
425 		{
426 			pView->EndCreateObj(SDRCREATE_FORCEEND);
427 			if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE)
428 			{
429 				//	Lauftext-Objekt erzeugen?
430 
431 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
432 				if (rMarkList.GetMark(0))
433 				{
434 					SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
435 
436 					// die fuer das Scrollen benoetigten Attribute setzen
437 					SfxItemSet aItemSet( pDrDoc->GetItemPool(),
438 											SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
439 
440 					aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
441 					aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
442 					aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
443 					aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
444 					aItemSet.Put( SdrTextAniCountItem( 1 ) );
445 					aItemSet.Put( SdrTextAniAmountItem(
446 									(sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
447 					pObj->SetMergedItemSetAndBroadcast(aItemSet);
448 				}
449 			}
450 
451 			// #93382# init object different when vertical writing
452 			sal_uInt16 nSlotID(aSfxRequest.GetSlot());
453 			sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID);
454 			if(bVertical)
455 			{
456 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
457 				if(rMarkList.GetMark(0))
458 				{
459 					SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
460 					if(pObj && pObj->ISA(SdrTextObj))
461 					{
462 						SdrTextObj* pText = (SdrTextObj*)pObj;
463 						SfxItemSet aSet(pDrDoc->GetItemPool());
464 
465 						pText->SetVerticalWriting(sal_True);
466 
467 						aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
468 						aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
469 						aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
470 						aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
471 
472 						pText->SetMergedItemSet(aSet);
473 					}
474 				}
475 			}
476 
477 			SetInEditMode();
478 
479 				//	Modus verlassen bei einzelnem Klick
480 				//	(-> fuconstr)
481 
482 			if ( !pView->AreObjectsMarked() )
483 			{
484 				pView->MarkObj(aPnt, -2, sal_False, rMEvt.IsMod1());
485 
486 				SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
487 				if ( pView->AreObjectsMarked() )
488 					rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
489 				else
490 					rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
491 			}
492 		}
493 	}
494 	else if ( pView->IsAction() )
495 	{
496 		pView->EndAction();
497 	}
498     else if( !pView->IsAction() )
499     {
500         pWindow->ReleaseMouse();
501 
502         if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
503         {
504             pView->MarkObj(aPnt, -2, sal_False, rMEvt.IsMod1());
505 
506             SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
507             if ( pView->AreObjectsMarked() )
508                 rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
509             else
510                 rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
511         }
512     }
513 
514 	return (bReturn);
515 }
516 
517 /*************************************************************************
518 |*
519 |* Maus-Pointer umschalten
520 |*
521 \************************************************************************/
522 
523 void FuText::ForcePointer(const MouseEvent* /* pMEvt */)
524 {
525 	pViewShell->SetActivePointer( aNewPointer );
526 
527 /*
528 	if ( !pView->IsAction() )
529 	{
530 		Point aPnt(pWindow->PixelToLogic( pWindow->ScreenToOutputPixel(
531 				   Pointer::GetPosPixel() ) ) );
532 		SdrHdl* pHdl=pView->HitHandle(aPnt, *pWindow);
533 
534 		if (pHdl!=NULL)
535 		{
536 			pViewShell->SetActivePointer(pHdl->GetPointer() );
537 		}
538 		else
539 		{
540 			SdrObject* pObj;
541 			SdrPageView* pPV;
542 
543 			if ( pView->IsMarkedHit(aPnt) )
544 			{
545 				if ( pView->TakeTextEditObject(aPnt, pObj, pPV) )
546 				{
547 					pViewShell->SetActivePointer(Pointer(POINTER_TEXT));
548 				}
549 				else
550 				{
551 					pViewShell->SetActivePointer(Pointer(POINTER_MOVE));
552 				}
553 			}
554 			else
555 			{
556 //				if ( pView->TakeMacroObject(aPnt, pObj, pPV) )
557 				if ( pView->PickObj(aPnt, pObj, pPV, SDRSEARCH_PICKMACRO) )
558 				{
559 					pViewShell->SetActivePointer( pObj->GetMacroPointer() );
560 				}
561 				else
562 				{
563 					pViewShell->SetActivePointer( aNewPointer );
564 				}
565 			}
566 		}
567 	}
568 */
569 }
570 
571 
572 
573 /*************************************************************************
574 |*
575 |* Tastaturereignisse bearbeiten
576 |*
577 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
578 |* FALSE.
579 |*
580 \************************************************************************/
581 
582 sal_Bool __EXPORT FuText::KeyInput(const KeyEvent& rKEvt)
583 {
584 	sal_Bool bReturn = sal_False;
585 
586 	if ( pView->KeyInput(rKEvt, pWindow) )
587 	{
588 		bReturn = sal_True;
589 		lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
590 	}
591 	else
592 	{
593 		bReturn = FuDraw::KeyInput(rKEvt);
594 	}
595 
596 	return (bReturn);
597 }
598 
599 
600 
601 /*************************************************************************
602 |*
603 |* Function aktivieren
604 |*
605 \************************************************************************/
606 
607 void FuText::Activate()
608 {
609 	pView->SetDragMode(SDRDRAG_MOVE);
610 	SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
611 	rBindings.Invalidate( SID_OBJECT_ROTATE );
612 	rBindings.Invalidate( SID_OBJECT_MIRROR );
613 
614 //	Sofort in den Edit Mode setzen
615 //	SetInEditMode();
616 
617 //	if (!pTextObj)
618 	{
619 		/**********************************************************************
620 		* Kein Textobjekt im EditMode, daher CreateMode setzen
621 		**********************************************************************/
622 		sal_uInt16 nObj = OBJ_TEXT;
623 
624 /*		sal_uInt16 nIdent;
625 		sal_uInt32 nInvent;
626 		pView->TakeCurrentObj(nIdent, nInvent);
627 */
628 		pView->SetCurrentObj(nObj);
629 
630 		pView->SetCreateMode();
631 	}
632 
633 	aNewPointer = Pointer(POINTER_TEXT);
634 //	aNewPointer = Pointer(POINTER_CROSS);				//! ???
635 
636 	aOldPointer = pWindow->GetPointer();
637 	pViewShell->SetActivePointer( aNewPointer );
638 
639 	FuConstruct::Activate();
640 }
641 
642 
643 /*************************************************************************
644 |*
645 |* Function deaktivieren
646 |*
647 \************************************************************************/
648 
649 void FuText::Deactivate()
650 {
651 	FuConstruct::Deactivate();
652 	pViewShell->SetActivePointer( aOldPointer );
653 	StopEditMode();
654 }
655 
656 
657 /*************************************************************************
658 |*
659 |* Selektion hat sich geaendert
660 |*
661 \************************************************************************/
662 
663 void FuText::SelectionHasChanged()
664 {
665 	pView->SetDragMode(SDRDRAG_MOVE);
666 	SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
667 	rBindings.Invalidate( SID_OBJECT_ROTATE );
668 	rBindings.Invalidate( SID_OBJECT_MIRROR );
669 
670 	pTextObj = NULL;
671 
672 	if ( pView->AreObjectsMarked() )
673 	{
674 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
675 
676 		if (rMarkList.GetMarkCount() == 1)
677 		{
678 			SdrMark* pMark = rMarkList.GetMark(0);
679 			SdrObject* pObj = pMark->GetMarkedSdrObj();
680 
681 			sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
682 
683 			if (nSdrObjKind == OBJ_TEXT ||
684 				nSdrObjKind == OBJ_TITLETEXT ||
685 				nSdrObjKind == OBJ_OUTLINETEXT /* ||
686 				pObj->ISA(SdrTextObj) */ )
687 			{
688 				pTextObj = (SdrTextObj*) pObj;
689 			}
690 		}
691 	}
692 
693 	if (!pTextObj)
694 	{
695 		/**********************************************************************
696 		* Kein Textobjekt im EditMode, daher CreateMode setzen
697 		**********************************************************************/
698 		sal_uInt16 nObj = OBJ_TEXT;
699 		sal_uInt16 nIdent;
700 		sal_uInt32 nInvent;
701 		pView->TakeCurrentObj(nIdent, nInvent);
702 
703 //		  if (! pView->IsEditMode() )
704 //		  {
705 //			  if (nIdent == OBJ_TEXT)
706 //			  {
707 //				  nObj = OBJ_TEXT;
708 //			  }
709 //			  else if (nIdent == OBJ_OUTLINETEXT)
710 //			  {
711 //				  nObj = OBJ_OUTLINETEXT;
712 //			  }
713 //			  else if (nIdent == OBJ_TITLETEXT)
714 //			  {
715 //				  nObj = OBJ_TITLETEXT;
716 //			  }
717 //		  }
718 
719 		pView->SetCurrentObj(nObj);
720 
721 		pView->SetCreateMode();
722 	}
723 }
724 
725 /*************************************************************************
726 |*
727 |* Objekt in Edit-Mode setzen
728 |*
729 \************************************************************************/
730 
731 void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
732 							sal_Bool bCursorToEnd, const KeyEvent* pInitialKey)
733 {
734     /*  It is possible to pass a special (unselected) object in pObj, e.g. the
735         caption object of a cell note. If pObj is 0, then the selected object
736         is used. The layer will be relocked in FuText::StopEditMode(). */
737 	if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) )
738         pView->UnlockInternalLayer();
739 
740 	if ( !pObj && pView->AreObjectsMarked() )
741 	{
742 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
743 		if (rMarkList.GetMarkCount() == 1)
744 		{
745 			SdrMark* pMark = rMarkList.GetMark(0);
746 			pObj = pMark->GetMarkedSdrObj();
747 		}
748 	}
749 
750 	pTextObj = NULL;
751 
752 	if ( pObj )
753 	{
754 		sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
755 
756 		if (nSdrObjKind == OBJ_TEXT ||
757 			nSdrObjKind == OBJ_TITLETEXT ||
758 			nSdrObjKind == OBJ_OUTLINETEXT ||
759 			pObj->ISA(SdrTextObj))
760 		{
761 			SdrPageView* pPV = pView->GetSdrPageView();
762 			Rectangle aRect = pObj->GetLogicRect();
763 			Point aPnt = aRect.Center();
764 
765 			if ( pObj->HasTextEdit() )
766 			{
767 				SdrOutliner* pO = MakeOutliner();
768 				lcl_UpdateHyphenator( *pO, pObj );
769 
770 				//	vertical flag:
771 				//	deduced from slot ids only if text object has no content
772 
773 				sal_uInt16 nSlotID = aSfxRequest.GetSlot();
774 				sal_Bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
775 				OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
776 				if ( pOPO )
777 					bVertical = pOPO->IsVertical();		// content wins
778 				pO->SetVertical( bVertical );
779 
780 				//!??	ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
781 				if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
782 				{
783 					//	EditEngine-UndoManager anmelden
784 					pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
785 
786 					pTextObj = (SdrTextObj*) pObj;
787 					pView->SetEditMode();
788 
789 					//	set text cursor to click position or to end,
790 					//	pass initial key event to outliner view
791 					if ( pMousePixel || bCursorToEnd || pInitialKey )
792 					{
793 						OutlinerView* pOLV = pView->GetTextEditOutlinerView();
794 						if (pOLV)
795 						{
796 							if ( pMousePixel )
797 							{
798 								MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
799 								pOLV->MouseButtonDown(aEditEvt);
800 								pOLV->MouseButtonUp(aEditEvt);
801 							}
802 							else if ( bCursorToEnd )
803 							{
804 								ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
805 								pOLV->SetSelection(aNewSelection);
806 							}
807 
808 							if ( pInitialKey )
809 								pOLV->PostKeyEvent( *pInitialKey );
810 						}
811 					}
812 				}
813 			}
814 		}
815 	}
816 }
817 
818 // #98185# Create default drawing objects via keyboard
819 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
820 {
821 	// case SID_DRAW_TEXT:
822 	// case SID_DRAW_TEXT_VERTICAL:
823 	// case SID_DRAW_TEXT_MARQUEE:
824 	// case SID_DRAW_NOTEEDIT:
825 
826 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
827 		pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
828 		0L, pDrDoc);
829 
830 	if(pObj)
831 	{
832 		if(pObj->ISA(SdrTextObj))
833 		{
834 			SdrTextObj* pText = (SdrTextObj*)pObj;
835 			pText->SetLogicRect(rRectangle);
836 
837 			//  #105815# don't set default text, start edit mode instead
838 			// String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
839 			// pText->SetText(aText);
840 
841 			sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID);
842 			sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID);
843 
844 			pText->SetVerticalWriting(bVertical);
845 
846 			if(bVertical)
847 			{
848 				SfxItemSet aSet(pDrDoc->GetItemPool());
849 
850 				aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
851 				aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
852 				aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
853 				aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
854 
855 				pText->SetMergedItemSet(aSet);
856 			}
857 
858 			if(bMarquee)
859 			{
860 				SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
861 
862 				aSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
863 				aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
864 				aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
865 				aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
866 				aSet.Put( SdrTextAniCountItem( 1 ) );
867 				aSet.Put( SdrTextAniAmountItem( (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
868 
869 				pObj->SetMergedItemSetAndBroadcast(aSet);
870 			}
871 
872 			SetInEditMode( pObj );		// #105815# start edit mode
873 		}
874 		else
875 		{
876 			DBG_ERROR("Object is NO text object");
877 		}
878 	}
879 
880 	return pObj;
881 }
882 
883