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