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