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