Update git submodules
[LibreOffice.git] / sd / source / ui / func / futext.cxx
blobf01851668f765cb92f6c85288686e80e61607681
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 <svx/sdrpagewindow.hxx>
23 #include <svx/sdrpaintwindow.hxx>
24 #include <tools/urlobj.hxx>
25 #include <vcl/help.hxx>
26 #include <editeng/fhgtitem.hxx>
27 #include <svl/intitem.hxx>
28 #include <svl/stritem.hxx>
29 #include <svx/svdotext.hxx>
30 #include <editeng/flditem.hxx>
31 #include <svl/style.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <svx/sdtmfitm.hxx>
34 #include <svx/sdtagitm.hxx>
35 #include <svx/sdtfsitm.hxx>
36 #include <sfx2/viewfrm.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/bindings.hxx>
39 #include <sfx2/request.hxx>
40 #include <editeng/editeng.hxx>
41 #include <svx/svdoutl.hxx>
42 #include <svx/svxids.hrc>
43 #include <svx/sdr/overlay/overlaymanager.hxx>
44 #include <sfx2/docfile.hxx>
45 #include <editeng/outlobj.hxx>
46 #include <osl/diagnose.h>
48 #include <editeng/frmdiritem.hxx>
50 #include <svx/svdetc.hxx>
51 #include <editeng/editview.hxx>
53 #include <sdresid.hxx>
54 #include <app.hrc>
56 #include <ViewShell.hxx>
57 #include <ViewShellBase.hxx>
58 #include <View.hxx>
59 #include <Window.hxx>
60 #include <drawdoc.hxx>
61 #include <sdpage.hxx>
62 #include <FrameView.hxx>
63 #include <ToolBarManager.hxx>
64 #include <DrawDocShell.hxx>
65 #include <strings.hrc>
66 #include <pres.hxx>
68 using namespace ::com::sun::star;
69 using namespace ::com::sun::star::uno;
70 using namespace ::com::sun::star::lang;
71 using namespace ::com::sun::star::linguistic2;
73 namespace sd {
75 const sal_uInt16 SidArray[] = {
76 SID_STYLE_FAMILY2, // 5542
77 SID_STYLE_FAMILY5, // 5545
78 SID_REDO, // 5700
79 SID_UNDO, // 5701
80 SID_CUT, // 5710
81 SID_COPY, // 5711
82 SID_ATTR_TABSTOP, // 10002
83 SID_ATTR_CHAR_FONT, // 10007
84 SID_ATTR_CHAR_POSTURE, // 10008
85 SID_ATTR_CHAR_WEIGHT, // 10009
86 SID_ATTR_CHAR_SHADOWED, // 10010
87 SID_ATTR_CHAR_STRIKEOUT, // 10013
88 SID_ATTR_CHAR_UNDERLINE, // 10014
89 SID_ATTR_CHAR_FONTHEIGHT, // 10015
90 SID_ATTR_CHAR_COLOR, // 10017
91 SID_ATTR_CHAR_KERNING, // 10018
92 SID_ATTR_CHAR_CASEMAP, // 10019
93 SID_ATTR_PARA_ADJUST_LEFT, // 10028
94 SID_ATTR_PARA_ADJUST_RIGHT, // 10029
95 SID_ATTR_PARA_ADJUST_CENTER, // 10030
96 SID_ATTR_PARA_ADJUST_BLOCK, // 10031
97 SID_ATTR_PARA_LINESPACE_10, // 10034
98 SID_ATTR_PARA_LINESPACE_15, // 10035
99 SID_ATTR_PARA_LINESPACE_20, // 10036
100 SID_ATTR_PARA_ULSPACE, // 10042
101 SID_ATTR_PARA_LRSPACE, // 10043
102 SID_ATTR_TRANSFORM_POS_X, // 10088
103 SID_ATTR_TRANSFORM_POS_Y, // 10089
104 SID_ATTR_TRANSFORM_WIDTH, // 10090
105 SID_ATTR_TRANSFORM_HEIGHT, // 10091
106 SID_ATTR_TRANSFORM_ROT_X, // 10093
107 SID_ATTR_TRANSFORM_ROT_Y, // 10094
108 SID_ATTR_TRANSFORM_ANGLE, // 10095 //Added
109 SID_OUTLINE_UP, // 10150
110 SID_OUTLINE_DOWN, // 10151
111 SID_OUTLINE_LEFT, // 10152
112 SID_OUTLINE_RIGHT, // 10153
113 SID_ATTR_TRANSFORM_PROTECT_POS, // 10236
114 SID_ATTR_TRANSFORM_PROTECT_SIZE, // 10237 //Added
115 SID_FORMTEXT_STYLE, // 10257
116 SID_SET_SUPER_SCRIPT, // 10294
117 SID_SET_SUB_SCRIPT, // 10295
118 SID_ATTR_TRANSFORM_AUTOWIDTH, // 10310
119 SID_ATTR_TRANSFORM_AUTOHEIGHT, // 10311 //Added
120 SID_HYPERLINK_GETLINK, // 10361
121 SID_DEC_INDENT, // 10461
122 SID_INC_INDENT, // 10462
123 SID_CHARMAP, // 10503
124 SID_TEXTDIRECTION_LEFT_TO_RIGHT, // 10907
125 SID_TEXTDIRECTION_TOP_TO_BOTTOM, // 10908
126 SID_ATTR_PARA_LEFT_TO_RIGHT, // 10950
127 SID_ATTR_PARA_RIGHT_TO_LEFT, // 10951
128 SID_PARASPACE_INCREASE, // 11145
129 SID_PARASPACE_DECREASE, // 11146
130 FN_NUM_BULLET_ON, // 20138
131 0 };
135 * base class for text functions
137 FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
138 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
139 , bFirstObjCreated(false)
140 , bJustEndedEdit(false)
141 , rRequest (rReq)
145 rtl::Reference<FuPoor> FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
147 rtl::Reference<FuPoor> xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
148 return xFunc;
151 void FuText::disposing()
153 if(mpView)
155 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
156 mxTextObj = nullptr;
158 // reset the RequestHandler of the used Outliner to the handler of the document
159 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
161 if (pOutliner)
162 pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
166 /*************************************************************************
168 |* Execute functionality of this class:
170 |* #71422: Start the functionality of this class in this method
171 |* and not in the ctor.
172 |* If you construct an object of this class and you put the
173 |* address of this object to pFuActual you've got a problem,
174 |* because some methods inside DoExecute use the pFuActual-Pointer.
175 |* If the code inside DoExecute is executed inside the ctor,
176 |* the value of pFuActual is not right. And the value will not
177 |* be right until the ctor finished !!!
179 \************************************************************************/
180 void FuText::DoExecute( SfxRequest& )
182 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
183 ToolBarManager::ToolBarGroup::Function,
184 ToolbarId::Draw_Text_Toolbox_Sd);
186 mpView->SetCurrentObj(SdrObjKind::Text);
187 mpView->SetEditMode(SdrViewEditMode::Edit);
189 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
191 if (nSlotId == SID_TEXTEDIT)
193 // Try to select an object
194 SdrPageView* pPV = mpView->GetSdrPageView();
195 SdrViewEvent aVEvt;
196 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
197 mpView->MarkObj(aVEvt.mpRootObj, pPV);
199 mxTextObj = DynCastSdrTextObj( aVEvt.mpObj );
201 else if (mpView->AreObjectsMarked())
203 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
205 if (rMarkList.GetMarkCount() == 1)
207 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
208 mxTextObj = DynCastSdrTextObj( pObj );
212 // check for table
213 if (mpView->AreObjectsMarked())
215 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
217 if (rMarkList.GetMarkCount() == 1)
219 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
220 if( pObj && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == SdrObjKind::Table) )
222 mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell(ToolBarManager::ToolBarGroup::Function, ToolbarId::Draw_Table_Toolbox);
227 bool bQuickDrag = true;
229 const SfxItemSet* pArgs = rRequest.GetArgs();
231 if (pArgs
233 // test for type before using
234 && SID_TEXTEDIT == nSlotId
235 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
237 && static_cast<const SfxUInt16Item&>(pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
239 // Selection by doubleclick -> don't allow QuickDrag
240 bQuickDrag = false;
243 SetInEditMode(aMEvt, bQuickDrag);
246 bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
248 bMBDown = true;
249 bJustEndedEdit = false;
251 bool bReturn = FuDraw::MouseButtonDown(rMEvt);
253 SdrViewEvent aVEvt;
254 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
256 // handle URL also during the text editing
257 if (rMEvt.GetClicks() == 1 && rMEvt.IsLeft() && rMEvt.IsMod1())
259 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
261 if (mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
263 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
264 if (pFieldItem)
266 const SvxFieldData* pField = pFieldItem->GetField();
268 if (auto pURLField = dynamic_cast< const SvxURLField *>( pField ))
270 eHit = SdrHitKind::MarkedObject;
271 aVEvt.meEvent = SdrEventKind::ExecuteUrl;
272 aVEvt.mpURLField = pURLField;
278 if (eHit == SdrHitKind::TextEdit)
280 // hit text -> SdrView handles event
281 if (mpView->MouseButtonDown(rMEvt, mpWindow->GetOutDev()))
282 return true;
285 if (rMEvt.GetClicks() == 1)
287 if (mpView->IsTextEdit() && eHit != SdrHitKind::MarkedObject && eHit != SdrHitKind::Handle)
289 // finish text input
290 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
292 /* Bugfix from MBA: during a double click onto the unused? area
293 in text mode, we get with the second click eHit =
294 SdrHitKind::TextEditObj since it goes to the TextObject which was
295 created with the first click. But this is removed by
296 SdrEndTextEdit since it is empty. But it is still in the mark
297 list. The call MarkObj further below accesses then the dead
298 object. As a simple fix, we determine eHit after
299 SdrEndTextEdit again, this returns then SdrHitKind::NONE. */
300 mxTextObj = nullptr;
301 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
304 mpView->SetCurrentObj(SdrObjKind::Text);
305 mpView->SetEditMode(SdrViewEditMode::Edit);
308 if (rMEvt.IsLeft() || rMEvt.IsRight())
310 mpWindow->CaptureMouse();
311 SdrPageView* pPV = mpView->GetSdrPageView();
313 if (eHit == SdrHitKind::TextEdit)
315 SetInEditMode(rMEvt, false);
317 else
319 // Don't remark table when clicking in it, mark change triggers a lot of updating
320 bool bMarkChanges = true;
321 rtl::Reference< sdr::SelectionController > xSelectionController(mpView->getSelectionController());
322 if (eHit == SdrHitKind::TextEditObj && xSelectionController.is())
324 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
325 if (rMarkList.GetMarkCount() == 1 && rMarkList.GetMark(0)->GetMarkedSdrObj() == aVEvt.mpRootObj)
326 bMarkChanges = false;
329 if (eHit != SdrHitKind::Handle)
331 // deselect selection
332 if (!rMEvt.IsShift() && eHit == SdrHitKind::TextEditObj)
334 if(bMarkChanges)
336 mpView->UnmarkAll();
337 mpView->SetDragMode(SdrDragMode::Move);
342 if ( aVEvt.meEvent == SdrEventKind::ExecuteUrl ||
343 eHit == SdrHitKind::Handle ||
344 eHit == SdrHitKind::MarkedObject ||
345 eHit == SdrHitKind::TextEditObj ||
346 ( eHit == SdrHitKind::UnmarkedObject && bFirstObjCreated &&
347 !bPermanent ) )
349 // Handle, hit marked or unmarked object
350 if (eHit == SdrHitKind::TextEditObj)
352 /* hit text of unmarked object:
353 select object and set to EditMode */
354 if (bMarkChanges)
355 mpView->MarkObj(aVEvt.mpRootObj, pPV);
357 if (auto pSdrTextObj = DynCastSdrTextObj(aVEvt.mpObj))
359 mxTextObj = pSdrTextObj;
362 SetInEditMode(rMEvt, true);
364 else if (aVEvt.meEvent == SdrEventKind::ExecuteUrl && !rMEvt.IsMod2())
366 // execute URL
367 mpWindow->ReleaseMouse();
369 if (aVEvt.mpURLField)
371 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.mpURLField->GetURL());
372 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
373 SfxBoolItem aBrowseItem( SID_BROWSE, true );
374 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
376 if (rMEvt.IsMod1())
378 // open in new frame
379 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
380 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
381 { &aStrItem, &aBrowseItem, &aReferer });
383 else
385 // open in current frame
386 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
387 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
388 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
389 { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
393 else
395 // drag object or handle
397 // #i78748#
398 // do the EndTextEdit first, it will delete the handles and force a
399 // recreation. This will make aVEvt.mpHdl to point to a deleted handle,
400 // thus it is necessary to reset it and to get it again.
402 // #i112855#
403 // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObject
404 // this caused SdrEndTextEdit() to be called also when not in text editing and
405 // this does not make sense and caused troubles. (see issue 112855)
407 if( mpView->IsTextEdit() )
409 mpView->SdrEndTextEdit();
410 bJustEndedEdit = true;
412 if(aVEvt.mpHdl)
414 // force new handle identification, the pointer will be dead here
415 // since SdrEndTextEdit has reset (deleted) the handles.
416 aVEvt.mpHdl = nullptr;
417 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
421 if (!aVEvt.mpHdl)
423 if( eHit == SdrHitKind::UnmarkedObject )
425 if ( !rMEvt.IsShift() )
426 mpView->UnmarkAll();
428 mpView->MarkObj(aVEvt.mpRootObj, pPV);
431 // Drag object
432 bFirstMouseMove = true;
433 aDragTimer.Start();
436 if ( ! rMEvt.IsRight())
438 // we need to pick again since SdrEndTextEdit can rebuild the handles list
439 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
440 if( (eHit == SdrHitKind::Handle) || (eHit == SdrHitKind::MarkedObject) )
442 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
443 mpView->BegDragObj(aMDPos, nullptr, aVEvt.mpHdl, nDrgLog);
446 bReturn = true;
449 else if ( nSlotId != SID_TEXTEDIT &&
450 (bPermanent || !bFirstObjCreated) )
452 // create object
453 mpView->SetCurrentObj(SdrObjKind::Text);
454 mpView->SetEditMode(SdrViewEditMode::Create);
455 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
456 mpView->BegCreateObj(aMDPos, nullptr, nDrgLog);
458 else
460 // select
461 if( !rMEvt.IsShift() )
462 mpView->UnmarkAll();
464 mpView->BegMarkObj( aMDPos );
469 else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
471 MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
472 SetInEditMode( aMEvt, false );
475 if (!bIsInDragMode)
477 ForcePointer(&rMEvt);
478 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
481 return bReturn;
484 bool FuText::MouseMove(const MouseEvent& rMEvt)
486 bool bReturn = FuDraw::MouseMove(rMEvt);
488 if (aDragTimer.IsActive() )
490 if( bFirstMouseMove )
491 bFirstMouseMove = false;
492 else
493 aDragTimer.Stop();
496 if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
498 Point aPix(rMEvt.GetPosPixel());
499 Point aPnt(mpWindow->PixelToLogic(aPix));
501 ForceScroll(aPix);
502 mpView->MovAction(aPnt);
505 ForcePointer(&rMEvt);
507 return bReturn;
510 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
512 if( nSlotId == SID_ATTR_CHAR )
514 SfxItemSet aSet(mpViewShell->GetPool());
515 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
516 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
517 pTxtObj->SetMergedItemSet(aSet);
518 pTxtObj->AdjustTextFrameWidthAndHeight();
519 const SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
520 if (pCurrentViewShell && (pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet()))
521 pTxtObj->SetText(SdResId(STR_PRESOBJ_TEXT_EDIT_MOBILE));
523 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
525 // draw text object, needs to be initialized when vertical text is used
526 SfxItemSet aSet(mpViewShell->GetPool());
528 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
529 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
531 // Set defaults for vertical click-n'drag text object, pool defaults are:
532 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
533 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
534 // Analog to that:
535 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
536 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
538 pTxtObj->SetMergedItemSet(aSet);
539 pTxtObj->AdjustTextFrameWidthAndHeight();
543 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
545 // FitToSize (fit to frame)
546 SfxItemSetFixed<SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH> aSet(mpViewShell->GetPool());
547 aSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL));
548 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
549 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
550 pTxtObj->SetMergedItemSet(aSet);
551 pTxtObj->AdjustTextFrameWidthAndHeight();
554 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
556 SfxItemSetFixed<SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH> aSet(mpViewShell->GetPool());
557 aSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL));
558 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
559 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
560 pTxtObj->SetMergedItemSet(aSet);
561 pTxtObj->AdjustTextFrameWidthAndHeight();
564 bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
566 bool bReturn = false;
567 if (aDragTimer.IsActive())
569 aDragTimer.Stop();
570 bIsInDragMode = false;
573 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
575 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
577 if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow->GetOutDev())) || rMEvt.GetClicks() == 2 )
578 return true; // handle event from SdrView
580 bool bEmptyTextObj = false;
582 if (mxTextObj.get().is())
584 bool bReset = true;
586 if (mpView)
588 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
590 if (rMarkList.GetMarkCount() == 1
591 && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get().get()) )
593 if( mxTextObj.get().is() && !GetTextObj()->GetOutlinerParaObject() )
594 bEmptyTextObj = true;
595 else
596 bFirstObjCreated = true;
597 bReset = false;
601 if (bReset)
603 mxTextObj = nullptr;
607 if( mpView && mpView->IsDragObj())
609 // object was moved
610 FrameView* pFrameView = mpViewShell->GetFrameView();
611 bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
613 if (bDragWithCopy)
615 bDragWithCopy = !mpView->IsPresObjSelected(false);
618 mpView->SetDragWithCopy(bDragWithCopy);
619 mpView->EndDragObj( mpView->IsDragWithCopy() );
620 mpView->ForceMarkedToAnotherPage();
621 mpView->SetCurrentObj(SdrObjKind::Text);
623 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
625 if (bJustEndedEdit)
627 bJustEndedEdit = false;
628 FuPoor::cancel();
630 if ((rMEvt.GetClicks() != 2) &&
631 !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
632 std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
633 std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
635 /*************************************************************
636 * From text mode, you don't want to rotate immediately.
637 **************************************************************/
638 SdrPageView* pPV;
639 SdrObject* pObj = mpView->PickObj(aMDPos, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK);
640 if (pObj && pPV->IsObjMarkable(pObj))
642 mpView->UnmarkAllObj();
643 mpView->MarkObj(pObj,pPV);
644 return bReturn;
648 else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
650 // object was created
651 rtl::Reference<SdrTextObj> pTextObj = DynCastSdrTextObj( mpView->GetCreateObj() );
652 mxTextObj = pTextObj.get();
654 if( pTextObj )
656 //AW outliner needs to be set to vertical when there is no
657 // outliner object up to now; also it needs to be set back to not
658 // vertical when there was a vertical one used last time.
659 OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
660 SdrOutliner& rOutl(pTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj()));
661 bool bVertical((pOPO && pOPO->IsEffectivelyVertical())
662 || nSlotId == SID_ATTR_CHAR_VERTICAL
663 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
664 rOutl.SetVertical(bVertical);
666 // Before ImpSetAttributesForNewTextObject the vertical writing mode
667 // needs to be set at the object. This is done here at the OutlinerParaObject
668 // directly to not mirror the layout text items involved. These items will be set
669 // from ImpSetAttributesForNewTextObject and below.
670 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
672 if(!pPara)
674 GetTextObj()->ForceOutlinerParaObject();
675 pPara = GetTextObj()->GetOutlinerParaObject();
678 if(pPara && bVertical != pPara->IsEffectivelyVertical())
680 // set ParaObject orientation accordingly
681 pPara->SetVertical(bVertical);
684 ImpSetAttributesForNewTextObject(GetTextObj());
687 if (!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
689 // it was not possible to create text object
690 mxTextObj = nullptr;
691 pTextObj = nullptr;
693 else if (nSlotId == SID_TEXT_FITTOSIZE)
695 ImpSetAttributesFitToSize(GetTextObj());
697 SetInEditMode(rMEvt, false);
699 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
701 ImpSetAttributesFitToSizeVertical(GetTextObj());
703 SetInEditMode(rMEvt, false);
705 else
707 // thereby the handles and the gray frame are correct
708 mpView->AdjustMarkHdl();
709 mpView->PickHandle(aPnt);
710 SetInEditMode(rMEvt, false);
713 else if ( mpView && mpView->IsAction())
715 mpView->EndAction();
718 ForcePointer(&rMEvt);
719 mpWindow->ReleaseMouse();
720 sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
722 if ( mpView && !mpView->AreObjectsMarked() &&
723 std::abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
724 std::abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
725 !rMEvt.IsShift() && !rMEvt.IsMod2() )
727 SdrPageView* pPV2 = mpView->GetSdrPageView();
728 SdrViewEvent aVEvt;
729 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
730 mpView->MarkObj(aVEvt.mpRootObj, pPV2);
733 if ( !mxTextObj.get().is() && mpView )
735 if ( ( (!bEmptyTextObj && bPermanent) ||
736 (!bFirstObjCreated && !bPermanent) ) &&
737 !mpDocSh->IsReadOnly() &&
738 nSlotId != SID_TEXTEDIT )
740 // text body (left-justified AutoGrow)
741 mpView->SetCurrentObj(SdrObjKind::Text);
742 mpView->SetEditMode(SdrViewEditMode::Create);
743 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
744 mpView->BegCreateObj(aMDPos, nullptr, nDrgLog);
746 bool bSnapEnabled = mpView->IsSnapEnabled();
748 if (bSnapEnabled)
749 mpView->SetSnapEnabled(false);
751 aPnt.AdjustX(nDrgLog + nDrgLog );
752 aPnt.AdjustY(nDrgLog + nDrgLog );
753 mpView->MovAction(aPnt);
755 mxTextObj = DynCastSdrTextObj( mpView->GetCreateObj() );
757 if(mxTextObj.get().is())
759 GetTextObj()->SetDisableAutoWidthOnDragging(true);
762 if(!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
764 mxTextObj.clear();
767 if(bSnapEnabled)
768 mpView->SetSnapEnabled(bSnapEnabled);
770 if(mxTextObj.get().is())
772 SfxItemSet aSet(mpViewShell->GetPool());
773 aSet.Put(makeSdrTextMinFrameHeightItem(0));
774 aSet.Put(makeSdrTextMinFrameWidthItem(0));
775 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
776 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
778 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
780 // Here, all items which need to be different from pool default need to be set
781 // again on the newly created text object.
782 // Since this is a simple click text object, it is first created, then SetVertical()
783 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
784 // deleted again since not the minimum drag distance was travelled. Then, a new
785 // click text object is created and thus all that stuff needs to be set again here.
787 // Before using the new object the vertical writing mode
788 // needs to be set. This is done here at the OutlinerParaObject
789 // directly to not mirror the layout text items involved. These items will be set
790 // below.
791 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
793 if(!pPara)
795 GetTextObj()->ForceOutlinerParaObject();
796 pPara = GetTextObj()->GetOutlinerParaObject();
799 if(pPara && !pPara->IsEffectivelyVertical())
801 // set ParaObject orientation accordingly
802 pPara->SetVertical(true);
805 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
807 // Analog to the else case below, for vertical simple click texts
808 // one of the default set items from ImpSetAttributesForNewTextObject
809 // needs to be adapted to non-block mode.
810 const SfxItemSet& rSet = mpView->GetDefaultAttr();
811 SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
813 if(SvxFrameDirection::Horizontal_RL_TB == eDirection || SvxFrameDirection::Vertical_RL_TB == eDirection)
815 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
817 else
819 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
822 else
824 // This is for Format/Page settings. Since this also leads
825 // to the object defaults to be changed, i think this code can be
826 // removed. CL. wanted to take a look before adding this.
828 // Look in the object defaults if left-to-right is wanted. If
829 // yes, set text anchoring to right to let the box grow to left.
830 const SfxItemSet& rSet = mpView->GetDefaultAttr();
831 SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
833 if(SvxFrameDirection::Horizontal_RL_TB == eDirection)
835 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
837 else
839 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
843 GetTextObj()->SetMergedItemSet(aSet);
844 GetTextObj()->SetDisableAutoWidthOnDragging(true);
845 SetInEditMode(rMEvt, false);
848 bFirstObjCreated = true;
850 else
852 // switch to selection
853 if (mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
855 mxTextObj = nullptr;
858 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
859 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
862 if (bJustEndedEdit)
864 bJustEndedEdit = false;
865 FuPoor::cancel();
867 bMBDown = false;
868 FuConstruct::MouseButtonUp(rMEvt);
869 return bReturn;
873 * handle keyboard events
874 * @returns sal_True if the event was handled, sal_False otherwise
876 bool FuText::KeyInput(const KeyEvent& rKEvt)
878 bool bReturn = false;
880 vcl::KeyCode nCode = rKEvt.GetKeyCode();
881 bool bShift = nCode.IsShift();
883 if(mxTextObj.get().is())
885 // maybe object is deleted, test if it's equal to the selected object
886 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
887 SdrObject* pSelectedObj = nullptr;
889 if(1 == rMarkList.GetMarkCount())
891 SdrMark* pMark = rMarkList.GetMark(0);
892 pSelectedObj = pMark->GetMarkedSdrObj();
895 if(mxTextObj.get().get() != pSelectedObj)
897 mxTextObj = nullptr;
901 if (auto pTextObj = mxTextObj.get())
902 if ( pTextObj->GetObjInventor() == SdrInventor::Default && pTextObj->GetObjIdentifier() == SdrObjKind::TitleText && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
904 // title text object: always soft breaks
905 bShift = true;
908 sal_uInt16 nKey = nCode.GetCode();
909 vcl::KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
910 KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
912 bool bOK = true;
914 if (mpDocSh->IsReadOnly())
916 bOK = !EditEngine::DoesKeyChangeText(aKEvt);
918 if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
920 bOK = false; // default handling in base class
923 if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
925 bReturn = true;
927 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
930 else if (aKeyCode == KEY_ESCAPE)
932 bReturn = cancel();
935 if( bPermanent )
937 mpView->SetCurrentObj(SdrObjKind::Text);
938 mpView->SetEditMode(SdrViewEditMode::Create);
941 if (!bReturn)
943 bReturn = FuDraw::KeyInput(aKEvt);
946 return bReturn;
949 void FuText::Activate()
951 mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
953 // #i89661# it's no longer necessary to make it so big here, it's fine tuned
954 // for text objects in SdrMarkView::CheckSingleSdrObjectHit
955 mpView->SetHitTolerancePixel( 2 * HITPIX );
957 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
959 if (pOLV)
960 pOLV->ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
962 FuConstruct::Activate();
964 if( pOLV )
965 mpView->SetEditMode(SdrViewEditMode::Edit);
968 void FuText::Deactivate()
970 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
972 if (pOLV)
973 pOLV->HideCursor(/*bDeactivate=*/true);
975 mpView->SetHitTolerancePixel( HITPIX );
977 FuConstruct::Deactivate();
981 * Sets the object into the edit mode.
983 void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
985 SdrPageView* pPV = mpView->GetSdrPageView();
986 if( mxTextObj.get().is() && (mxTextObj.get()->getSdrPageFromSdrObject() == pPV->GetPage()) )
988 mpView->SetCurrentObj(SdrObjKind::Text);
990 if( bPermanent )
991 mpView->SetEditMode(SdrViewEditMode::Create);
992 else
993 mpView->SetEditMode(SdrViewEditMode::Edit);
995 bool bEmptyOutliner = false;
997 if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
999 ::Outliner* pOutl = mpView->GetTextEditOutliner();
1000 sal_Int32 nParagraphCnt = pOutl->GetParagraphCount();
1001 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1003 if (nParagraphCnt==1 && p1stPara)
1005 // with only one paragraph
1006 if (pOutl->GetText(p1stPara).isEmpty())
1008 bEmptyOutliner = true;
1013 if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1015 rtl::Reference<SdrTextObj> pTextObj = mxTextObj.get();
1016 SdrInventor nInv = pTextObj->GetObjInventor();
1017 SdrObjKind nSdrObjKind = pTextObj->GetObjIdentifier();
1019 if (nInv == SdrInventor::Default && GetTextObj()->HasTextEdit() &&
1020 (nSdrObjKind == SdrObjKind::Text ||
1021 nSdrObjKind == SdrObjKind::TitleText ||
1022 nSdrObjKind == SdrObjKind::OutlineText || !pTextObj->IsEmptyPresObj() ) )
1024 // create new outliner (owned by SdrObjEditView)
1025 std::unique_ptr<SdrOutliner> pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
1027 if (bEmptyOutliner)
1028 mpView->SdrEndTextEdit(true);
1030 pTextObj = GetTextObj();
1031 if( pTextObj )
1033 OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1034 if( pOPO && pOPO->IsEffectivelyVertical() )
1036 pOutl->SetVertical(pOPO->GetVertical());
1037 pOutl->SetRotation(pOPO->GetRotation());
1039 else if (nSlotId == SID_ATTR_CHAR_VERTICAL || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL)
1040 pOutl->SetVertical( true );
1042 if( pTextObj->getTextCount() > 1 )
1044 Point aPix(rMEvt.GetPosPixel());
1045 Point aPnt(mpWindow->PixelToLogic(aPix));
1046 pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1049 if (mpView->SdrBeginTextEdit(pTextObj.get(), pPV, mpWindow, true, pOutl.release()) && mxTextObj.get()->GetObjInventor() == SdrInventor::Default)
1051 //tdf#102293 flush overlay before going on to pass clicks down to
1052 //the outline view which will want to paint selections
1053 for (sal_uInt32 b = 0; b < pPV->PageWindowCount(); ++b)
1055 const SdrPageWindow& rPageWindow = *pPV->GetPageWindow(b);
1056 if (!rPageWindow.GetPaintWindow().OutputToWindow())
1057 continue;
1058 const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager();
1059 if (!xManager.is())
1060 continue;
1061 xManager->flush();
1064 bFirstObjCreated = true;
1065 DeleteDefaultText();
1067 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1069 nSdrObjKind = mxTextObj.get()->GetObjIdentifier();
1071 SdrViewEvent aVEvt;
1072 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1074 if (eHit == SdrHitKind::TextEdit)
1076 // hit text
1077 if (nSdrObjKind == SdrObjKind::Text ||
1078 nSdrObjKind == SdrObjKind::TitleText ||
1079 nSdrObjKind == SdrObjKind::OutlineText ||
1080 nSdrObjKind == SdrObjKind::Table ||
1081 nSlotId == SID_TEXTEDIT ||
1082 !bQuickDrag)
1084 pOLV->MouseButtonDown(rMEvt);
1085 pOLV->MouseMove(rMEvt);
1086 pOLV->MouseButtonUp(rMEvt);
1089 if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1091 pOLV->MouseButtonDown(rMEvt);
1094 else
1096 // Move cursor to end of text
1097 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1098 if (pOLV != nullptr)
1099 pOLV->SetSelection(aNewSelection);
1102 else
1104 mpView->RestoreDefaultText( mxTextObj.get().get() );
1110 else
1112 mxTextObj = nullptr;
1117 * Text entry is started, if necessary delete the default text.
1119 void FuText::DeleteDefaultText()
1121 if ( !(mxTextObj.get().is() && mxTextObj.get()->IsEmptyPresObj()) )
1122 return;
1124 SdPage* pPage = static_cast<SdPage*>( mxTextObj.get()->getSdrPageFromSdrObject() );
1126 if (!pPage)
1127 return;
1129 PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get().get());
1131 if ( !(ePresObjKind == PresObjKind::Title ||
1132 ePresObjKind == PresObjKind::Outline ||
1133 ePresObjKind == PresObjKind::Notes ||
1134 ePresObjKind == PresObjKind::Text ) ||
1135 pPage->IsMasterPage() )
1136 return;
1138 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1139 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1140 bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1141 if( bIsUndoEnabled )
1142 pOutliner->EnableUndo(false);
1144 pOutliner->SetText( OUString(), pOutliner->GetParagraph( 0 ) );
1146 if( bIsUndoEnabled )
1147 pOutliner->EnableUndo(true);
1149 if (pSheet &&
1150 (ePresObjKind == PresObjKind::Notes || ePresObjKind == PresObjKind::Text))
1151 pOutliner->SetStyleSheet(0, pSheet);
1153 mxTextObj.get()->SetEmptyPresObj(true);
1156 bool FuText::RequestHelp(const HelpEvent& rHEvt)
1158 bool bReturn = false;
1160 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1162 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1163 mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
1165 OUString aHelpText;
1166 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1167 const SvxFieldData* pField = pFieldItem->GetField();
1169 if (auto pURLField = dynamic_cast< const SvxURLField *>( pField ))
1171 // URL-Field
1172 aHelpText = INetURLObject::decode( pURLField->GetURL(), INetURLObject::DecodeMechanism::WithCharset );
1174 if (!aHelpText.isEmpty())
1176 ::tools::Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj.get()->GetLogicRect());
1177 ::tools::Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1178 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1180 if (Help::IsBalloonHelpEnabled())
1182 Help::ShowBalloon( static_cast<vcl::Window*>(mpWindow), rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1183 bReturn = true;
1185 else if (Help::IsQuickHelpEnabled())
1187 Help::ShowQuickHelp( static_cast<vcl::Window*>(mpWindow), aScreenRect, aHelpText);
1188 bReturn = true;
1193 if (!bReturn)
1195 bReturn = FuConstruct::RequestHelp(rHEvt);
1198 return bReturn;
1201 void FuText::ReceiveRequest(SfxRequest& rReq)
1203 nSlotId = rReq.GetSlot();
1205 // then we call the base class (besides others, nSlotId is NOT set there)
1206 FuPoor::ReceiveRequest(rReq);
1208 if (!(nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId))
1209 return;
1211 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1213 mxTextObj = nullptr;
1215 if (nSlotId == SID_TEXTEDIT)
1217 // are we currently editing?
1218 mxTextObj = mpView->GetTextEditObject();
1220 if (!mxTextObj.get().is())
1222 // Try to select an object
1223 SdrPageView* pPV = mpView->GetSdrPageView();
1224 SdrViewEvent aVEvt;
1225 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1226 mpView->MarkObj(aVEvt.mpRootObj, pPV);
1228 if (auto pSdrTextObj = DynCastSdrTextObj(aVEvt.mpObj))
1230 mxTextObj = pSdrTextObj;
1234 else if (mpView->AreObjectsMarked())
1236 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1238 if (rMarkList.GetMarkCount() == 1)
1240 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1242 if( auto pTextObj = DynCastSdrTextObj( pObj ))
1244 mxTextObj = pTextObj;
1249 bool bQuickDrag = true;
1251 const SfxItemSet* pArgs = rReq.GetArgs();
1253 if (pArgs
1255 // test for type before using
1256 && SID_TEXTEDIT == nSlotId
1257 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
1259 && static_cast<const SfxUInt16Item&>( pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1261 // selection with double click -> do not allow QuickDrag
1262 bQuickDrag = false;
1265 SetInEditMode(aMEvt, bQuickDrag);
1268 void FuText::DoubleClick(const MouseEvent& )
1270 // Nothing to do
1273 /** Removed the insertion of default text and putting a new text
1274 object directly into edit mode.
1276 rtl::Reference<SdrObject> FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
1278 rtl::Reference<SdrObject> pObj( SdrObjFactory::MakeNewObject(
1279 mpView->getSdrModelFromSdrView(),
1280 mpView->GetCurrentObjInventor(),
1281 mpView->GetCurrentObjIdentifier(),
1282 nullptr) );
1284 if(pObj)
1286 if( auto pText = DynCastSdrTextObj( pObj.get() ) )
1288 pText->SetLogicRect(rRectangle);
1290 bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1291 pText->SetVerticalWriting(bVertical);
1293 ImpSetAttributesForNewTextObject(pText);
1295 if (nSlotId == SID_TEXT_FITTOSIZE)
1297 ImpSetAttributesFitToSize(pText);
1299 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1301 ImpSetAttributesFitToSizeVertical(pText);
1304 // Put text object into edit mode.
1305 SdrPageView* pPV = mpView->GetSdrPageView();
1306 mpView->SdrBeginTextEdit(pText, pPV);
1308 else
1310 OSL_FAIL("Object is NO text object");
1314 return pObj;
1317 /** is called when the current function should be aborted. <p>
1318 This is used when a function gets a KEY_ESCAPE but can also
1319 be called directly.
1321 @returns true if an active function was aborted
1323 bool FuText::cancel()
1325 if ( mpView->IsTextEdit() )
1327 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
1328 mxTextObj = nullptr;
1330 mpView->SetCurrentObj(SdrObjKind::Text);
1331 mpView->SetEditMode(SdrViewEditMode::Edit);
1332 return true;
1334 else
1336 return false;
1340 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1342 if( !pFontList || !pView )
1343 return;
1345 if( pOLV )
1347 pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1349 else
1352 pView->BegUndo(SdResId(bGrow ? STR_GROW_FONT_SIZE : STR_SHRINK_FONT_SIZE));
1353 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1354 for( size_t nMark = 0; nMark < rMarkList.GetMarkCount(); ++nMark )
1356 SdrTextObj* pTextObj = DynCastSdrTextObj( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1357 if( pTextObj )
1359 rtl::Reference<sdr::SelectionController> xSelectionController(pView->getSelectionController());
1360 if (xSelectionController.is() && xSelectionController->ChangeFontSize(bGrow, pFontList))
1362 continue;
1364 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1366 pTextObj->setActiveText( nText );
1368 // Put text object into edit mode.
1369 SdrPageView* pPV = pView->GetSdrPageView();
1370 pView->SdrBeginTextEdit(pTextObj, pPV);
1372 pOLV = pView->GetTextEditOutlinerView();
1373 if( pOLV )
1375 EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1376 if( pEditEngine )
1378 ESelection aSel;
1379 aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1380 aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1381 pOLV->SetSelection(aSel);
1384 ChangeFontSize( bGrow, pOLV, pFontList, pView );
1387 pView->SdrEndTextEdit();
1390 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1391 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1393 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1394 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1395 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1399 pView->EndUndo();
1403 void FuText::InvalidateBindings()
1405 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
1409 } // end of namespace sd
1411 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */