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