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