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