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