bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / futext.cxx
blob9c02439fadb59a89ffd760a8757d29b3dda1612d
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/debug.hxx>
25 #include <tools/urlobj.hxx>
26 #include <vcl/help.hxx>
27 #include <editeng/fhgtitem.hxx>
28 #include <svl/intitem.hxx>
29 #include <svl/stritem.hxx>
30 #include <svx/svdotext.hxx>
31 #include <editeng/flditem.hxx>
32 #include <svl/style.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <svx/sdtmfitm.hxx>
35 #include <svx/sdtagitm.hxx>
36 #include <svx/sdtfsitm.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/request.hxx>
41 #include <editeng/editeng.hxx>
42 #include <svx/svdoutl.hxx>
43 #include <svx/svxids.hrc>
44 #include <svx/sdr/overlay/overlaymanager.hxx>
45 #include <sfx2/docfile.hxx>
46 #include <editeng/outlobj.hxx>
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 static 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.reset(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(OBJ_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.pRootObj, pPV);
199 mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
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.reset( dynamic_cast< SdrTextObj* >( 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() == OBJ_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 if (eHit == SdrHitKind::TextEdit)
258 // hit text -> SdrView handles event
259 if (mpView->MouseButtonDown(rMEvt, mpWindow))
260 return true;
263 if (rMEvt.GetClicks() == 1)
265 if (mpView->IsTextEdit() && eHit != SdrHitKind::MarkedObject && eHit != SdrHitKind::Handle)
267 // finish text input
268 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
270 /* Bugfix from MBA: during a double click onto the unused? area
271 in text mode, we get with the second click eHit =
272 SdrHitKind::TextEditObj since it goes to the TextObject which was
273 created with the first click. But this is removed by
274 SdrEndTextEdit since it is empty. But it is still in the mark
275 list. The call MarkObj further below accesses then the dead
276 object. As a simple fix, we determine eHit after
277 SdrEndTextEdit again, this returns then SdrHitKind::NONE. */
278 mxTextObj.reset(nullptr);
279 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
282 mpView->SetCurrentObj(OBJ_TEXT);
283 mpView->SetEditMode(SdrViewEditMode::Edit);
286 if (rMEvt.IsLeft() || rMEvt.IsRight())
288 mpWindow->CaptureMouse();
289 SdrPageView* pPV = mpView->GetSdrPageView();
291 if (eHit == SdrHitKind::TextEdit)
293 SetInEditMode(rMEvt, false);
295 else
297 // Don't remark table when clicking in it, mark change triggers a lot of updating
298 bool bMarkChanges = true;
299 rtl::Reference< sdr::SelectionController > xSelectionController(mpView->getSelectionController());
300 if (eHit == SdrHitKind::TextEditObj && xSelectionController.is())
302 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
303 if (rMarkList.GetMarkCount() == 1 && rMarkList.GetMark(0)->GetMarkedSdrObj() == aVEvt.pRootObj)
304 bMarkChanges = false;
307 if (eHit != SdrHitKind::Handle)
309 // deselect selection
310 if (!rMEvt.IsShift() && eHit == SdrHitKind::TextEditObj)
312 if(bMarkChanges)
314 mpView->UnmarkAll();
315 mpView->SetDragMode(SdrDragMode::Move);
320 if ( aVEvt.eEvent == SdrEventKind::ExecuteUrl ||
321 eHit == SdrHitKind::Handle ||
322 eHit == SdrHitKind::MarkedObject ||
323 eHit == SdrHitKind::TextEditObj ||
324 ( eHit == SdrHitKind::UnmarkedObject && bFirstObjCreated &&
325 !bPermanent ) )
327 // Handle, hit marked or unmarked object
328 if (eHit == SdrHitKind::TextEditObj)
330 /* hit text of unmarked object:
331 select object and set to EditMode */
332 if (bMarkChanges)
333 mpView->MarkObj(aVEvt.pRootObj, pPV);
335 if (auto pSdrTextObj = dynamic_cast<SdrTextObj *>( aVEvt.pObj ))
337 mxTextObj.reset( pSdrTextObj );
340 SetInEditMode(rMEvt, true);
342 else if (aVEvt.eEvent == SdrEventKind::ExecuteUrl && !rMEvt.IsMod2())
344 // execute URL
345 mpWindow->ReleaseMouse();
346 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
347 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
348 SfxBoolItem aBrowseItem( SID_BROWSE, true );
349 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
350 mpWindow->ReleaseMouse();
352 if (rMEvt.IsMod1())
354 // open in new frame
355 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
356 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
357 { &aStrItem, &aBrowseItem, &aReferer });
359 else
361 // open in current frame
362 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
363 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
364 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
365 { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
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->GetOutlinerParaObject
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 reset (deleted) the handles.
391 aVEvt.pHdl = nullptr;
392 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
396 if (!aVEvt.pHdl)
398 if( eHit == SdrHitKind::UnmarkedObject )
400 if ( !rMEvt.IsShift() )
401 mpView->UnmarkAll();
403 mpView->MarkObj(aVEvt.pRootObj, pPV);
406 // Drag object
407 bFirstMouseMove = true;
408 aDragTimer.Start();
411 if ( ! rMEvt.IsRight())
413 // we need to pick again since SdrEndTextEdit can rebuild the handles list
414 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
415 if( (eHit == SdrHitKind::Handle) || (eHit == SdrHitKind::MarkedObject) )
417 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
418 mpView->BegDragObj(aMDPos, nullptr, aVEvt.pHdl, nDrgLog);
421 bReturn = true;
424 else if ( nSlotId != SID_TEXTEDIT &&
425 (bPermanent || !bFirstObjCreated) )
427 // create object
428 mpView->SetCurrentObj(OBJ_TEXT);
429 mpView->SetEditMode(SdrViewEditMode::Create);
430 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
431 mpView->BegCreateObj(aMDPos, nullptr, nDrgLog);
433 else
435 // select
436 if( !rMEvt.IsShift() )
437 mpView->UnmarkAll();
439 mpView->BegMarkObj( aMDPos );
444 else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
446 MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
447 SetInEditMode( aMEvt, false );
450 if (!bIsInDragMode)
452 ForcePointer(&rMEvt);
453 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
456 return bReturn;
459 bool FuText::MouseMove(const MouseEvent& rMEvt)
461 bool bReturn = FuDraw::MouseMove(rMEvt);
463 if (aDragTimer.IsActive() )
465 if( bFirstMouseMove )
466 bFirstMouseMove = false;
467 else
468 aDragTimer.Stop();
471 if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
473 Point aPix(rMEvt.GetPosPixel());
474 Point aPnt(mpWindow->PixelToLogic(aPix));
476 ForceScroll(aPix);
477 mpView->MovAction(aPnt);
480 ForcePointer(&rMEvt);
482 return bReturn;
485 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
487 if(mpDoc->GetDocumentType() == DocumentType::Impress)
489 if( nSlotId == SID_ATTR_CHAR )
491 /* Create Impress text object (rescales to line height)
492 We get the correct height during the subsequent creation of the
493 object, otherwise we draw to much */
494 SfxItemSet aSet(mpViewShell->GetPool());
495 aSet.Put(makeSdrTextMinFrameHeightItem(0));
496 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
497 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
498 pTxtObj->SetMergedItemSet(aSet);
499 pTxtObj->AdjustTextFrameWidthAndHeight();
500 aSet.Put(makeSdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
501 pTxtObj->SetMergedItemSet(aSet);
503 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
505 SfxItemSet aSet(mpViewShell->GetPool());
506 aSet.Put(makeSdrTextMinFrameWidthItem(0));
507 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
508 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
510 // Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
511 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
512 pTxtObj->SetMergedItemSet(aSet);
513 pTxtObj->AdjustTextFrameWidthAndHeight();
514 aSet.Put(makeSdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
515 pTxtObj->SetMergedItemSet(aSet);
518 else
520 if( nSlotId == SID_ATTR_CHAR_VERTICAL )
522 // draw text object, needs to be initialized when vertical text is used
523 SfxItemSet aSet(mpViewShell->GetPool());
525 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
526 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
528 // Set defaults for vertical click-n'drag text object, pool defaults are:
529 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
530 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
531 // Analog to that:
532 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
533 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
535 pTxtObj->SetMergedItemSet(aSet);
540 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
542 // FitToSize (fit to frame)
543 SfxItemSet aSet(mpViewShell->GetPool(), svl::Items<SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH>{});
544 aSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL));
545 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
546 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
547 pTxtObj->SetMergedItemSet(aSet);
548 pTxtObj->AdjustTextFrameWidthAndHeight();
551 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
553 SfxItemSet aSet(mpViewShell->GetPool(),
554 svl::Items<SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH>{});
555 aSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL));
556 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
557 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
558 pTxtObj->SetMergedItemSet(aSet);
559 pTxtObj->AdjustTextFrameWidthAndHeight();
562 void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
564 // Normal Textobject
565 if (mpDoc->GetDocumentType() != DocumentType::Impress)
566 return;
568 if( nSlotId == SID_ATTR_CHAR )
570 // Impress text object (rescales to line height)
571 SfxItemSet aSet(mpViewShell->GetPool());
572 aSet.Put(makeSdrTextMinFrameHeightItem(0));
573 aSet.Put(makeSdrTextMaxFrameHeightItem(0));
574 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
575 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
576 pTxtObj->SetMergedItemSet(aSet);
578 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
580 SfxItemSet aSet(mpViewShell->GetPool());
581 aSet.Put(makeSdrTextMinFrameWidthItem(0));
582 aSet.Put(makeSdrTextMaxFrameWidthItem(0));
583 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
584 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
585 pTxtObj->SetMergedItemSet(aSet);
588 pTxtObj->AdjustTextFrameWidthAndHeight();
591 bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
593 bool bReturn = false;
594 if (aDragTimer.IsActive())
596 aDragTimer.Stop();
597 bIsInDragMode = false;
600 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
602 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
604 if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
605 return true; // handle event from SdrView
607 bool bEmptyTextObj = false;
609 if (mxTextObj.is())
611 bool bReset = true;
613 if (mpView)
615 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
617 if (rMarkList.GetMarkCount() == 1
618 && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
620 if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
621 bEmptyTextObj = true;
622 else
623 bFirstObjCreated = true;
624 bReset = false;
628 if (bReset)
630 mxTextObj.reset(nullptr);
634 if( mpView && mpView->IsDragObj())
636 // object was moved
637 FrameView* pFrameView = mpViewShell->GetFrameView();
638 bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
640 if (bDragWithCopy)
642 bDragWithCopy = !mpView->IsPresObjSelected(false);
645 mpView->SetDragWithCopy(bDragWithCopy);
646 mpView->EndDragObj( mpView->IsDragWithCopy() );
647 mpView->ForceMarkedToAnotherPage();
648 mpView->SetCurrentObj(OBJ_TEXT);
650 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
652 if (bJustEndedEdit)
654 bJustEndedEdit = false;
655 FuPoor::cancel();
657 if ((rMEvt.GetClicks() != 2) &&
658 !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
659 std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
660 std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
662 /*************************************************************
663 * From text mode, you don't want to rotate immediately.
664 **************************************************************/
665 SdrPageView* pPV;
666 SdrObject* pObj = mpView->PickObj(aMDPos, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK);
667 if (pObj && pPV->IsObjMarkable(pObj))
669 mpView->UnmarkAllObj();
670 mpView->MarkObj(pObj,pPV);
671 return bReturn;
675 else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
677 // object was created
678 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
680 if( mxTextObj.is() )
682 //AW outliner needs to be set to vertical when there is no
683 // outliner object up to now; also it needs to be set back to not
684 // vertical when there was a vertical one used last time.
685 OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
686 SdrOutliner& rOutl(mxTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj()));
687 bool bVertical((pOPO && pOPO->IsVertical())
688 || nSlotId == SID_ATTR_CHAR_VERTICAL
689 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
690 rOutl.SetVertical(bVertical);
692 // Before ImpSetAttributesForNewTextObject the vertical writing mode
693 // needs to be set at the object. This is done here at the OutlinerParaObject
694 // directly to not mirror the layout text items involved. These items will be set
695 // from ImpSetAttributesForNewTextObject and below.
696 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
698 if(!pPara)
700 GetTextObj()->ForceOutlinerParaObject();
701 pPara = GetTextObj()->GetOutlinerParaObject();
704 if(pPara && bVertical != pPara->IsVertical())
706 // set ParaObject orientation accordingly
707 pPara->SetVertical(bVertical);
710 ImpSetAttributesForNewTextObject(GetTextObj());
713 if (!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
715 // it was not possible to create text object
716 mxTextObj.reset(nullptr);
718 else if (nSlotId == SID_TEXT_FITTOSIZE)
720 ImpSetAttributesFitToSize(GetTextObj());
722 SetInEditMode(rMEvt, false);
724 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
726 ImpSetAttributesFitToSizeVertical(GetTextObj());
728 SetInEditMode(rMEvt, false);
730 else
732 ImpSetAttributesFitCommon(GetTextObj());
734 // thereby the handles and the gray frame are correct
735 mpView->AdjustMarkHdl();
736 mpView->PickHandle(aPnt);
737 SetInEditMode(rMEvt, false);
740 else if ( mpView && mpView->IsAction())
742 mpView->EndAction();
745 ForcePointer(&rMEvt);
746 mpWindow->ReleaseMouse();
747 sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
749 if ( mpView && !mpView->AreObjectsMarked() &&
750 std::abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
751 std::abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
752 !rMEvt.IsShift() && !rMEvt.IsMod2() )
754 SdrPageView* pPV2 = mpView->GetSdrPageView();
755 SdrViewEvent aVEvt;
756 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
757 mpView->MarkObj(aVEvt.pRootObj, pPV2);
760 if ( !mxTextObj.is() && mpView )
762 if ( ( (!bEmptyTextObj && bPermanent) ||
763 (!bFirstObjCreated && !bPermanent) ) &&
764 !mpDocSh->IsReadOnly() &&
765 nSlotId != SID_TEXTEDIT )
767 // text body (left-justified AutoGrow)
768 mpView->SetCurrentObj(OBJ_TEXT);
769 mpView->SetEditMode(SdrViewEditMode::Create);
770 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
771 mpView->BegCreateObj(aMDPos, nullptr, nDrgLog);
773 bool bSnapEnabled = mpView->IsSnapEnabled();
775 if (bSnapEnabled)
776 mpView->SetSnapEnabled(false);
778 aPnt.AdjustX(nDrgLog + nDrgLog );
779 aPnt.AdjustY(nDrgLog + nDrgLog );
780 mpView->MovAction(aPnt);
782 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
784 if(mxTextObj.is())
786 GetTextObj()->SetDisableAutoWidthOnDragging(true);
789 if(!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
791 mxTextObj.reset(nullptr);
794 if(bSnapEnabled)
795 mpView->SetSnapEnabled(bSnapEnabled);
797 if(mxTextObj.is())
799 SfxItemSet aSet(mpViewShell->GetPool());
800 aSet.Put(makeSdrTextMinFrameHeightItem(0));
801 aSet.Put(makeSdrTextMinFrameWidthItem(0));
802 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
803 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
805 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
807 // Here, all items which need to be different from pool default need to be set
808 // again on the newly created text object.
809 // Since this is a simple click text object, it is first created, then SetVertical()
810 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
811 // deleted again since not the minimum drag distance was travelled. Then, a new
812 // click text object is created and thus all that stuff needs to be set again here.
814 // Before using the new object the vertical writing mode
815 // needs to be set. This is done here at the OutlinerParaObject
816 // directly to not mirror the layout text items involved. These items will be set
817 // below.
818 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
820 if(!pPara)
822 GetTextObj()->ForceOutlinerParaObject();
823 pPara = GetTextObj()->GetOutlinerParaObject();
826 if(pPara && !pPara->IsVertical())
828 // set ParaObject orientation accordingly
829 pPara->SetVertical(true);
832 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
834 // Analog to the else case below, for vertical simple click texts
835 // one of the default set items from ImpSetAttributesForNewTextObject
836 // needs to be adapted to non-block mode.
837 const SfxItemSet& rSet = mpView->GetDefaultAttr();
838 SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
840 if(SvxFrameDirection::Horizontal_RL_TB == eDirection || SvxFrameDirection::Vertical_RL_TB == eDirection)
842 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
844 else
846 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
849 else
851 // This is for Format/Page settings. Since this also leads
852 // to the object defaults to be changed, i think this code can be
853 // removed. CL. wanted to take a look before adding this.
855 // Look in the object defaults if left-to-right is wanted. If
856 // yes, set text anchoring to right to let the box grow to left.
857 const SfxItemSet& rSet = mpView->GetDefaultAttr();
858 SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
860 if(SvxFrameDirection::Horizontal_RL_TB == eDirection)
862 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
864 else
866 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
870 GetTextObj()->SetMergedItemSet(aSet);
871 GetTextObj()->SetDisableAutoWidthOnDragging(true);
872 SetInEditMode(rMEvt, false);
875 bFirstObjCreated = true;
877 else
879 // switch to selection
880 if (mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
882 mxTextObj.reset(nullptr);
885 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
886 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
889 if (bJustEndedEdit)
891 bJustEndedEdit = false;
892 FuPoor::cancel();
894 bMBDown = false;
895 FuConstruct::MouseButtonUp(rMEvt);
896 return bReturn;
900 * handle keyboard events
901 * @returns sal_True if the event was handled, sal_False otherwise
903 bool FuText::KeyInput(const KeyEvent& rKEvt)
905 bool bReturn = false;
907 vcl::KeyCode nCode = rKEvt.GetKeyCode();
908 bool bShift = nCode.IsShift();
910 if(mxTextObj.is())
912 // maybe object is deleted, test if it's equal to the selected object
913 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
914 SdrObject* pSelectedObj = nullptr;
916 if(1 == rMarkList.GetMarkCount())
918 SdrMark* pMark = rMarkList.GetMark(0);
919 pSelectedObj = pMark->GetMarkedSdrObj();
922 if(mxTextObj.get() != pSelectedObj)
924 mxTextObj.reset(nullptr);
928 if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor::Default && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
930 // title text object: always soft breaks
931 bShift = true;
934 sal_uInt16 nKey = nCode.GetCode();
935 vcl::KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
936 KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
938 bool bOK = true;
940 if (mpDocSh->IsReadOnly())
942 bOK = !EditEngine::DoesKeyChangeText(aKEvt);
944 if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
946 bOK = false; // default handling in base class
949 if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
951 bReturn = true;
953 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
956 else if (aKeyCode == KEY_ESCAPE)
958 bReturn = cancel();
961 if( bPermanent )
963 mpView->SetCurrentObj(OBJ_TEXT);
964 mpView->SetEditMode(SdrViewEditMode::Create);
967 if (!bReturn)
969 bReturn = FuDraw::KeyInput(aKEvt);
972 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(/*bGotoCursor=*/true, /*bActivate=*/true);
988 FuConstruct::Activate();
990 if( pOLV )
991 mpView->SetEditMode(SdrViewEditMode::Edit);
994 void FuText::Deactivate()
996 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
998 if (pOLV)
999 pOLV->HideCursor(/*bDeactivate=*/true);
1001 mpView->SetHitTolerancePixel( HITPIX );
1003 FuConstruct::Deactivate();
1007 * Sets the object into the edit mode.
1009 void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
1011 SdrPageView* pPV = mpView->GetSdrPageView();
1012 if( mxTextObj.is() && (mxTextObj->getSdrPageFromSdrObject() == pPV->GetPage()) )
1014 mpView->SetCurrentObj(OBJ_TEXT);
1016 if( bPermanent )
1017 mpView->SetEditMode(SdrViewEditMode::Create);
1018 else
1019 mpView->SetEditMode(SdrViewEditMode::Edit);
1021 bool bEmptyOutliner = false;
1023 if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1025 ::Outliner* pOutl = mpView->GetTextEditOutliner();
1026 sal_Int32 nParagraphCnt = pOutl->GetParagraphCount();
1027 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1029 if (nParagraphCnt==1 && p1stPara)
1031 // with only one paragraph
1032 if (pOutl->GetText(p1stPara).isEmpty())
1034 bEmptyOutliner = true;
1039 if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1041 SdrInventor nInv = mxTextObj->GetObjInventor();
1042 sal_uInt16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1044 if (nInv == SdrInventor::Default && GetTextObj()->HasTextEdit() &&
1045 (nSdrObjKind == OBJ_TEXT ||
1046 nSdrObjKind == OBJ_TITLETEXT ||
1047 nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1049 // create new outliner (owned by SdrObjEditView)
1050 std::unique_ptr<SdrOutliner> pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
1052 if (bEmptyOutliner)
1053 mpView->SdrEndTextEdit(true);
1055 SdrTextObj* pTextObj = GetTextObj();
1056 if( pTextObj )
1058 OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1059 if( pOPO && pOPO->IsVertical() )
1060 pOutl->SetVertical( true, pOPO->IsTopToBottom());
1061 else if (nSlotId == SID_ATTR_CHAR_VERTICAL || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL)
1062 pOutl->SetVertical( 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, true, pOutl.release()) && mxTextObj->GetObjInventor() == SdrInventor::Default)
1073 //tdf#102293 flush overlay before going on to pass clicks down to
1074 //the outline view which will want to paint selections
1075 for (sal_uInt32 b = 0; b < pPV->PageWindowCount(); ++b)
1077 const SdrPageWindow& rPageWindow = *pPV->GetPageWindow(b);
1078 if (!rPageWindow.GetPaintWindow().OutputToWindow())
1079 continue;
1080 const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager();
1081 if (!xManager.is())
1082 continue;
1083 xManager->flush();
1086 bFirstObjCreated = true;
1087 DeleteDefaultText();
1089 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1091 nSdrObjKind = mxTextObj->GetObjIdentifier();
1093 SdrViewEvent aVEvt;
1094 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1096 if (eHit == SdrHitKind::TextEdit)
1098 // hit text
1099 if (nSdrObjKind == OBJ_TEXT ||
1100 nSdrObjKind == OBJ_TITLETEXT ||
1101 nSdrObjKind == OBJ_OUTLINETEXT ||
1102 nSdrObjKind == OBJ_TABLE ||
1103 nSlotId == SID_TEXTEDIT ||
1104 !bQuickDrag)
1106 pOLV->MouseButtonDown(rMEvt);
1107 pOLV->MouseMove(rMEvt);
1108 pOLV->MouseButtonUp(rMEvt);
1111 if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1113 pOLV->MouseButtonDown(rMEvt);
1116 else
1118 // Move cursor to end of text
1119 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1120 if (pOLV != nullptr)
1121 pOLV->SetSelection(aNewSelection);
1124 else
1126 mpView->RestoreDefaultText( mxTextObj.get() );
1132 else
1134 mxTextObj.reset(nullptr);
1139 * Text entry is started, if necessary delete the default text.
1141 void FuText::DeleteDefaultText()
1143 if ( !(mxTextObj.is() && mxTextObj->IsEmptyPresObj()) )
1144 return;
1146 SdPage* pPage = static_cast<SdPage*>( mxTextObj->getSdrPageFromSdrObject() );
1148 if (!pPage)
1149 return;
1151 PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1153 if ( !((ePresObjKind == PRESOBJ_TITLE ||
1154 ePresObjKind == PRESOBJ_OUTLINE ||
1155 ePresObjKind == PRESOBJ_NOTES ||
1156 ePresObjKind == PRESOBJ_TEXT) &&
1157 !pPage->IsMasterPage()) )
1158 return;
1160 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1161 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1162 bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1163 if( bIsUndoEnabled )
1164 pOutliner->EnableUndo(false);
1166 pOutliner->SetText( OUString(), pOutliner->GetParagraph( 0 ) );
1168 if( bIsUndoEnabled )
1169 pOutliner->EnableUndo(true);
1171 if (pSheet &&
1172 (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1173 pOutliner->SetStyleSheet(0, pSheet);
1175 mxTextObj->SetEmptyPresObj(true);
1178 bool FuText::RequestHelp(const HelpEvent& rHEvt)
1180 bool bReturn = false;
1182 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1184 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1185 mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1187 OUString aHelpText;
1188 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1189 const SvxFieldData* pField = pFieldItem->GetField();
1191 if (auto pURLField = dynamic_cast< const SvxURLField *>( pField ))
1193 // URL-Field
1194 aHelpText = INetURLObject::decode( pURLField->GetURL(), INetURLObject::DecodeMechanism::WithCharset );
1196 if (!aHelpText.isEmpty())
1198 ::tools::Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1199 ::tools::Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1200 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1202 if (Help::IsBalloonHelpEnabled())
1204 Help::ShowBalloon( static_cast<vcl::Window*>(mpWindow), rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1205 bReturn = true;
1207 else if (Help::IsQuickHelpEnabled())
1209 Help::ShowQuickHelp( static_cast<vcl::Window*>(mpWindow), aScreenRect, aHelpText);
1210 bReturn = true;
1215 if (!bReturn)
1217 bReturn = FuConstruct::RequestHelp(rHEvt);
1220 return bReturn;
1223 void FuText::ReceiveRequest(SfxRequest& rReq)
1225 nSlotId = rReq.GetSlot();
1227 // then we call the base class (besides others, nSlotId is NOT set there)
1228 FuPoor::ReceiveRequest(rReq);
1230 if (!(nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId))
1231 return;
1233 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1235 mxTextObj.reset(nullptr);
1237 if (nSlotId == SID_TEXTEDIT)
1239 // are we currently editing?
1240 mxTextObj.reset( mpView->GetTextEditObject() );
1242 if (!mxTextObj.is())
1244 // Try to select an object
1245 SdrPageView* pPV = mpView->GetSdrPageView();
1246 SdrViewEvent aVEvt;
1247 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1248 mpView->MarkObj(aVEvt.pRootObj, pPV);
1250 if (auto pSdrTextObj = dynamic_cast< SdrTextObj *>( aVEvt.pObj ))
1252 mxTextObj.reset( pSdrTextObj );
1256 else if (mpView->AreObjectsMarked())
1258 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1260 if (rMarkList.GetMarkCount() == 1)
1262 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1264 if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr)
1266 mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1271 bool bQuickDrag = true;
1273 const SfxItemSet* pArgs = rReq.GetArgs();
1275 if (pArgs
1277 // test for type before using
1278 && SID_TEXTEDIT == nSlotId
1279 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
1281 && static_cast<const SfxUInt16Item&>( pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1283 // selection with double click -> do not allow QuickDrag
1284 bQuickDrag = false;
1287 SetInEditMode(aMEvt, bQuickDrag);
1290 void FuText::DoubleClick(const MouseEvent& )
1292 // Nothing to do
1295 /** Removed the insertion of default text and putting a new text
1296 object directly into edit mode.
1298 SdrObjectUniquePtr FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
1300 SdrObjectUniquePtr pObj( SdrObjFactory::MakeNewObject(
1301 mpView->getSdrModelFromSdrView(),
1302 mpView->GetCurrentObjInventor(),
1303 mpView->GetCurrentObjIdentifier(),
1304 nullptr) );
1306 if(pObj)
1308 if( auto pText = dynamic_cast< SdrTextObj *>( pObj.get() ) )
1310 pText->SetLogicRect(rRectangle);
1312 bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1313 pText->SetVerticalWriting(bVertical);
1315 ImpSetAttributesForNewTextObject(pText);
1317 if (nSlotId == SID_TEXT_FITTOSIZE)
1319 ImpSetAttributesFitToSize(pText);
1321 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1323 ImpSetAttributesFitToSizeVertical(pText);
1325 else
1327 ImpSetAttributesFitCommon(pText);
1330 // Put text object into edit mode.
1331 SdrPageView* pPV = mpView->GetSdrPageView();
1332 mpView->SdrBeginTextEdit(pText, pPV);
1334 else
1336 OSL_FAIL("Object is NO text object");
1340 return pObj;
1343 /** is called when the current function should be aborted. <p>
1344 This is used when a function gets a KEY_ESCAPE but can also
1345 be called directly.
1347 @returns true if a active function was aborted
1349 bool FuText::cancel()
1351 if ( mpView->IsTextEdit() )
1353 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
1354 mxTextObj.reset(nullptr);
1356 mpView->SetCurrentObj(OBJ_TEXT);
1357 mpView->SetEditMode(SdrViewEditMode::Edit);
1358 return true;
1360 else
1362 return false;
1366 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1368 if( !pFontList || !pView )
1369 return;
1371 if( pOLV )
1373 pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1375 else
1378 pView->BegUndo(SdResId(bGrow ? STR_GROW_FONT_SIZE : STR_SHRINK_FONT_SIZE));
1379 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1380 for( size_t nMark = 0; nMark < rMarkList.GetMarkCount(); ++nMark )
1382 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1383 if( pTextObj )
1385 rtl::Reference<sdr::SelectionController> xSelectionController(pView->getSelectionController());
1386 if (xSelectionController.is() && xSelectionController->ChangeFontSize(bGrow, pFontList))
1388 continue;
1390 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1392 pTextObj->setActiveText( nText );
1394 // Put text object into edit mode.
1395 SdrPageView* pPV = pView->GetSdrPageView();
1396 pView->SdrBeginTextEdit(pTextObj, pPV);
1398 pOLV = pView->GetTextEditOutlinerView();
1399 if( pOLV )
1401 EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1402 if( pEditEngine )
1404 ESelection aSel;
1405 aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1406 aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1407 pOLV->SetSelection(aSel);
1410 ChangeFontSize( bGrow, pOLV, pFontList, pView );
1413 pView->SdrEndTextEdit();
1416 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1417 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1419 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1420 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1421 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1425 pView->EndUndo();
1429 void FuText::InvalidateBindings()
1431 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
1435 } // end of namespace sd
1437 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */