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