xref: /aoo41x/main/sd/source/ui/func/futext.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include "futext.hxx"
29 #include <editeng/eeitem.hxx>
30 #include <editeng/editerr.hxx>
31 #include <svx/dlgutil.hxx>
32 #include <svx/svxerr.hxx>
33 #include <tools/urlobj.hxx>
34 #include <vcl/help.hxx>
35 #include <editeng/editstat.hxx>
36 #include <svl/aeitem.hxx>
37 #include <svl/intitem.hxx>
38 #include <svx/svdotext.hxx>
39 #include <svx/svdogrp.hxx>
40 #include <editeng/flditem.hxx>
41 #include <svl/style.hxx>
42 #include <svx/svdpagv.hxx>
43 #include <sfx2/viewfrm.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/request.hxx>
47 #include <editeng/editeng.hxx>
48 #include <svx/svdoutl.hxx>
49 #include <svx/svxids.hrc>
50 #include <sfx2/docfile.hxx>
51 #include <comphelper/processfactory.hxx>
52 #include <editeng/outlobj.hxx>
53 #include <svtools/langtab.hxx>
54 
55 // #104122#
56 #include <editeng/frmdiritem.hxx>
57 
58 #include <svx/svdetc.hxx>
59 #include <editeng/editview.hxx>
60 
61 #include "sdresid.hxx"
62 #include "app.hrc"
63 #include "res_bmp.hrc"
64 #include "ViewShell.hxx"
65 #include "ViewShellBase.hxx"
66 #include "View.hxx"
67 #include "Outliner.hxx"
68 #include "Window.hxx"
69 #include "drawdoc.hxx"
70 #include "sdpage.hxx"
71 #include "sdmod.hxx"
72 #include "FrameView.hxx"
73 #include "ToolBarManager.hxx"
74 #include "DrawDocShell.hxx"
75 #include "glob.hrc"
76 #include "pres.hxx"
77 #include "optsitem.hxx"
78 
79 using ::rtl::OUString;
80 using namespace ::com::sun::star;
81 using namespace ::com::sun::star::uno;
82 using namespace ::com::sun::star::lang;
83 using namespace ::com::sun::star::linguistic2;
84 
85 namespace sd {
86 
87 static sal_uInt16 SidArray[] = {
88 	SID_STYLE_FAMILY2,                //    5542
89 	SID_STYLE_FAMILY5,                //    5545
90 	SID_CUT,                          //    5710
91 	SID_COPY,                         //    5711
92 	SID_ATTR_TABSTOP,                 //   10002
93 	SID_ATTR_CHAR_FONT,               //   10007
94 	SID_ATTR_CHAR_POSTURE,            //   10008
95 	SID_ATTR_CHAR_WEIGHT,             //   10009
96 	SID_ATTR_CHAR_UNDERLINE,          //   10014
97 	SID_ATTR_CHAR_FONTHEIGHT,         //   10015
98 	SID_ATTR_CHAR_COLOR,              //   10017
99 	SID_ATTR_PARA_ADJUST_LEFT,        //   10028
100 	SID_ATTR_PARA_ADJUST_RIGHT,       //   10029
101 	SID_ATTR_PARA_ADJUST_CENTER,      //   10030
102 	SID_ATTR_PARA_ADJUST_BLOCK,       //   10031
103 	SID_ATTR_PARA_LINESPACE_10,       //   10034
104 	SID_ATTR_PARA_LINESPACE_15,       //   10035
105 	SID_ATTR_PARA_LINESPACE_20,       //   10036
106 	SID_ATTR_PARA_LRSPACE,            //   10043
107 	SID_OUTLINE_UP,                   //   10150
108 	SID_OUTLINE_DOWN,                 //   10151
109 	SID_OUTLINE_LEFT,                 //   10152
110 	SID_OUTLINE_RIGHT,                //   10153
111 	SID_FORMTEXT_STYLE,               //   10257
112 	SID_SET_SUPER_SCRIPT,             //   10294
113 	SID_SET_SUB_SCRIPT,               //   10295
114 	SID_HYPERLINK_GETLINK,            //   10361
115 	SID_CHARMAP,					  //   10503
116 	SID_TEXTDIRECTION_LEFT_TO_RIGHT,  //   10907
117 	SID_TEXTDIRECTION_TOP_TO_BOTTOM,  //   10908
118     SID_ATTR_PARA_LEFT_TO_RIGHT,      //   10950
119     SID_ATTR_PARA_RIGHT_TO_LEFT,      //   10951
120 	FN_NUM_BULLET_ON,                 //   20138
121 	SID_PARASPACE_INCREASE,           //   27346
122 	SID_PARASPACE_DECREASE,           //   27347
123 							0 };
124 
125 TYPEINIT1( FuText, FuConstruct );
126 
127 
128 static sal_Bool bTestText = 0;
129 
130 /*************************************************************************
131 |*
132 |* Basisklasse fuer Textfunktionen
133 |*
134 \************************************************************************/
135 
136 FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
137 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
138 , bFirstObjCreated(sal_False)
139 , rRequest (rReq)
140 {
141 }
142 
143 FunctionReference FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
144 {
145 	FunctionReference xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
146 	return xFunc;
147 }
148 
149 /*************************************************************************
150 |*
151 |* Destruktor
152 |*
153 \************************************************************************/
154 
155 void FuText::disposing()
156 {
157 	if(mpView)
158 	{
159 		if(mpView->SdrEndTextEdit(sal_False) == SDRENDTEXTEDIT_DELETED)
160 			mxTextObj.reset( 0 );
161 
162 		// die RequestHandler der benutzten Outliner zuruecksetzen auf den
163 		// Handler am Dokument
164 		::Outliner* pOutliner = mpView->GetTextEditOutliner();
165 
166 		if (pOutliner)
167 			pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
168 	}
169 }
170 
171 /*************************************************************************
172 |*
173 |* Execute functionality of this class:
174 |*
175 |* #71422: Start the functionality of this class in this method
176 |* and not in the ctor.
177 |* If you construct an object of this class and you put the
178 |* address of this object to pFuActual you've got a problem,
179 |* because some methods inside DoExecute use the pFuActual-Pointer.
180 |* If the code inside DoExecute is executed inside the ctor,
181 |* the value of pFuActual is not right. And the value will not
182 |* be right until the ctor finished !!!
183 |*
184 \************************************************************************/
185 void FuText::DoExecute( SfxRequest& )
186 {
187 	mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
188         ToolBarManager::TBG_FUNCTION,
189         RID_DRAW_TEXT_TOOLBOX);
190 
191 	mpView->SetCurrentObj(OBJ_TEXT);
192 	mpView->SetEditMode(SDREDITMODE_EDIT);
193 
194 	MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
195 
196 	if (nSlotId == SID_TEXTEDIT)
197 	{
198 		// Try to select an object
199 		SdrPageView* pPV = mpView->GetSdrPageView();
200 		SdrViewEvent aVEvt;
201 		mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
202 		mpView->MarkObj(aVEvt.pRootObj, pPV);
203 
204 		mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
205 	}
206 	else if (mpView->AreObjectsMarked())
207 	{
208 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
209 
210 		if (rMarkList.GetMarkCount() == 1)
211 		{
212 			SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
213 			mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
214 		}
215 	}
216 
217 	// check for table
218 	if (mpView->AreObjectsMarked())
219 	{
220 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
221 
222 		if (rMarkList.GetMarkCount() == 1)
223 		{
224 			SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
225 			if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
226 			{
227 				mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX );
228 			}
229 		}
230 	}
231 
232 	sal_Bool bQuickDrag = sal_True;
233 
234 	const SfxItemSet* pArgs = rRequest.GetArgs();
235 
236 	if (pArgs
237 
238 		// #98198# test for type before using
239 		&& SID_TEXTEDIT == nSlotId
240 		&& SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
241 
242 		&& (sal_uInt16)((SfxUInt16Item&)pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
243 	{
244 		// Selection by doubleclick -> don't allow QuickDrag
245 		bQuickDrag = sal_False;
246 	}
247 
248 	SetInEditMode(aMEvt, bQuickDrag);
249 }
250 
251 /*************************************************************************
252 |*
253 |* MouseButtonDown-event
254 |*
255 \************************************************************************/
256 
257 sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
258 {
259 	bMBDown = sal_True;
260 
261 	sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
262 
263     /* af: (de)Select object before showing the context menu.
264 	// Fuer PopupMenu (vorher DrawViewShell)
265 	if ((rMEvt.GetButtons() == MOUSE_RIGHT) && rMEvt.GetClicks() == 1 &&
266 		mpView->IsTextEdit())
267 	{
268 		return (sal_True);
269 	}
270         */
271 
272 	mpView->SetMarkHdlWhenTextEdit(sal_True);
273 	SdrViewEvent aVEvt;
274 	SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
275 
276 	if (eHit == SDRHIT_TEXTEDIT)
277 	{
278 		// Text getroffen -> Event von SdrView auswerten lassen
279 		if (mpView->MouseButtonDown(rMEvt, mpWindow))
280 			return (sal_True);
281 	}
282 
283 	if (rMEvt.GetClicks() == 1)
284 	{
285 		if (mpView->IsTextEdit() && eHit != SDRHIT_MARKEDOBJECT && eHit != SDRHIT_HANDLE)
286 		{
287 			// Texteingabe beenden
288 			if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
289 			{
290 				// Bugfix von MBA: bei Doppelclick auf der Wiese im Modus Text wird
291 				// beim zweiten Click eHit = SDRHIT_TEXTEDITOBJ erhalten, weil ja der
292 				// zweite Click auf das im ersten Click angelegte TextObject geht.
293 				// Dieses wird aber in SdrEndTextEdit entfernt, weil es leer ist. Es
294 				// befindet sich aber noch in der Mark-Liste und der Aufruf MarkObj
295 				// weiter unten greift dann auf das tote Object zu.
296 				// Als einfacher Fix wird nach SdrEndTextEdit noch einmal eHit ermittelt,
297 				// was dann SDRHIT_NONE liefert.
298 				mxTextObj.reset( NULL );
299 				eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
300 			}
301 
302 			mpView->SetCurrentObj(OBJ_TEXT);
303 			mpView->SetEditMode(SDREDITMODE_EDIT);
304 		}
305 
306 		if (rMEvt.IsLeft() || rMEvt.IsRight())
307 		{
308 			mpWindow->CaptureMouse();
309 			SdrObject* pObj;
310 			SdrPageView* pPV = mpView->GetSdrPageView();
311 
312 			if (eHit == SDRHIT_TEXTEDIT)
313 			{
314 				SetInEditMode(rMEvt, sal_False);
315 			}
316 			else
317 			{
318 				sal_Bool bMacro = sal_False;
319 
320 				if (bMacro && mpView->PickObj(aMDPos,mpView->getHitTolLog(),pObj,pPV,SDRSEARCH_PICKMACRO))
321 				{
322 					// Makro
323 					sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
324 					mpView->BegMacroObj(aMDPos,nHitLog,pObj,pPV,mpWindow);
325 				}
326 				else
327 				{
328 					if (eHit != SDRHIT_HANDLE)
329 					{
330 						// Selektion aufheben
331 						if (!rMEvt.IsShift() && eHit == SDRHIT_TEXTEDITOBJ)
332 						{
333 							mpView->UnmarkAll();
334 							mpView->SetDragMode(SDRDRAG_MOVE);
335 						}
336 					}
337 
338 					if ( aVEvt.eEvent == SDREVENT_EXECUTEURL                   ||
339 						 eHit == SDRHIT_HANDLE                                 ||
340 						 eHit == SDRHIT_MARKEDOBJECT                           ||
341 						 eHit == SDRHIT_TEXTEDITOBJ                            ||
342 						 ( eHit == SDRHIT_UNMARKEDOBJECT && bFirstObjCreated &&
343 						   !bPermanent ) )
344 					{
345 						/**********************************************************
346 						* Handle, markiertes oder unmarkiertes Objekt getroffen
347 						**********************************************************/
348 						if (eHit == SDRHIT_TEXTEDITOBJ)
349 						{
350 							/******************************************************
351 							* Text eines unmarkierten Objekts getroffen:
352 							* Objekt wird selektiert und in EditMode versetzt
353 							******************************************************/
354 							mpView->MarkObj(aVEvt.pRootObj, pPV);
355 
356 							if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
357 							{
358 								mxTextObj.reset( static_cast<SdrTextObj*>(aVEvt.pObj) );
359 							}
360 
361 							SetInEditMode(rMEvt, sal_True);
362 						}
363 						else if (aVEvt.eEvent == SDREVENT_EXECUTEURL && !rMEvt.IsMod2())
364 						{
365 							/******************************************************
366 							* URL ausfuehren
367 							******************************************************/
368 							mpWindow->ReleaseMouse();
369 							SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
370 							SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
371 							SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
372 							SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
373 							mpWindow->ReleaseMouse();
374 
375 							if (rMEvt.IsMod1())
376 							{
377 								// Im neuen Frame oeffnen
378 								pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
379 											&aStrItem, &aBrowseItem, &aReferer, 0L);
380 							}
381 							else
382 							{
383 								// Im aktuellen Frame oeffnen
384 								SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
385 								pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
386 											&aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
387 							}
388 						}
389 						else
390 						{
391 							/******************************************************
392 							* Objekt oder Handle draggen
393 							******************************************************/
394 
395 							// #i78748#
396 							// do the EndTextEdit first, it will delete the handles and force a
397 							// recreation. This will make aVEvt.pHdl to point to a deleted handle,
398 							// thus it is necessary to reset it and to get it again.
399 
400 							// #i112855#
401 							// cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObjet
402 							// this caused SdrEndTextEdit() to be called also when not in text editing and
403 							// this does not make sense and caused troubles. (see issue 112855)
404 
405 //							::Outliner* pOutl = mpView->GetTextEditOutliner();
406 //
407 //							if (mxTextObj.is() && (mxTextObj->GetOutlinerParaObject() ||
408 //								(pOutl && pOutl->GetText(pOutl->GetParagraph( 0 )).Len() != 0)))
409 							if( mpView->IsTextEdit() )
410 							{
411 								mpView->SdrEndTextEdit();
412 
413 								if(aVEvt.pHdl)
414 								{
415 									// force new handle identification, the pointer will be dead here
416 									// since SdrEndTextEdit has resetted (deleted) the handles.
417 									aVEvt.pHdl = 0;
418 									mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
419 								}
420 							}
421 
422 							if (!aVEvt.pHdl)
423 							{
424 								if( eHit == SDRHIT_UNMARKEDOBJECT )
425 								{
426 									if ( !rMEvt.IsShift() )
427 										mpView->UnmarkAll();
428 
429 									mpView->MarkObj(aVEvt.pRootObj, pPV);
430 								}
431 
432 								// Objekt draggen
433 								bFirstMouseMove = sal_True;
434 								aDragTimer.Start();
435 							}
436 
437 
438                             if ( ! rMEvt.IsRight())
439                             {
440 							    // we need to pick again since SdrEndTextEdit can rebuild the handles list
441                                 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
442 							    if( (eHit == SDRHIT_HANDLE) || (eHit == SDRHIT_MARKEDOBJECT) )
443 							    {
444 								    sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
445 								    mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
446 							    }
447                             }
448                             bReturn = true;
449 						}
450 					}
451 					else if ( nSlotId != SID_TEXTEDIT &&
452 							  (bPermanent || !bFirstObjCreated) )
453 					{
454 						/**********************************************************
455 						* Objekt erzeugen
456 						**********************************************************/
457 						mpView->SetCurrentObj(OBJ_TEXT);
458 						mpView->SetEditMode(SDREDITMODE_CREATE);
459 						sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
460 						mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
461 					}
462 					else
463 					{
464 						/**********************************************************
465 						* Selektieren
466 						**********************************************************/
467 						if( !rMEvt.IsShift() )
468 							mpView->UnmarkAll();
469 
470 						mpView->BegMarkObj( aMDPos );
471 					}
472 				}
473 			}
474 		}
475 	}
476 	else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
477 	{
478 		MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
479 		SetInEditMode( aMEvt, sal_False );
480 	}
481 
482 	if (!bIsInDragMode)
483 	{
484 		ForcePointer(&rMEvt);
485 		mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
486 	}
487 
488 	return (bReturn);
489 }
490 
491 /*************************************************************************
492 |*
493 |* MouseMove-event
494 |*
495 \************************************************************************/
496 
497 sal_Bool FuText::MouseMove(const MouseEvent& rMEvt)
498 {
499 	sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
500 
501 	if (aDragTimer.IsActive() )
502 	{
503 		if( bFirstMouseMove )
504 			bFirstMouseMove = sal_False;
505 		else
506 			aDragTimer.Stop();
507 	}
508 
509 	if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
510 	{
511 		Point aPix(rMEvt.GetPosPixel());
512 		Point aPnt(mpWindow->PixelToLogic(aPix));
513 
514 		ForceScroll(aPix);
515 		mpView->MovAction(aPnt);
516 	}
517 
518 	ForcePointer(&rMEvt);
519 
520 	return (bReturn);
521 }
522 
523 /*************************************************************************
524 |*
525 |* MouseButtonUp-event
526 |*
527 \************************************************************************/
528 
529 // #97016#
530 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
531 {
532 	if(mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
533 	{
534 		if( nSlotId == SID_ATTR_CHAR )
535 		{
536 			// Impress-Textobjekt wird erzeugt (faellt auf Zeilenhoehe zusammen)
537 			// Damit das Objekt beim anschliessenden Erzeugen gleich die richtige
538 			// Hoehe bekommt (sonst wird zuviel gepainted)
539 			SfxItemSet aSet(mpViewShell->GetPool());
540 			aSet.Put(SdrTextMinFrameHeightItem(0));
541 			aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
542 			aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
543 			pTxtObj->SetMergedItemSet(aSet);
544 			pTxtObj->AdjustTextFrameWidthAndHeight();
545 			aSet.Put(SdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
546 			pTxtObj->SetMergedItemSet(aSet);
547 		}
548 		else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
549 		{
550 			SfxItemSet aSet(mpViewShell->GetPool());
551 			aSet.Put(SdrTextMinFrameWidthItem(0));
552 			aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
553 			aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
554 
555 			// #91853# Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
556 			aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
557 			pTxtObj->SetMergedItemSet(aSet);
558 			pTxtObj->AdjustTextFrameWidthAndHeight();
559 			aSet.Put(SdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
560 			pTxtObj->SetMergedItemSet(aSet);
561 		}
562 	}
563 	else
564 	{
565 		if( nSlotId == SID_ATTR_CHAR_VERTICAL )
566 		{
567 			// draw text object, needs to be initialized when vertical text is used
568 			SfxItemSet aSet(mpViewShell->GetPool());
569 
570 			// #91510#
571 			aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
572 			aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
573 
574 			// #91508#
575 			//aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
576 			//aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
577 
578 			// #107235#
579 			// Set defaults for vertical klick-n'drag text object, pool defaults are:
580 			// SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
581 			// SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
582 			// Analog to that (thus, #91508# was not completely correct):
583 			aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
584 			aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
585 
586 			pTxtObj->SetMergedItemSet(aSet);
587 		}
588 	}
589 }
590 
591 // #97016#
592 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
593 {
594 	// FitToSize (An Rahmen anpassen)
595 	SfxItemSet aSet(mpViewShell->GetPool(), SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
596 	SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
597 	aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
598 	aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
599 	aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
600 	pTxtObj->SetMergedItemSet(aSet);
601 	pTxtObj->AdjustTextFrameWidthAndHeight();
602 }
603 
604 // #97016#
605 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
606 {
607 	SfxItemSet aSet(mpViewShell->GetPool(),
608 		SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
609 	SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
610 	aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
611 	aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
612 	aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
613 	pTxtObj->SetMergedItemSet(aSet);
614 	pTxtObj->AdjustTextFrameWidthAndHeight();
615 }
616 
617 // #97016#
618 void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
619 {
620 	// Normales Textobjekt
621 	if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
622 	{
623 		if( nSlotId == SID_ATTR_CHAR )
624 		{
625 			// Impress-Textobjekt (faellt auf Zeilenhoehe zusammen)
626 			SfxItemSet aSet(mpViewShell->GetPool());
627 			aSet.Put(SdrTextMinFrameHeightItem(0));
628 			aSet.Put(SdrTextMaxFrameHeightItem(0));
629 			aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
630 			aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
631 			pTxtObj->SetMergedItemSet(aSet);
632 		}
633 		else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
634 		{
635 			SfxItemSet aSet(mpViewShell->GetPool());
636 			aSet.Put(SdrTextMinFrameWidthItem(0));
637 			aSet.Put(SdrTextMaxFrameWidthItem(0));
638 			aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
639 			aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
640 			pTxtObj->SetMergedItemSet(aSet);
641 		}
642 
643 		pTxtObj->AdjustTextFrameWidthAndHeight();
644 	}
645 }
646 
647 sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
648 {
649 	sal_Bool bReturn = sal_False;
650 
651 	if (aDragTimer.IsActive())
652 	{
653 		aDragTimer.Stop();
654 		bIsInDragMode = sal_False;
655 	}
656 
657 	mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
658 
659 	Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
660 
661 	if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
662 		return (sal_True); // Event von der SdrView ausgewertet
663 
664 	sal_Bool bEmptyTextObj = sal_False;
665 
666 	if (mxTextObj.is())
667 	{
668 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
669 
670 		if (rMarkList.GetMarkCount() == 1
671             && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
672 		{
673 			if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
674 				bEmptyTextObj = sal_True;
675 			else
676 				bFirstObjCreated = sal_True;
677 		}
678 		else
679 		{
680 			mxTextObj.reset( 0 );
681 		}
682 	}
683 
684 	if( mpView && mpView->IsDragObj())
685 	{
686 		/**********************************************************************
687 		* Objekt wurde verschoben
688 		**********************************************************************/
689 		FrameView* pFrameView = mpViewShell->GetFrameView();
690 		sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
691 
692 		if (bDragWithCopy)
693 		{
694 			bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
695 		}
696 
697 		mpView->SetDragWithCopy(bDragWithCopy);
698 		mpView->EndDragObj( mpView->IsDragWithCopy() );
699 		mpView->ForceMarkedToAnotherPage();
700 		mpView->SetCurrentObj(OBJ_TEXT);
701 
702 	    sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
703 
704         if ( mpView->IsRotateAllowed() && mpViewShell->GetFrameView()->IsClickChangeRotation() && (rMEvt.GetClicks() != 2) &&
705 			!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
706             Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
707             Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
708         {
709 			// toggle to rotation mode
710 			mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_ROTATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
711 		}
712 	}
713 	else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
714 	{
715 		/**********************************************************************
716 		* Objekt wurde erzeugt
717 		**********************************************************************/
718 		mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
719 
720 		if( mxTextObj.is() )
721 		{
722 			//AW outliner needs to be set to vertical when there is no
723 			// outliner object up to now; also it needs to be set back to not
724 			// vertical when there was a vertical one used last time.
725 			OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
726 			SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj());
727 			sal_Bool bVertical((pOPO && pOPO->IsVertical())
728 				|| nSlotId == SID_ATTR_CHAR_VERTICAL
729 				|| nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
730 			rOutl.SetVertical(bVertical);
731 
732 			// #107235#
733 			// Before ImpSetAttributesForNewTextObject the vertical writing mode
734 			// needs to be set at the object. This is done here at the OutlinerParaObject
735 			// directly to not mirror the layout text items involved. These items will be set
736 			// from ImpSetAttributesForNewTextObject and below.
737 			OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
738 
739 			if(!pPara)
740 			{
741 				GetTextObj()->ForceOutlinerParaObject();
742 				pPara = GetTextObj()->GetOutlinerParaObject();
743 			}
744 
745 			if(pPara && (bool)bVertical != pPara->IsVertical())
746 			{
747 				// set ParaObject orientation accordingly
748 				pPara->SetVertical(bVertical);
749 			}
750 
751 			// #97016#
752 			ImpSetAttributesForNewTextObject(GetTextObj());
753 		}
754 
755 		if (!mpView->EndCreateObj(SDRCREATE_FORCEEND))
756 		{
757 			// Textobjekt konnte nicht erzeugt werden
758 			mxTextObj.reset(0);
759 		}
760 		else if (nSlotId == SID_TEXT_FITTOSIZE)
761 		{
762 			// #97016#
763 			ImpSetAttributesFitToSize(GetTextObj());
764 
765 			SetInEditMode(rMEvt, sal_False);
766 		}
767 		else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
768 		{
769 			// #97016#
770 			ImpSetAttributesFitToSizeVertical(GetTextObj());
771 
772 			SetInEditMode(rMEvt, sal_False);
773 		}
774 		else
775 		{
776 			// #97016#
777 			ImpSetAttributesFitCommon(GetTextObj());
778 
779 			// Damit die Handles und der graue Rahmen stimmen
780 			mpView->AdjustMarkHdl();
781 			mpView->PickHandle(aPnt);
782 			SetInEditMode(rMEvt, sal_False);
783 		}
784 	}
785 	else if ( mpView && mpView->IsAction())
786 	{
787 		mpView->EndAction();
788 	}
789 
790 	ForcePointer(&rMEvt);
791 	mpWindow->ReleaseMouse();
792 	sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
793 
794 	if ( mpView && !mpView->AreObjectsMarked() &&
795 		 Abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
796 		 Abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
797 		 !rMEvt.IsShift() && !rMEvt.IsMod2() )
798 	{
799 		SdrPageView* pPV = mpView->GetSdrPageView();
800 		SdrViewEvent aVEvt;
801 		mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
802 		mpView->MarkObj(aVEvt.pRootObj, pPV);
803 	}
804 
805 	if ( !mxTextObj.is() && mpView )
806 	{
807 		if ( ( (!bEmptyTextObj   &&  bPermanent) ||
808 			 (!bFirstObjCreated && !bPermanent) ) &&
809 			  !mpDocSh->IsReadOnly()               &&
810 			  nSlotId != SID_TEXTEDIT )
811 		{
812 			/**********************************************************************
813 			* Mengentext (linksbuendiges AutoGrow)
814 			**********************************************************************/
815 			mpView->SetCurrentObj(OBJ_TEXT);
816 			mpView->SetEditMode(SDREDITMODE_CREATE);
817 			sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
818 			mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
819 
820 			sal_Bool bSnapEnabled = mpView->IsSnapEnabled();
821 
822 			if (bSnapEnabled)
823 				mpView->SetSnapEnabled(sal_False);
824 
825 			aPnt.X() += nDrgLog + nDrgLog;
826 			aPnt.Y() += nDrgLog + nDrgLog;
827 			mpView->MovAction(aPnt);
828 
829 			mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
830 
831 			if(mxTextObj.is())
832 			{
833 				GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
834 			}
835 
836 			if(!mpView->EndCreateObj(SDRCREATE_FORCEEND))
837 			{
838 				mxTextObj.reset(0);
839 			}
840 
841 			if(bSnapEnabled)
842 				mpView->SetSnapEnabled(bSnapEnabled);
843 
844 			if(mxTextObj.is())
845 			{
846 				SfxItemSet aSet(mpViewShell->GetPool());
847 				aSet.Put(SdrTextMinFrameHeightItem(0));
848 				aSet.Put(SdrTextMinFrameWidthItem(0));
849 				aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
850 				aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
851 
852 				// #91508#
853 				if(nSlotId == SID_ATTR_CHAR_VERTICAL)
854 				{
855 					// #107235#
856 					//
857 					// Here, all items which need to be different from pool default need to be set
858 					// again on the newly created text object.
859 					// Since this is a simple klick text object, it is first created, then SetVertical()
860 					// is used, then ImpSetAttributesForNewTextObject is called and then the object is
861 					// deleted again since not the minimum drag distance was travelled. Then, a new
862 					// klick text object is created and thus all that stuff needs to be set again here.
863 					//
864 					// Before using the new object the vertical writing mode
865 					// needs to be set. This is done here at the OutlinerParaObject
866 					// directly to not mirror the layout text items involved. These items will be set
867 					// below.
868 					OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
869 
870 					if(!pPara)
871 					{
872 						GetTextObj()->ForceOutlinerParaObject();
873 						pPara = GetTextObj()->GetOutlinerParaObject();
874 					}
875 
876 					if(pPara && sal_True != pPara->IsVertical())
877 					{
878 						// set ParaObject orientation accordingly
879 						pPara->SetVertical(sal_True);
880 					}
881 
882 					// #91508#
883 					// aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
884 					aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
885 
886 					// #107235#
887 					// Analog to the else case below, for vertical simple click texts
888 					// one of the defaulted setted items from ImpSetAttributesForNewTextObject
889 					// needs to be adapted to non-block mode. This could have been done with the
890 					// #104122#, but was obviously overseen.
891 					const SfxItemSet& rSet = mpView->GetDefaultAttr();
892 					SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
893 
894 					if(FRMDIR_HORI_RIGHT_TOP == eDirection || FRMDIR_VERT_TOP_RIGHT == eDirection)
895 					{
896 	                    aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
897 					}
898 					else
899 					{
900 	                    aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
901 					}
902 				}
903 				else
904 				{
905 					// #104122# This is for Format/Page settings. Since this also leads
906 					// to the object defaults to be changed, i think this code can be
907 					// removed. CL. wanted to take a look before adding this.
908                     //const SdrTextHorzAdjust eHA = ( ( pDoc && pDoc->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ) ?
909                     //                                SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_LEFT );
910                     //aSet.Put( SdrTextHorzAdjustItem( eHA ) );
911 
912 					// #104122# Look in the object defaults if left-to-right is wanted. If
913 					// yes, set text anchoring to right to let the box grow to left.
914 					const SfxItemSet& rSet = mpView->GetDefaultAttr();
915 					SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
916 
917 					if(FRMDIR_HORI_RIGHT_TOP == eDirection)
918 					{
919 	                    aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
920 					}
921 					else
922 					{
923 	                    aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
924 					}
925 				}
926 
927 				GetTextObj()->SetMergedItemSet(aSet);
928 				GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
929 				SetInEditMode(rMEvt, sal_False);
930 			}
931 
932 			bFirstObjCreated = sal_True;
933 		}
934 		else
935 		{
936 			// In die Fkt. Selektion wechseln
937 			if (mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
938 			{
939 				mxTextObj.reset(0);
940 			}
941 
942 			mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
943 									  SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
944 		}
945 	}
946 
947 	bMBDown = sal_False;
948 	FuConstruct::MouseButtonUp(rMEvt);
949 	return (bReturn);
950 }
951 
952 /*************************************************************************
953 |*
954 |* Tastaturereignisse bearbeiten
955 |*
956 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
957 |* sal_False.
958 |*
959 \************************************************************************/
960 
961 sal_Bool FuText::KeyInput(const KeyEvent& rKEvt)
962 {
963 	sal_Bool bReturn = sal_False;
964 	mpView->SetMarkHdlWhenTextEdit(sal_True);
965 
966 	KeyCode nCode = rKEvt.GetKeyCode();
967 	sal_Bool bShift = nCode.IsShift();
968 
969 	// #97016# IV
970 	if(mxTextObj.is())
971 	{
972 		// maybe object is deleted, test if it's equal to the selected object
973 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
974 		SdrObject* pSelectedObj = 0L;
975 
976 		if(1 == rMarkList.GetMarkCount())
977 		{
978 			SdrMark* pMark = rMarkList.GetMark(0);
979 			pSelectedObj = pMark->GetMarkedSdrObj();
980 		}
981 
982 		if(mxTextObj.get() != pSelectedObj)
983 		{
984 			mxTextObj.reset(0);
985 		}
986 	}
987 
988 	if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
989 	{
990 		// Titeltext-Objekt: immer "weiche" Umbrueche
991 		bShift = sal_True;
992 	}
993 
994 	sal_uInt16 nKey = nCode.GetCode();
995 	KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
996 	KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
997 
998 	sal_Bool bOK = sal_True;
999 
1000 	if (mpDocSh->IsReadOnly())
1001 	{
1002 		bOK = !EditEngine::DoesKeyChangeText(aKEvt);
1003 	}
1004 	if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
1005 	{
1006 		bOK = sal_False;   // default handling in base class
1007 	}
1008 
1009 	if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
1010 	{
1011 		bReturn = sal_True;
1012 
1013 		mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
1014 
1015 //		if ( pTextObj )
1016 //			pTextObj->SetEmptyPresObj(sal_False);
1017 	}
1018 	else if (aKeyCode == KEY_ESCAPE)
1019 	{
1020 		bReturn = cancel();
1021 	}
1022 
1023 	if( bPermanent )
1024 	{
1025 		mpView->SetCurrentObj(OBJ_TEXT);
1026 		mpView->SetEditMode(SDREDITMODE_CREATE);
1027 	}
1028 
1029 	if (!bReturn)
1030 	{
1031 		bReturn = FuDraw::KeyInput(aKEvt);
1032 	}
1033 
1034 	return (bReturn);
1035 }
1036 
1037 
1038 
1039 /*************************************************************************
1040 |*
1041 |* Function aktivieren
1042 |*
1043 \************************************************************************/
1044 
1045 void FuText::Activate()
1046 {
1047 	mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
1048 
1049     // #i89661# it's no longer necessary to make it so big here, it's fine tuned
1050     // for text objects in SdrMarkView::CheckSingleSdrObjectHit
1051 	mpView->SetHitTolerancePixel( 2 * HITPIX );
1052 
1053 	OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1054 
1055 	if (pOLV)
1056 		pOLV->ShowCursor();
1057 
1058 	FuConstruct::Activate();
1059 
1060 	if( pOLV )
1061 		mpView->SetEditMode(SDREDITMODE_EDIT);
1062 }
1063 
1064 
1065 /*************************************************************************
1066 |*
1067 |* Function deaktivieren
1068 |*
1069 \************************************************************************/
1070 
1071 void FuText::Deactivate()
1072 {
1073 	OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1074 
1075 	if (pOLV)
1076 		pOLV->HideCursor();
1077 
1078 	mpView->SetHitTolerancePixel( HITPIX );
1079 
1080 	FuConstruct::Deactivate();
1081 }
1082 
1083 
1084 /*************************************************************************
1085 |*
1086 |* Objekt in Edit-Mode setzen
1087 |*
1088 \************************************************************************/
1089 
1090 void FuText::SetInEditMode(const MouseEvent& rMEvt, sal_Bool bQuickDrag)
1091 {
1092 	SdrPageView* pPV = mpView->GetSdrPageView();
1093 	if( mxTextObj.is() && (mxTextObj->GetPage() == pPV->GetPage()) )
1094 	{
1095 		mpView->SetCurrentObj(OBJ_TEXT);
1096 
1097 		if( bPermanent )
1098 			mpView->SetEditMode(SDREDITMODE_CREATE);
1099 		else
1100 			mpView->SetEditMode(SDREDITMODE_EDIT);
1101 
1102 		sal_Bool bEmptyOutliner = sal_False;
1103 
1104 		if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1105 		{
1106 			::Outliner* pOutl = mpView->GetTextEditOutliner();
1107 			sal_uLong nParaAnz = pOutl->GetParagraphCount();
1108 			Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1109 
1110 			if (nParaAnz==1 && p1stPara)
1111 			{
1112 				// Bei nur einem Pararaph
1113 				if (pOutl->GetText(p1stPara).Len() == 0)
1114 				{
1115 					bEmptyOutliner = sal_True;
1116 				}
1117 			}
1118 		}
1119 
1120 		if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1121 		{
1122 			sal_uInt32 nInv = mxTextObj->GetObjInventor();
1123 			sal_uInt16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1124 
1125 			if (nInv == SdrInventor && GetTextObj()->HasTextEdit() &&
1126 				(nSdrObjKind == OBJ_TEXT ||
1127 			 	nSdrObjKind == OBJ_TITLETEXT ||
1128 			 	nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1129 			{
1130 				// Neuen Outliner machen (gehoert der SdrObjEditView)
1131 				SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
1132 
1133 				if (bEmptyOutliner)
1134 					mpView->SdrEndTextEdit(sal_True);
1135 
1136 				SdrTextObj* pTextObj = GetTextObj();
1137 				if( pTextObj )
1138 				{
1139 					OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1140 					if( ( pOPO && pOPO->IsVertical() ) || (nSlotId == SID_ATTR_CHAR_VERTICAL) || (nSlotId == SID_TEXT_FITTOSIZE_VERTICAL) )
1141 						pOutl->SetVertical( sal_True );
1142 
1143 					if( pTextObj->getTextCount() > 1 )
1144 					{
1145 						Point aPix(rMEvt.GetPosPixel());
1146 						Point aPnt(mpWindow->PixelToLogic(aPix));
1147 						pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1148 					}
1149 
1150 					if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, sal_True, pOutl) && mxTextObj->GetObjInventor() == SdrInventor)
1151 					{
1152 						bFirstObjCreated = sal_True;
1153 						DeleteDefaultText();
1154 
1155 						OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1156 
1157 						nSdrObjKind = mxTextObj->GetObjIdentifier();
1158 
1159 						SdrViewEvent aVEvt;
1160 						SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1161 
1162 						if (eHit == SDRHIT_TEXTEDIT)
1163 						{
1164 							// Text getroffen
1165 							if (nSdrObjKind == OBJ_TEXT ||
1166 								nSdrObjKind == OBJ_TITLETEXT ||
1167 								nSdrObjKind == OBJ_OUTLINETEXT ||
1168 								nSdrObjKind == OBJ_TABLE ||
1169 								nSlotId == SID_TEXTEDIT ||
1170 								!bQuickDrag)
1171 							{
1172 								pOLV->MouseButtonDown(rMEvt);
1173 								pOLV->MouseMove(rMEvt);
1174 								pOLV->MouseButtonUp(rMEvt);
1175 							}
1176 
1177 							if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1178 							{
1179 								pOLV->MouseButtonDown(rMEvt);
1180 							}
1181 						}
1182 						else
1183 						{
1184 							// #98198# Move cursor to end of text
1185 							ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1186 							pOLV->SetSelection(aNewSelection);
1187 						}
1188 					}
1189 					else
1190 					{
1191 						mpView->RestoreDefaultText(dynamic_cast< SdrTextObj* >( mxTextObj.get() ));
1192 					}
1193 				}
1194 			}
1195 		}
1196 	}
1197 	else
1198 	{
1199 		mxTextObj.reset(0);
1200 	}
1201 }
1202 
1203 /*************************************************************************
1204 |*
1205 |* Texteingabe wird gestartet, ggf. Default-Text loeschen
1206 |*
1207 \************************************************************************/
1208 
1209 sal_Bool FuText::DeleteDefaultText()
1210 {
1211 	sal_Bool bDeleted = sal_False;
1212 
1213 	if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() )
1214 	{
1215 		String aString;
1216 		SdPage* pPage = (SdPage*) mxTextObj->GetPage();
1217 
1218 		if (pPage)
1219 		{
1220 			PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1221 
1222 			if ( (ePresObjKind == PRESOBJ_TITLE   ||
1223 				  ePresObjKind == PRESOBJ_OUTLINE ||
1224 				  ePresObjKind == PRESOBJ_NOTES   ||
1225 				  ePresObjKind == PRESOBJ_TEXT) &&
1226 				  !pPage->IsMasterPage() )
1227 			{
1228 				::Outliner* pOutliner = mpView->GetTextEditOutliner();
1229 				SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1230 				sal_Bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1231 				if( bIsUndoEnabled )
1232 					pOutliner->EnableUndo(sal_False);
1233 
1234 				pOutliner->SetText( String(), pOutliner->GetParagraph( 0 ) );
1235 
1236 				if( bIsUndoEnabled )
1237 					pOutliner->EnableUndo(sal_True);
1238 
1239 				if (pSheet &&
1240 					(ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1241 					pOutliner->SetStyleSheet(0, pSheet);
1242 
1243 				mxTextObj->SetEmptyPresObj(sal_True);
1244 				bDeleted = sal_True;
1245 			}
1246 		}
1247 	}
1248 
1249 	return(bDeleted);
1250 }
1251 
1252 /*************************************************************************
1253 |*
1254 |* Command-event
1255 |*
1256 \************************************************************************/
1257 
1258 sal_Bool FuText::Command(const CommandEvent& rCEvt)
1259 {
1260 	return( FuPoor::Command(rCEvt) );
1261 }
1262 
1263 /*************************************************************************
1264 |*
1265 |* Help-event
1266 |*
1267 \************************************************************************/
1268 
1269 sal_Bool FuText::RequestHelp(const HelpEvent& rHEvt)
1270 {
1271 	sal_Bool bReturn = sal_False;
1272 
1273 	OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1274 
1275 	if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1276 		mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1277 	{
1278 		String aHelpText;
1279 		const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1280 		const SvxFieldData* pField = pFieldItem->GetField();
1281 
1282 		if (pField && pField->ISA(SvxURLField))
1283 		{
1284 			/******************************************************************
1285 			* URL-Field
1286 			******************************************************************/
1287 			aHelpText = INetURLObject::decode( ((const SvxURLField*)pField)->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1288 		}
1289 		if (aHelpText.Len())
1290 		{
1291 			Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1292 			Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1293 								  mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1294 
1295 			if (Help::IsBalloonHelpEnabled())
1296 			{
1297 				bReturn = Help::ShowBalloon( (Window*)mpWindow, rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1298 			}
1299 			else if (Help::IsQuickHelpEnabled())
1300 			{
1301 				bReturn = Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1302 			}
1303 		}
1304 	}
1305 
1306 	if (!bReturn)
1307 	{
1308 		bReturn = FuConstruct::RequestHelp(rHEvt);
1309 	}
1310 
1311 	return(bReturn);
1312 }
1313 
1314 /*************************************************************************
1315 |*
1316 |* Request verarbeiten
1317 |*
1318 \************************************************************************/
1319 
1320 void FuText::ReceiveRequest(SfxRequest& rReq)
1321 {
1322 	nSlotId = rReq.GetSlot();
1323 
1324 	// Dann Basisklasse rufen (dort wird u.a. nSlotId NICHT gesetzt)
1325 	FuPoor::ReceiveRequest(rReq);
1326 
1327 	if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || /*#95971#*/ SID_ATTR_CHAR == nSlotId)
1328 	{
1329 		MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1330 
1331 		mxTextObj.reset(0);
1332 
1333 		if (nSlotId == SID_TEXTEDIT)
1334 		{
1335 			// Wird gerade editiert?
1336 			if(!bTestText)
1337 				mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetTextEditObject() ) );
1338 
1339 			if (!mxTextObj.is())
1340 			{
1341 				// Versuchen, ein Obj zu selektieren
1342 				SdrPageView* pPV = mpView->GetSdrPageView();
1343 				SdrViewEvent aVEvt;
1344 				mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1345 				mpView->MarkObj(aVEvt.pRootObj, pPV);
1346 
1347 				if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
1348 				{
1349 					mxTextObj.reset( static_cast< SdrTextObj* >( aVEvt.pObj ) );
1350 				}
1351 			}
1352 		}
1353 		else if (mpView->AreObjectsMarked())
1354 		{
1355 			const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1356 
1357 			if (rMarkList.GetMarkCount() == 1)
1358 			{
1359 				SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1360 
1361 				if (pObj->ISA(SdrTextObj))
1362 				{
1363 					mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1364 				}
1365 			}
1366 		}
1367 
1368 		sal_Bool bQuickDrag = sal_True;
1369 
1370 		const SfxItemSet* pArgs = rReq.GetArgs();
1371 
1372 		if (pArgs
1373 
1374 			// #98198# test for type before using
1375 			&& SID_TEXTEDIT == nSlotId
1376 			&& SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
1377 
1378 			&& (sal_uInt16) ((SfxUInt16Item&) pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1379 		{
1380 			// Anwahl per Doppelklick -> kein QuickDrag zulassen
1381 			bQuickDrag = sal_False;
1382 		}
1383 
1384 		SetInEditMode(aMEvt, bQuickDrag);
1385 	}
1386 }
1387 
1388 
1389 
1390 /*************************************************************************
1391 |*
1392 |* SpellChecker: Error-LinkHdl
1393 |*
1394 \************************************************************************/
1395 
1396 IMPL_LINK( FuText, SpellError, void *, nLang )
1397 {
1398 	String aError( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_uLong)nLang ) );
1399 	ErrorHandler::HandleError(* new StringErrorInfo(
1400 								ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aError) );
1401 	return 0;
1402 }
1403 
1404 
1405 /*************************************************************************
1406 |*
1407 |* Reaktion auf Doppelklick
1408 |*
1409 \************************************************************************/
1410 void FuText::DoubleClick(const MouseEvent& )
1411 {
1412 	// Nichts zu tun
1413 }
1414 
1415 /** #97016#
1416     #105815# Removed the insertion of default text and putting a new text
1417     object directly into edit mode.
1418 */
1419 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
1420 {
1421 	// case SID_TEXTEDIT:	// BASIC ???
1422 	// case SID_ATTR_CHAR:
1423 	// case SID_ATTR_CHAR_VERTICAL:
1424 	// case SID_TEXT_FITTOSIZE:
1425 	// case SID_TEXT_FITTOSIZE_VERTICAL:
1426 
1427 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
1428 		mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
1429 		0L, mpDoc);
1430 
1431 	if(pObj)
1432 	{
1433 		if(pObj->ISA(SdrTextObj))
1434 		{
1435 			SdrTextObj* pText = (SdrTextObj*)pObj;
1436 			pText->SetLogicRect(rRectangle);
1437 
1438 			sal_Bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1439 			pText->SetVerticalWriting(bVertical);
1440 
1441 			// #97016#
1442 			ImpSetAttributesForNewTextObject(pText);
1443 
1444 			if (nSlotId == SID_TEXT_FITTOSIZE)
1445 			{
1446 				// #97016#
1447 				ImpSetAttributesFitToSize(pText);
1448 			}
1449 			else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1450 			{
1451 				// #97016#
1452 				ImpSetAttributesFitToSizeVertical(pText);
1453 			}
1454 			else
1455 			{
1456 				// #97016#
1457 				ImpSetAttributesFitCommon(pText);
1458 			}
1459 
1460             // Put text object into edit mode.
1461             SdrPageView* pPV = mpView->GetSdrPageView();
1462             mpView->SdrBeginTextEdit(pText, pPV);
1463 		}
1464 		else
1465 		{
1466 			DBG_ERROR("Object is NO text object");
1467 		}
1468 	}
1469 
1470 	return pObj;
1471 }
1472 
1473 
1474 
1475 
1476 /** is called when the currenct function should be aborted. <p>
1477 	This is used when a function gets a KEY_ESCAPE but can also
1478 	be called directly.
1479 
1480 	@returns true if a active function was aborted
1481 */
1482 bool FuText::cancel()
1483 {
1484 	if ( mpView->IsTextEdit() )
1485 	{
1486 		if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
1487 			mxTextObj.reset(0);
1488 
1489 		mpView->SetCurrentObj(OBJ_TEXT);
1490 		mpView->SetEditMode(SDREDITMODE_EDIT);
1491 		return true;
1492 	}
1493 	else
1494 	{
1495 		return false;
1496 	}
1497 }
1498 
1499 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1500 {
1501     if( !pFontList || !pView )
1502         return;
1503 
1504     if( pOLV )
1505     {
1506         pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1507     }
1508     else
1509     {
1510 //		SdDrawDocument* pDoc = pView->GetDoc();
1511 
1512         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1513         for( sal_uInt32 nMark = 0; nMark < rMarkList.GetMarkCount(); nMark++ )
1514         {
1515             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1516             if( pTextObj )
1517             {
1518                 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1519                 {
1520                     pTextObj->setActiveText( nText );
1521 
1522                     // Put text object into edit mode.
1523                     SdrPageView* pPV = pView->GetSdrPageView();
1524                     pView->SdrBeginTextEdit(pTextObj, pPV);
1525 
1526                     pOLV = pView->GetTextEditOutlinerView();
1527                     if( pOLV )
1528                     {
1529                         EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1530                         if( pEditEngine )
1531                         {
1532                             ESelection aSel;
1533                             aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1534                             aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1535                             pOLV->SetSelection(aSel);
1536                         }
1537 
1538                         ChangeFontSize( bGrow, pOLV, pFontList, pView );
1539                     }
1540 
1541                     pView->SdrEndTextEdit();
1542                 }
1543 
1544                 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1545                 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1546                 {
1547                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1548                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1549                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1550                 }
1551             }
1552         }
1553     }
1554 }
1555 
1556 } // end of namespace sd
1557 
1558