bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / func / futext.cxx
blob6784daa6714035f984e79105549d883e799a50cf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "futext.hxx"
21 #include <editeng/eeitem.hxx>
22 #include <editeng/editerr.hxx>
23 #include <svx/dlgutil.hxx>
24 #include <svx/svxerr.hxx>
25 #include <tools/urlobj.hxx>
26 #include <vcl/help.hxx>
27 #include <editeng/editstat.hxx>
28 #include <svl/aeitem.hxx>
29 #include <svl/intitem.hxx>
30 #include <svx/svdotext.hxx>
31 #include <svx/svdogrp.hxx>
32 #include <editeng/flditem.hxx>
33 #include <svl/style.hxx>
34 #include <svx/svdpagv.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/bindings.hxx>
38 #include <sfx2/request.hxx>
39 #include <editeng/editeng.hxx>
40 #include <svx/svdoutl.hxx>
41 #include <svx/svxids.hrc>
42 #include <sfx2/docfile.hxx>
43 #include <comphelper/processfactory.hxx>
44 #include <editeng/outlobj.hxx>
45 #include <svtools/langtab.hxx>
47 #include <editeng/frmdiritem.hxx>
49 #include <svx/svdetc.hxx>
50 #include <editeng/editview.hxx>
52 #include "sdresid.hxx"
53 #include "app.hrc"
54 #include "res_bmp.hrc"
55 #include "ViewShell.hxx"
56 #include "ViewShellBase.hxx"
57 #include "View.hxx"
58 #include "Outliner.hxx"
59 #include "Window.hxx"
60 #include "drawdoc.hxx"
61 #include "sdpage.hxx"
62 #include "sdmod.hxx"
63 #include "FrameView.hxx"
64 #include "ToolBarManager.hxx"
65 #include "DrawDocShell.hxx"
66 #include "glob.hrc"
67 #include "pres.hxx"
68 #include "optsitem.hxx"
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::lang;
73 using namespace ::com::sun::star::linguistic2;
75 namespace sd {
77 static sal_uInt16 SidArray[] = {
78 SID_STYLE_FAMILY2, // 5542
79 SID_STYLE_FAMILY5, // 5545
80 SID_REDO, // 5700
81 SID_UNDO, // 5701
82 SID_CUT, // 5710
83 SID_COPY, // 5711
84 SID_ATTR_TABSTOP, // 10002
85 SID_ATTR_CHAR_FONT, // 10007
86 SID_ATTR_CHAR_POSTURE, // 10008
87 SID_ATTR_CHAR_WEIGHT, // 10009
88 SID_ATTR_CHAR_SHADOWED, //10010
89 SID_ATTR_CHAR_STRIKEOUT, //10013
90 SID_ATTR_CHAR_UNDERLINE, // 10014
91 SID_ATTR_CHAR_FONTHEIGHT, // 10015
92 SID_ATTR_CHAR_COLOR, // 10017
93 SID_ATTR_CHAR_KERNING, //10018
94 SID_ATTR_PARA_ADJUST_LEFT, // 10028
95 SID_ATTR_PARA_ADJUST_RIGHT, // 10029
96 SID_ATTR_PARA_ADJUST_CENTER, // 10030
97 SID_ATTR_PARA_ADJUST_BLOCK, // 10031
98 SID_ATTR_PARA_LINESPACE_10, // 10034
99 SID_ATTR_PARA_LINESPACE_15, // 10035
100 SID_ATTR_PARA_LINESPACE_20, // 10036
101 SID_ATTR_PARA_ULSPACE, // 10042
102 SID_ATTR_PARA_LRSPACE, // 10043
103 SID_ATTR_TRANSFORM_POS_X, // 10088
104 SID_ATTR_TRANSFORM_POS_Y, // 10089
105 SID_ATTR_TRANSFORM_WIDTH, // 10090
106 SID_ATTR_TRANSFORM_HEIGHT,// 10091
107 SID_ATTR_TRANSFORM_ROT_X, // 10093
108 SID_ATTR_TRANSFORM_ROT_Y, // 10094
109 SID_ATTR_TRANSFORM_ANGLE, // 10095 //Added
110 SID_OUTLINE_UP, // 10150
111 SID_OUTLINE_DOWN, // 10151
112 SID_OUTLINE_LEFT, // 10152
113 SID_OUTLINE_RIGHT, // 10153
114 SID_ATTR_TRANSFORM_PROTECT_POS,// 10236
115 SID_ATTR_TRANSFORM_PROTECT_SIZE,// 10237 //Added
116 SID_FORMTEXT_STYLE, // 10257
117 SID_SET_SUPER_SCRIPT, // 10294
118 SID_SET_SUB_SCRIPT, // 10295
119 SID_ATTR_TRANSFORM_AUTOWIDTH,// 10310
120 SID_ATTR_TRANSFORM_AUTOHEIGHT,// 10311 //Added
121 SID_HYPERLINK_GETLINK, // 10361
122 SID_CHARMAP, // 10503
123 SID_TEXTDIRECTION_LEFT_TO_RIGHT, // 10907
124 SID_TEXTDIRECTION_TOP_TO_BOTTOM, // 10908
125 SID_ATTR_PARA_LEFT_TO_RIGHT, // 10950
126 SID_ATTR_PARA_RIGHT_TO_LEFT, // 10951
127 FN_NUM_BULLET_ON, // 20138
128 SID_PARASPACE_INCREASE, // 27346
129 SID_PARASPACE_DECREASE, // 27347
130 0 };
132 TYPEINIT1( FuText, FuConstruct );
135 static sal_Bool bTestText = 0;
138 * base class for text functions
140 FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
141 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
142 , bFirstObjCreated(sal_False)
143 , bJustEndedEdit(false)
144 , rRequest (rReq)
148 FunctionReference FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
150 FunctionReference xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
151 return xFunc;
154 /** Destruktor */
155 void FuText::disposing()
157 if(mpView)
159 if(mpView->SdrEndTextEdit(sal_False) == SDRENDTEXTEDIT_DELETED)
160 mxTextObj.reset( 0 );
162 // reset the RequestHandler of the used Outliner to the handler of the document
163 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
165 if (pOutliner)
166 pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
170 /*************************************************************************
172 |* Execute functionality of this class:
174 |* #71422: Start the functionality of this class in this method
175 |* and not in the ctor.
176 |* If you construct an object of this class and you put the
177 |* address of this object to pFuActual you've got a problem,
178 |* because some methods inside DoExecute use the pFuActual-Pointer.
179 |* If the code inside DoExecute is executed inside the ctor,
180 |* the value of pFuActual is not right. And the value will not
181 |* be right until the ctor finished !!!
183 \************************************************************************/
184 void FuText::DoExecute( SfxRequest& )
186 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
187 ToolBarManager::TBG_FUNCTION,
188 RID_DRAW_TEXT_TOOLBOX);
190 mpView->SetCurrentObj(OBJ_TEXT);
191 mpView->SetEditMode(SDREDITMODE_EDIT);
193 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
195 if (nSlotId == SID_TEXTEDIT)
197 // Try to select an object
198 SdrPageView* pPV = mpView->GetSdrPageView();
199 SdrViewEvent aVEvt;
200 mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
201 mpView->MarkObj(aVEvt.pRootObj, pPV);
203 mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
205 else if (mpView->AreObjectsMarked())
207 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
209 if (rMarkList.GetMarkCount() == 1)
211 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
212 mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
216 // check for table
217 if (mpView->AreObjectsMarked())
219 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
221 if (rMarkList.GetMarkCount() == 1)
223 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
224 if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
226 mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX );
231 sal_Bool bQuickDrag = sal_True;
233 const SfxItemSet* pArgs = rRequest.GetArgs();
235 if (pArgs
237 // test for type before using
238 && SID_TEXTEDIT == nSlotId
239 && SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
241 && (sal_uInt16)((SfxUInt16Item&)pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
243 // Selection by doubleclick -> don't allow QuickDrag
244 bQuickDrag = sal_False;
247 SetInEditMode(aMEvt, bQuickDrag);
250 sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
252 bMBDown = sal_True;
253 bJustEndedEdit = false;
255 sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
257 mpView->SetMarkHdlWhenTextEdit(sal_True);
258 SdrViewEvent aVEvt;
259 SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
261 if (eHit == SDRHIT_TEXTEDIT)
263 // hit text -> SdrView handles event
264 if (mpView->MouseButtonDown(rMEvt, mpWindow))
265 return (sal_True);
268 if (rMEvt.GetClicks() == 1)
270 if (mpView->IsTextEdit() && eHit != SDRHIT_MARKEDOBJECT && eHit != SDRHIT_HANDLE)
272 // finish text input
273 if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
275 /* Bugfix from MBA: during a double click onto the unused? area
276 in text mode, we get with the second click eHit =
277 SDRHIT_TEXTEDITOBJ since it goes to the TextObject which was
278 created with the first click. But this is removed by
279 SdrEndTextEdit since it is empty. But it is still in the mark
280 list. The call MarkObj further below accesses then the dead
281 object. As a simple fix, we determine eHit after
282 SdrEndTextEdit again, this returns then SDRHIT_NONE. */
283 mxTextObj.reset( NULL );
284 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
287 mpView->SetCurrentObj(OBJ_TEXT);
288 mpView->SetEditMode(SDREDITMODE_EDIT);
291 if (rMEvt.IsLeft() || rMEvt.IsRight())
293 mpWindow->CaptureMouse();
294 SdrObject* pObj;
295 SdrPageView* pPV = mpView->GetSdrPageView();
297 if (eHit == SDRHIT_TEXTEDIT)
299 SetInEditMode(rMEvt, sal_False);
301 else
303 sal_Bool bMacro = sal_False;
305 if (bMacro && mpView->PickObj(aMDPos,mpView->getHitTolLog(),pObj,pPV,SDRSEARCH_PICKMACRO))
307 // Macro
308 sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
309 mpView->BegMacroObj(aMDPos,nHitLog,pObj,pPV,mpWindow);
311 else
313 if (eHit != SDRHIT_HANDLE)
315 // deselect selection
316 if (!rMEvt.IsShift() && eHit == SDRHIT_TEXTEDITOBJ)
318 mpView->UnmarkAll();
319 mpView->SetDragMode(SDRDRAG_MOVE);
323 if ( aVEvt.eEvent == SDREVENT_EXECUTEURL ||
324 eHit == SDRHIT_HANDLE ||
325 eHit == SDRHIT_MARKEDOBJECT ||
326 eHit == SDRHIT_TEXTEDITOBJ ||
327 ( eHit == SDRHIT_UNMARKEDOBJECT && bFirstObjCreated &&
328 !bPermanent ) )
330 // Handle, hit marked or umarked object
331 if (eHit == SDRHIT_TEXTEDITOBJ)
333 /* hit text of unmarked object:
334 select object and set to EditMode */
335 mpView->MarkObj(aVEvt.pRootObj, pPV);
337 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
339 mxTextObj.reset( static_cast<SdrTextObj*>(aVEvt.pObj) );
342 SetInEditMode(rMEvt, sal_True);
344 else if (aVEvt.eEvent == SDREVENT_EXECUTEURL && !rMEvt.IsMod2())
346 // execute URL
347 mpWindow->ReleaseMouse();
348 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
349 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
350 SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
351 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
352 mpWindow->ReleaseMouse();
354 if (rMEvt.IsMod1())
356 // open in new frame
357 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
358 &aStrItem, &aBrowseItem, &aReferer, 0L);
360 else
362 // open in current frame
363 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
364 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
365 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
368 else
370 // drag object or handle
372 // #i78748#
373 // do the EndTextEdit first, it will delete the handles and force a
374 // recreation. This will make aVEvt.pHdl to point to a deleted handle,
375 // thus it is necessary to reset it and to get it again.
377 // #i112855#
378 // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObjet
379 // this caused SdrEndTextEdit() to be called also when not in text editing and
380 // this does not make sense and caused troubles. (see issue 112855)
382 if( mpView->IsTextEdit() )
384 mpView->SdrEndTextEdit();
385 bJustEndedEdit = true;
387 if(aVEvt.pHdl)
389 // force new handle identification, the pointer will be dead here
390 // since SdrEndTextEdit has resetted (deleted) the handles.
391 aVEvt.pHdl = 0;
392 mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
396 if (!aVEvt.pHdl)
398 if( eHit == SDRHIT_UNMARKEDOBJECT )
400 if ( !rMEvt.IsShift() )
401 mpView->UnmarkAll();
403 mpView->MarkObj(aVEvt.pRootObj, pPV);
406 // Drag object
407 bFirstMouseMove = sal_True;
408 aDragTimer.Start();
412 if ( ! rMEvt.IsRight())
414 // we need to pick again since SdrEndTextEdit can rebuild the handles list
415 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
416 if( (eHit == SDRHIT_HANDLE) || (eHit == SDRHIT_MARKEDOBJECT) )
418 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
419 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
422 bReturn = true;
425 else if ( nSlotId != SID_TEXTEDIT &&
426 (bPermanent || !bFirstObjCreated) )
428 // create object
429 mpView->SetCurrentObj(OBJ_TEXT);
430 mpView->SetEditMode(SDREDITMODE_CREATE);
431 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
432 mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
434 else
436 // select
437 if( !rMEvt.IsShift() )
438 mpView->UnmarkAll();
440 mpView->BegMarkObj( aMDPos );
446 else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
448 MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
449 SetInEditMode( aMEvt, sal_False );
452 if (!bIsInDragMode)
454 ForcePointer(&rMEvt);
455 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
458 return (bReturn);
461 sal_Bool FuText::MouseMove(const MouseEvent& rMEvt)
463 sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
465 if (aDragTimer.IsActive() )
467 if( bFirstMouseMove )
468 bFirstMouseMove = sal_False;
469 else
470 aDragTimer.Stop();
473 if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
475 Point aPix(rMEvt.GetPosPixel());
476 Point aPnt(mpWindow->PixelToLogic(aPix));
478 ForceScroll(aPix);
479 mpView->MovAction(aPnt);
482 ForcePointer(&rMEvt);
484 return (bReturn);
487 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
489 if(mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
491 if( nSlotId == SID_ATTR_CHAR )
493 /* Create Impress text object (rescales to line height)
494 We get the correct height during the subsequent creation of the
495 object, otherwise we draw to much */
496 SfxItemSet aSet(mpViewShell->GetPool());
497 aSet.Put(SdrTextMinFrameHeightItem(0));
498 aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
499 aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
500 pTxtObj->SetMergedItemSet(aSet);
501 pTxtObj->AdjustTextFrameWidthAndHeight();
502 aSet.Put(SdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
503 pTxtObj->SetMergedItemSet(aSet);
505 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
507 SfxItemSet aSet(mpViewShell->GetPool());
508 aSet.Put(SdrTextMinFrameWidthItem(0));
509 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
510 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
512 // Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
513 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
514 pTxtObj->SetMergedItemSet(aSet);
515 pTxtObj->AdjustTextFrameWidthAndHeight();
516 aSet.Put(SdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
517 pTxtObj->SetMergedItemSet(aSet);
520 else
522 if( nSlotId == SID_ATTR_CHAR_VERTICAL )
524 // draw text object, needs to be initialized when vertical text is used
525 SfxItemSet aSet(mpViewShell->GetPool());
527 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
528 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
530 // Set defaults for vertical klick-n'drag text object, pool defaults are:
531 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
532 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
533 // Analog to that:
534 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
535 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
537 pTxtObj->SetMergedItemSet(aSet);
542 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
544 // FitToSize (fit to frame)
545 SfxItemSet aSet(mpViewShell->GetPool(), SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
546 SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
547 aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
548 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
549 aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
550 pTxtObj->SetMergedItemSet(aSet);
551 pTxtObj->AdjustTextFrameWidthAndHeight();
554 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
556 SfxItemSet aSet(mpViewShell->GetPool(),
557 SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
558 SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
559 aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
560 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
561 aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
562 pTxtObj->SetMergedItemSet(aSet);
563 pTxtObj->AdjustTextFrameWidthAndHeight();
566 void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
568 // Normal Textobject
569 if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
571 if( nSlotId == SID_ATTR_CHAR )
573 // Impress text object (rescales to line height)
574 SfxItemSet aSet(mpViewShell->GetPool());
575 aSet.Put(SdrTextMinFrameHeightItem(0));
576 aSet.Put(SdrTextMaxFrameHeightItem(0));
577 aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
578 aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
579 pTxtObj->SetMergedItemSet(aSet);
581 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
583 SfxItemSet aSet(mpViewShell->GetPool());
584 aSet.Put(SdrTextMinFrameWidthItem(0));
585 aSet.Put(SdrTextMaxFrameWidthItem(0));
586 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
587 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
588 pTxtObj->SetMergedItemSet(aSet);
591 pTxtObj->AdjustTextFrameWidthAndHeight();
595 sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
597 sal_Bool bReturn = sal_False;
598 SdrObject* pObj;
599 SdrPageView* pPV;
600 if (aDragTimer.IsActive())
602 aDragTimer.Stop();
603 bIsInDragMode = sal_False;
606 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
608 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
610 if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
611 return (sal_True); // handle event from SdrView
613 sal_Bool bEmptyTextObj = sal_False;
615 if (mxTextObj.is())
617 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
619 if (rMarkList.GetMarkCount() == 1
620 && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
622 if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
623 bEmptyTextObj = sal_True;
624 else
625 bFirstObjCreated = sal_True;
627 else
629 mxTextObj.reset( 0 );
633 if( mpView && mpView->IsDragObj())
635 // object was moved
636 FrameView* pFrameView = mpViewShell->GetFrameView();
637 sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
639 if (bDragWithCopy)
641 bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
644 mpView->SetDragWithCopy(bDragWithCopy);
645 mpView->EndDragObj( mpView->IsDragWithCopy() );
646 mpView->ForceMarkedToAnotherPage();
647 mpView->SetCurrentObj(OBJ_TEXT);
649 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
651 if (bJustEndedEdit)
653 bJustEndedEdit = false;
654 FuPoor::cancel();
656 if ((rMEvt.GetClicks() != 2) &&
657 !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
658 std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
659 std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
661 /*************************************************************
662 * From text mode, you don't want to rotate immediately.
663 **************************************************************/
664 if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
666 mpView->UnmarkAllObj();
667 mpView->MarkObj(pObj,pPV,false,false);
668 return (bReturn);
672 else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
674 // object was created
675 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
677 if( mxTextObj.is() )
679 //AW outliner needs to be set to vertical when there is no
680 // outliner object up to now; also it needs to be set back to not
681 // vertical when there was a vertical one used last time.
682 OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
683 SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj());
684 sal_Bool bVertical((pOPO && pOPO->IsVertical())
685 || nSlotId == SID_ATTR_CHAR_VERTICAL
686 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
687 rOutl.SetVertical(bVertical);
689 // Before ImpSetAttributesForNewTextObject the vertical writing mode
690 // needs to be set at the object. This is done here at the OutlinerParaObject
691 // directly to not mirror the layout text items involved. These items will be set
692 // from ImpSetAttributesForNewTextObject and below.
693 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
695 if(!pPara)
697 GetTextObj()->ForceOutlinerParaObject();
698 pPara = GetTextObj()->GetOutlinerParaObject();
701 if(pPara && (bool)bVertical != pPara->IsVertical())
703 // set ParaObject orientation accordingly
704 pPara->SetVertical(bVertical);
707 ImpSetAttributesForNewTextObject(GetTextObj());
710 if (!mpView->EndCreateObj(SDRCREATE_FORCEEND))
712 // it was not possible to create text object
713 mxTextObj.reset(0);
715 else if (nSlotId == SID_TEXT_FITTOSIZE)
717 ImpSetAttributesFitToSize(GetTextObj());
719 SetInEditMode(rMEvt, sal_False);
721 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
723 ImpSetAttributesFitToSizeVertical(GetTextObj());
725 SetInEditMode(rMEvt, sal_False);
727 else
729 ImpSetAttributesFitCommon(GetTextObj());
731 // thereby the handles and the gray frame are correct
732 mpView->AdjustMarkHdl();
733 mpView->PickHandle(aPnt);
734 SetInEditMode(rMEvt, sal_False);
737 else if ( mpView && mpView->IsAction())
739 mpView->EndAction();
742 ForcePointer(&rMEvt);
743 mpWindow->ReleaseMouse();
744 sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
746 if ( mpView && !mpView->AreObjectsMarked() &&
747 std::abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
748 std::abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
749 !rMEvt.IsShift() && !rMEvt.IsMod2() )
751 SdrPageView* pPV2 = mpView->GetSdrPageView();
752 SdrViewEvent aVEvt;
753 mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
754 mpView->MarkObj(aVEvt.pRootObj, pPV2);
757 if ( !mxTextObj.is() && mpView )
759 if ( ( (!bEmptyTextObj && bPermanent) ||
760 (!bFirstObjCreated && !bPermanent) ) &&
761 !mpDocSh->IsReadOnly() &&
762 nSlotId != SID_TEXTEDIT )
764 // text body (left-justified AutoGrow)
765 mpView->SetCurrentObj(OBJ_TEXT);
766 mpView->SetEditMode(SDREDITMODE_CREATE);
767 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
768 mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
770 sal_Bool bSnapEnabled = mpView->IsSnapEnabled();
772 if (bSnapEnabled)
773 mpView->SetSnapEnabled(sal_False);
775 aPnt.X() += nDrgLog + nDrgLog;
776 aPnt.Y() += nDrgLog + nDrgLog;
777 mpView->MovAction(aPnt);
779 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
781 if(mxTextObj.is())
783 GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
786 if(!mpView->EndCreateObj(SDRCREATE_FORCEEND))
788 mxTextObj.reset(0);
791 if(bSnapEnabled)
792 mpView->SetSnapEnabled(bSnapEnabled);
794 if(mxTextObj.is())
796 SfxItemSet aSet(mpViewShell->GetPool());
797 aSet.Put(SdrTextMinFrameHeightItem(0));
798 aSet.Put(SdrTextMinFrameWidthItem(0));
799 aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
800 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
802 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
804 // Here, all items which need to be different from pool default need to be set
805 // again on the newly created text object.
806 // Since this is a simple klick text object, it is first created, then SetVertical()
807 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
808 // deleted again since not the minimum drag distance was travelled. Then, a new
809 // klick text object is created and thus all that stuff needs to be set again here.
811 // Before using the new object the vertical writing mode
812 // needs to be set. This is done here at the OutlinerParaObject
813 // directly to not mirror the layout text items involved. These items will be set
814 // below.
815 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
817 if(!pPara)
819 GetTextObj()->ForceOutlinerParaObject();
820 pPara = GetTextObj()->GetOutlinerParaObject();
823 if(pPara && sal_True != pPara->IsVertical())
825 // set ParaObject orientation accordingly
826 pPara->SetVertical(sal_True);
829 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
831 // Analog to the else case below, for vertical simple click texts
832 // one of the defaulted setted items from ImpSetAttributesForNewTextObject
833 // needs to be adapted to non-block mode.
834 const SfxItemSet& rSet = mpView->GetDefaultAttr();
835 SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
837 if(FRMDIR_HORI_RIGHT_TOP == eDirection || FRMDIR_VERT_TOP_RIGHT == eDirection)
839 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
841 else
843 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
846 else
848 // This is for Format/Page settings. Since this also leads
849 // to the object defaults to be changed, i think this code can be
850 // removed. CL. wanted to take a look before adding this.
852 // Look in the object defaults if left-to-right is wanted. If
853 // yes, set text anchoring to right to let the box grow to left.
854 const SfxItemSet& rSet = mpView->GetDefaultAttr();
855 SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
857 if(FRMDIR_HORI_RIGHT_TOP == eDirection)
859 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
861 else
863 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
867 GetTextObj()->SetMergedItemSet(aSet);
868 GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
869 SetInEditMode(rMEvt, sal_False);
872 bFirstObjCreated = sal_True;
874 else
876 // switch to selection
877 if (mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
879 mxTextObj.reset(0);
882 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
883 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
886 if (bJustEndedEdit)
888 bJustEndedEdit = false;
889 FuPoor::cancel();
891 bMBDown = sal_False;
892 FuConstruct::MouseButtonUp(rMEvt);
893 return (bReturn);
897 * handle keyboard events
898 * @returns sal_True if the event was handled, sal_False otherwise
900 sal_Bool FuText::KeyInput(const KeyEvent& rKEvt)
902 sal_Bool bReturn = sal_False;
903 mpView->SetMarkHdlWhenTextEdit(sal_True);
905 KeyCode nCode = rKEvt.GetKeyCode();
906 sal_Bool bShift = nCode.IsShift();
908 if(mxTextObj.is())
910 // maybe object is deleted, test if it's equal to the selected object
911 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
912 SdrObject* pSelectedObj = 0L;
914 if(1 == rMarkList.GetMarkCount())
916 SdrMark* pMark = rMarkList.GetMark(0);
917 pSelectedObj = pMark->GetMarkedSdrObj();
920 if(mxTextObj.get() != pSelectedObj)
922 mxTextObj.reset(0);
926 if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
928 // title text object: always soft breaks
929 bShift = sal_True;
932 sal_uInt16 nKey = nCode.GetCode();
933 KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
934 KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
936 sal_Bool bOK = sal_True;
938 if (mpDocSh->IsReadOnly())
940 bOK = !EditEngine::DoesKeyChangeText(aKEvt);
942 if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
944 bOK = sal_False; // default handling in base class
947 if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
949 bReturn = sal_True;
951 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
954 else if (aKeyCode == KEY_ESCAPE)
956 bReturn = cancel();
959 if( bPermanent )
961 mpView->SetCurrentObj(OBJ_TEXT);
962 mpView->SetEditMode(SDREDITMODE_CREATE);
965 if (!bReturn)
967 bReturn = FuDraw::KeyInput(aKEvt);
970 return (bReturn);
975 void FuText::Activate()
977 mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
979 // #i89661# it's no longer necessary to make it so big here, it's fine tuned
980 // for text objects in SdrMarkView::CheckSingleSdrObjectHit
981 mpView->SetHitTolerancePixel( 2 * HITPIX );
983 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
985 if (pOLV)
986 pOLV->ShowCursor();
988 FuConstruct::Activate();
990 if( pOLV )
991 mpView->SetEditMode(SDREDITMODE_EDIT);
995 void FuText::Deactivate()
997 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
999 if (pOLV)
1000 pOLV->HideCursor();
1002 mpView->SetHitTolerancePixel( HITPIX );
1004 FuConstruct::Deactivate();
1009 * Sets the object into the edit mode.
1011 void FuText::SetInEditMode(const MouseEvent& rMEvt, sal_Bool bQuickDrag)
1013 SdrPageView* pPV = mpView->GetSdrPageView();
1014 if( mxTextObj.is() && (mxTextObj->GetPage() == pPV->GetPage()) )
1016 mpView->SetCurrentObj(OBJ_TEXT);
1018 if( bPermanent )
1019 mpView->SetEditMode(SDREDITMODE_CREATE);
1020 else
1021 mpView->SetEditMode(SDREDITMODE_EDIT);
1023 sal_Bool bEmptyOutliner = sal_False;
1025 if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1027 ::Outliner* pOutl = mpView->GetTextEditOutliner();
1028 sal_Int32 nParaAnz = pOutl->GetParagraphCount();
1029 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1031 if (nParaAnz==1 && p1stPara)
1033 // with only one paragraph
1034 if (pOutl->GetText(p1stPara).Len() == 0)
1036 bEmptyOutliner = sal_True;
1041 if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1043 sal_uInt32 nInv = mxTextObj->GetObjInventor();
1044 sal_uInt16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1046 if (nInv == SdrInventor && GetTextObj()->HasTextEdit() &&
1047 (nSdrObjKind == OBJ_TEXT ||
1048 nSdrObjKind == OBJ_TITLETEXT ||
1049 nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1051 // create new outliner (owned by SdrObjEditView)
1052 SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
1054 if (bEmptyOutliner)
1055 mpView->SdrEndTextEdit(sal_True);
1057 SdrTextObj* pTextObj = GetTextObj();
1058 if( pTextObj )
1060 OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1061 if( ( pOPO && pOPO->IsVertical() ) || (nSlotId == SID_ATTR_CHAR_VERTICAL) || (nSlotId == SID_TEXT_FITTOSIZE_VERTICAL) )
1062 pOutl->SetVertical( sal_True );
1064 if( pTextObj->getTextCount() > 1 )
1066 Point aPix(rMEvt.GetPosPixel());
1067 Point aPnt(mpWindow->PixelToLogic(aPix));
1068 pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1071 if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, sal_True, pOutl) && mxTextObj->GetObjInventor() == SdrInventor)
1073 bFirstObjCreated = sal_True;
1074 DeleteDefaultText();
1076 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1078 nSdrObjKind = mxTextObj->GetObjIdentifier();
1080 SdrViewEvent aVEvt;
1081 SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1083 if (eHit == SDRHIT_TEXTEDIT)
1085 // hit text
1086 if (nSdrObjKind == OBJ_TEXT ||
1087 nSdrObjKind == OBJ_TITLETEXT ||
1088 nSdrObjKind == OBJ_OUTLINETEXT ||
1089 nSdrObjKind == OBJ_TABLE ||
1090 nSlotId == SID_TEXTEDIT ||
1091 !bQuickDrag)
1093 pOLV->MouseButtonDown(rMEvt);
1094 pOLV->MouseMove(rMEvt);
1095 pOLV->MouseButtonUp(rMEvt);
1098 if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1100 pOLV->MouseButtonDown(rMEvt);
1103 else
1105 // Move cursor to end of text
1106 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1107 if (pOLV != NULL)
1108 pOLV->SetSelection(aNewSelection);
1111 else
1113 mpView->RestoreDefaultText(dynamic_cast< SdrTextObj* >( mxTextObj.get() ));
1119 else
1121 mxTextObj.reset(0);
1126 * Text entry is started, if necessary delete the default text.
1128 sal_Bool FuText::DeleteDefaultText()
1130 sal_Bool bDeleted = sal_False;
1132 if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() )
1134 SdPage* pPage = (SdPage*) mxTextObj->GetPage();
1136 if (pPage)
1138 PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1140 if ( (ePresObjKind == PRESOBJ_TITLE ||
1141 ePresObjKind == PRESOBJ_OUTLINE ||
1142 ePresObjKind == PRESOBJ_NOTES ||
1143 ePresObjKind == PRESOBJ_TEXT) &&
1144 !pPage->IsMasterPage() )
1146 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1147 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1148 sal_Bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1149 if( bIsUndoEnabled )
1150 pOutliner->EnableUndo(sal_False);
1152 pOutliner->SetText( String(), pOutliner->GetParagraph( 0 ) );
1154 if( bIsUndoEnabled )
1155 pOutliner->EnableUndo(sal_True);
1157 if (pSheet &&
1158 (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1159 pOutliner->SetStyleSheet(0, pSheet);
1161 mxTextObj->SetEmptyPresObj(sal_True);
1162 bDeleted = sal_True;
1167 return(bDeleted);
1170 sal_Bool FuText::Command(const CommandEvent& rCEvt)
1172 return( FuPoor::Command(rCEvt) );
1175 sal_Bool FuText::RequestHelp(const HelpEvent& rHEvt)
1177 sal_Bool bReturn = sal_False;
1179 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1181 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1182 mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1184 String aHelpText;
1185 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1186 const SvxFieldData* pField = pFieldItem->GetField();
1188 if (pField && pField->ISA(SvxURLField))
1190 // URL-Field
1191 aHelpText = INetURLObject::decode( ((const SvxURLField*)pField)->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1193 if (aHelpText.Len())
1195 Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1196 Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1197 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1199 if (Help::IsBalloonHelpEnabled())
1201 bReturn = Help::ShowBalloon( (Window*)mpWindow, rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1203 else if (Help::IsQuickHelpEnabled())
1205 bReturn = Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1210 if (!bReturn)
1212 bReturn = FuConstruct::RequestHelp(rHEvt);
1215 return(bReturn);
1218 void FuText::ReceiveRequest(SfxRequest& rReq)
1220 nSlotId = rReq.GetSlot();
1222 // then we call the base class (besides others, nSlotId is NOT set there)
1223 FuPoor::ReceiveRequest(rReq);
1225 if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId)
1227 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1229 mxTextObj.reset(0);
1231 if (nSlotId == SID_TEXTEDIT)
1233 // are we currently editing?
1234 if(!bTestText)
1235 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetTextEditObject() ) );
1237 if (!mxTextObj.is())
1239 // Try to select an object
1240 SdrPageView* pPV = mpView->GetSdrPageView();
1241 SdrViewEvent aVEvt;
1242 mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1243 mpView->MarkObj(aVEvt.pRootObj, pPV);
1245 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
1247 mxTextObj.reset( static_cast< SdrTextObj* >( aVEvt.pObj ) );
1251 else if (mpView->AreObjectsMarked())
1253 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1255 if (rMarkList.GetMarkCount() == 1)
1257 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1259 if (pObj->ISA(SdrTextObj))
1261 mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1266 sal_Bool bQuickDrag = sal_True;
1268 const SfxItemSet* pArgs = rReq.GetArgs();
1270 if (pArgs
1272 // test for type before using
1273 && SID_TEXTEDIT == nSlotId
1274 && SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
1276 && (sal_uInt16) ((SfxUInt16Item&) pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1278 // selection wit double click -> do not allow QuickDrag
1279 bQuickDrag = sal_False;
1282 SetInEditMode(aMEvt, bQuickDrag);
1286 void FuText::DoubleClick(const MouseEvent& )
1288 // Nothing to do
1291 /** Removed the insertion of default text and putting a new text
1292 object directly into edit mode.
1294 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
1297 SdrObject* pObj = SdrObjFactory::MakeNewObject(
1298 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
1299 0L, mpDoc);
1301 if(pObj)
1303 if(pObj->ISA(SdrTextObj))
1305 SdrTextObj* pText = (SdrTextObj*)pObj;
1306 pText->SetLogicRect(rRectangle);
1308 sal_Bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1309 pText->SetVerticalWriting(bVertical);
1311 ImpSetAttributesForNewTextObject(pText);
1313 if (nSlotId == SID_TEXT_FITTOSIZE)
1315 ImpSetAttributesFitToSize(pText);
1317 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1319 ImpSetAttributesFitToSizeVertical(pText);
1321 else
1323 ImpSetAttributesFitCommon(pText);
1326 // Put text object into edit mode.
1327 SdrPageView* pPV = mpView->GetSdrPageView();
1328 mpView->SdrBeginTextEdit(pText, pPV);
1330 else
1332 OSL_FAIL("Object is NO text object");
1336 return pObj;
1342 /** is called when the currenct function should be aborted. <p>
1343 This is used when a function gets a KEY_ESCAPE but can also
1344 be called directly.
1346 @returns true if a active function was aborted
1348 bool FuText::cancel()
1350 if ( mpView->IsTextEdit() )
1352 if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
1353 mxTextObj.reset(0);
1355 mpView->SetCurrentObj(OBJ_TEXT);
1356 mpView->SetEditMode(SDREDITMODE_EDIT);
1357 return true;
1359 else
1361 return false;
1365 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1367 if( !pFontList || !pView )
1368 return;
1370 if( pOLV )
1372 pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1374 else
1377 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1378 for( sal_uInt32 nMark = 0; nMark < rMarkList.GetMarkCount(); nMark++ )
1380 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1381 if( pTextObj )
1383 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1385 pTextObj->setActiveText( nText );
1387 // Put text object into edit mode.
1388 SdrPageView* pPV = pView->GetSdrPageView();
1389 pView->SdrBeginTextEdit(pTextObj, pPV);
1391 pOLV = pView->GetTextEditOutlinerView();
1392 if( pOLV )
1394 EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1395 if( pEditEngine )
1397 ESelection aSel;
1398 aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1399 aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1400 pOLV->SetSelection(aSel);
1403 ChangeFontSize( bGrow, pOLV, pFontList, pView );
1406 pView->SdrEndTextEdit();
1409 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1410 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1412 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1413 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1414 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1421 } // end of namespace sd
1423 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */