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