Get the style color and number just once
[LibreOffice.git] / sd / source / ui / func / futext.cxx
blob799dc51c42aad8b1ee74ceaf15117a1124827e17
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;
71 namespace sd {
73 const sal_uInt16 SidArray[] = {
74 SID_STYLE_FAMILY2, // 5542
75 SID_STYLE_FAMILY5, // 5545
76 SID_REDO, // 5700
77 SID_UNDO, // 5701
78 SID_CUT, // 5710
79 SID_COPY, // 5711
80 SID_ATTR_TABSTOP, // 10002
81 SID_ATTR_CHAR_FONT, // 10007
82 SID_ATTR_CHAR_POSTURE, // 10008
83 SID_ATTR_CHAR_WEIGHT, // 10009
84 SID_ATTR_CHAR_SHADOWED, // 10010
85 SID_ATTR_CHAR_STRIKEOUT, // 10013
86 SID_ATTR_CHAR_UNDERLINE, // 10014
87 SID_ATTR_CHAR_FONTHEIGHT, // 10015
88 SID_ATTR_CHAR_COLOR, // 10017
89 SID_ATTR_CHAR_KERNING, // 10018
90 SID_ATTR_CHAR_CASEMAP, // 10019
91 SID_ATTR_PARA_ADJUST_LEFT, // 10028
92 SID_ATTR_PARA_ADJUST_RIGHT, // 10029
93 SID_ATTR_PARA_ADJUST_CENTER, // 10030
94 SID_ATTR_PARA_ADJUST_BLOCK, // 10031
95 SID_ATTR_PARA_LINESPACE_10, // 10034
96 SID_ATTR_PARA_LINESPACE_15, // 10035
97 SID_ATTR_PARA_LINESPACE_20, // 10036
98 SID_ATTR_PARA_ULSPACE, // 10042
99 SID_ATTR_PARA_LRSPACE, // 10043
100 SID_ATTR_TRANSFORM_POS_X, // 10088
101 SID_ATTR_TRANSFORM_POS_Y, // 10089
102 SID_ATTR_TRANSFORM_WIDTH, // 10090
103 SID_ATTR_TRANSFORM_HEIGHT, // 10091
104 SID_ATTR_TRANSFORM_ROT_X, // 10093
105 SID_ATTR_TRANSFORM_ROT_Y, // 10094
106 SID_ATTR_TRANSFORM_ANGLE, // 10095 //Added
107 SID_OUTLINE_UP, // 10150
108 SID_OUTLINE_DOWN, // 10151
109 SID_OUTLINE_LEFT, // 10152
110 SID_OUTLINE_RIGHT, // 10153
111 SID_ATTR_TRANSFORM_PROTECT_POS, // 10236
112 SID_ATTR_TRANSFORM_PROTECT_SIZE, // 10237 //Added
113 SID_FORMTEXT_STYLE, // 10257
114 SID_SET_SUPER_SCRIPT, // 10294
115 SID_SET_SUB_SCRIPT, // 10295
116 SID_ATTR_TRANSFORM_AUTOWIDTH, // 10310
117 SID_ATTR_TRANSFORM_AUTOHEIGHT, // 10311 //Added
118 SID_HYPERLINK_GETLINK, // 10361
119 SID_DEC_INDENT, // 10461
120 SID_INC_INDENT, // 10462
121 SID_CHARMAP, // 10503
122 SID_TEXTDIRECTION_LEFT_TO_RIGHT, // 10907
123 SID_TEXTDIRECTION_TOP_TO_BOTTOM, // 10908
124 SID_ATTR_PARA_LEFT_TO_RIGHT, // 10950
125 SID_ATTR_PARA_RIGHT_TO_LEFT, // 10951
126 SID_PARASPACE_INCREASE, // 11145
127 SID_PARASPACE_DECREASE, // 11146
128 FN_NUM_BULLET_ON, // 20138
129 0 };
133 * base class for text functions
135 FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
136 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
137 , bFirstObjCreated(false)
138 , bJustEndedEdit(false)
139 , rRequest (rReq)
143 rtl::Reference<FuPoor> FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
145 rtl::Reference<FuPoor> xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
146 return xFunc;
149 void FuText::disposing()
151 if(mpView)
153 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
154 mxTextObj = nullptr;
156 // reset the RequestHandler of the used Outliner to the handler of the document
157 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
159 if (pOutliner)
160 pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
164 /*************************************************************************
166 |* Execute functionality of this class:
168 |* #71422: Start the functionality of this class in this method
169 |* and not in the ctor.
170 |* If you construct an object of this class and you put the
171 |* address of this object to pFuActual you've got a problem,
172 |* because some methods inside DoExecute use the pFuActual-Pointer.
173 |* If the code inside DoExecute is executed inside the ctor,
174 |* the value of pFuActual is not right. And the value will not
175 |* be right until the ctor finished !!!
177 \************************************************************************/
178 void FuText::DoExecute( SfxRequest& )
180 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
181 ToolBarManager::ToolBarGroup::Function,
182 ToolbarId::Draw_Text_Toolbox_Sd);
184 mpView->SetCurrentObj(SdrObjKind::Text);
185 mpView->SetEditMode(SdrViewEditMode::Edit);
187 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
189 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
190 if (nSlotId == SID_TEXTEDIT)
192 // Try to select an object
193 SdrPageView* pPV = mpView->GetSdrPageView();
194 SdrViewEvent aVEvt;
195 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
196 mpView->MarkObj(aVEvt.mpRootObj, pPV);
198 mxTextObj = DynCastSdrTextObj( aVEvt.mpObj );
200 else if (rMarkList.GetMarkCount() != 0)
202 if (rMarkList.GetMarkCount() == 1)
204 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
205 mxTextObj = DynCastSdrTextObj( pObj );
209 // check for table
210 if (rMarkList.GetMarkCount() != 0)
212 if (rMarkList.GetMarkCount() == 1)
214 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
215 if( pObj && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == SdrObjKind::Table) )
217 mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell(ToolBarManager::ToolBarGroup::Function, ToolbarId::Draw_Table_Toolbox);
222 bool bQuickDrag = true;
224 const SfxItemSet* pArgs = rRequest.GetArgs();
226 if (pArgs
228 // test for type before using
229 && SID_TEXTEDIT == nSlotId
230 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
232 && pArgs->Get(SID_TEXTEDIT).GetValue() == 2)
234 // Selection by doubleclick -> don't allow QuickDrag
235 bQuickDrag = false;
238 SetInEditMode(aMEvt, bQuickDrag);
241 bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
243 bMBDown = true;
244 bJustEndedEdit = false;
246 bool bReturn = FuDraw::MouseButtonDown(rMEvt);
248 SdrViewEvent aVEvt;
249 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
251 // handle URL also during the text editing
252 if (rMEvt.GetClicks() == 1 && rMEvt.IsLeft() && rMEvt.IsMod1())
254 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
256 if (mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
258 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
259 if (pFieldItem)
261 const SvxFieldData* pField = pFieldItem->GetField();
263 if (auto pURLField = dynamic_cast< const SvxURLField *>( pField ))
265 eHit = SdrHitKind::MarkedObject;
266 aVEvt.meEvent = SdrEventKind::ExecuteUrl;
267 aVEvt.mpURLField = pURLField;
273 if (eHit == SdrHitKind::TextEdit)
275 // hit text -> SdrView handles event
276 if (mpView->MouseButtonDown(rMEvt, mpWindow->GetOutDev()))
277 return true;
280 if (rMEvt.GetClicks() == 1)
282 if (mpView->IsTextEdit() && eHit != SdrHitKind::MarkedObject && eHit != SdrHitKind::Handle)
284 // finish text input
285 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
287 /* Bugfix from MBA: during a double click onto the unused? area
288 in text mode, we get with the second click eHit =
289 SdrHitKind::TextEditObj since it goes to the TextObject which was
290 created with the first click. But this is removed by
291 SdrEndTextEdit since it is empty. But it is still in the mark
292 list. The call MarkObj further below accesses then the dead
293 object. As a simple fix, we determine eHit after
294 SdrEndTextEdit again, this returns then SdrHitKind::NONE. */
295 mxTextObj = nullptr;
296 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
299 mpView->SetCurrentObj(SdrObjKind::Text);
300 mpView->SetEditMode(SdrViewEditMode::Edit);
303 if (rMEvt.IsLeft() || rMEvt.IsRight())
305 mpWindow->CaptureMouse();
306 SdrPageView* pPV = mpView->GetSdrPageView();
308 if (eHit == SdrHitKind::TextEdit)
310 SetInEditMode(rMEvt, false);
312 else
314 // Don't remark table when clicking in it, mark change triggers a lot of updating
315 bool bMarkChanges = true;
316 rtl::Reference< sdr::SelectionController > xSelectionController(mpView->getSelectionController());
317 if (eHit == SdrHitKind::TextEditObj && xSelectionController.is())
319 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
320 if (rMarkList.GetMarkCount() == 1 && rMarkList.GetMark(0)->GetMarkedSdrObj() == aVEvt.mpRootObj)
321 bMarkChanges = false;
324 if (eHit != SdrHitKind::Handle)
326 // deselect selection
327 if (!rMEvt.IsShift() && eHit == SdrHitKind::TextEditObj)
329 if(bMarkChanges)
331 mpView->UnmarkAll();
332 mpView->SetDragMode(SdrDragMode::Move);
337 if ( aVEvt.meEvent == SdrEventKind::ExecuteUrl ||
338 eHit == SdrHitKind::Handle ||
339 eHit == SdrHitKind::MarkedObject ||
340 eHit == SdrHitKind::TextEditObj ||
341 ( eHit == SdrHitKind::UnmarkedObject && bFirstObjCreated &&
342 !bPermanent ) )
344 // Handle, hit marked or unmarked object
345 if (eHit == SdrHitKind::TextEditObj)
347 /* hit text of unmarked object:
348 select object and set to EditMode */
349 if (bMarkChanges)
350 mpView->MarkObj(aVEvt.mpRootObj, pPV);
352 if (auto pSdrTextObj = DynCastSdrTextObj(aVEvt.mpObj))
354 mxTextObj = pSdrTextObj;
357 SetInEditMode(rMEvt, true);
359 else if (aVEvt.meEvent == SdrEventKind::ExecuteUrl && !rMEvt.IsMod2())
361 // execute URL
362 mpWindow->ReleaseMouse();
364 if (aVEvt.mpURLField)
366 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.mpURLField->GetURL());
367 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
368 SfxBoolItem aBrowseItem( SID_BROWSE, true );
369 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
371 if (rMEvt.IsMod1())
373 // open in new frame
374 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
375 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
376 { &aStrItem, &aBrowseItem, &aReferer });
378 else
380 // open in current frame
381 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
382 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
383 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
384 { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
388 else
390 // drag object or handle
392 // #i78748#
393 // do the EndTextEdit first, it will delete the handles and force a
394 // recreation. This will make aVEvt.mpHdl to point to a deleted handle,
395 // thus it is necessary to reset it and to get it again.
397 // #i112855#
398 // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObject
399 // this caused SdrEndTextEdit() to be called also when not in text editing and
400 // this does not make sense and caused troubles. (see issue 112855)
402 if( mpView->IsTextEdit() )
404 mpView->SdrEndTextEdit();
405 bJustEndedEdit = true;
407 if(aVEvt.mpHdl)
409 // force new handle identification, the pointer will be dead here
410 // since SdrEndTextEdit has reset (deleted) the handles.
411 aVEvt.mpHdl = nullptr;
412 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
416 if (!aVEvt.mpHdl)
418 if( eHit == SdrHitKind::UnmarkedObject )
420 if ( !rMEvt.IsShift() )
421 mpView->UnmarkAll();
423 mpView->MarkObj(aVEvt.mpRootObj, pPV);
426 // Drag object
427 bFirstMouseMove = true;
428 aDragTimer.Start();
431 if ( ! rMEvt.IsRight())
433 // we need to pick again since SdrEndTextEdit can rebuild the handles list
434 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
435 if( (eHit == SdrHitKind::Handle) || (eHit == SdrHitKind::MarkedObject) )
437 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
438 mpView->BegDragObj(aMDPos, nullptr, aVEvt.mpHdl, nDrgLog);
441 bReturn = true;
444 else if ( nSlotId != SID_TEXTEDIT &&
445 (bPermanent || !bFirstObjCreated) )
447 // create object
448 mpView->SetCurrentObj(SdrObjKind::Text);
449 mpView->SetEditMode(SdrViewEditMode::Create);
450 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
451 mpView->BegCreateObj(aMDPos, nullptr, nDrgLog);
453 else
455 // select
456 if( !rMEvt.IsShift() )
457 mpView->UnmarkAll();
459 mpView->BegMarkObj( aMDPos );
464 else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
466 MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
467 SetInEditMode( aMEvt, false );
470 if (!bIsInDragMode)
472 ForcePointer(&rMEvt);
473 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
476 return bReturn;
479 bool FuText::MouseMove(const MouseEvent& rMEvt)
481 bool bReturn = FuDraw::MouseMove(rMEvt);
483 if (aDragTimer.IsActive() )
485 if( bFirstMouseMove )
486 bFirstMouseMove = false;
487 else
488 aDragTimer.Stop();
491 if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
493 Point aPix(rMEvt.GetPosPixel());
494 Point aPnt(mpWindow->PixelToLogic(aPix));
496 ForceScroll(aPix);
497 mpView->MovAction(aPnt);
500 ForcePointer(&rMEvt);
502 return bReturn;
505 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
507 if( nSlotId == SID_ATTR_CHAR )
509 SfxItemSet aSet(mpViewShell->GetPool());
510 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
511 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
512 pTxtObj->SetMergedItemSet(aSet);
513 pTxtObj->AdjustTextFrameWidthAndHeight();
514 const SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
515 if (pCurrentViewShell && (pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet()))
516 pTxtObj->SetText(SdResId(STR_PRESOBJ_TEXT_EDIT_MOBILE));
518 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
520 // draw text object, needs to be initialized when vertical text is used
521 SfxItemSet aSet(mpViewShell->GetPool());
523 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
524 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
526 // Set defaults for vertical click-n'drag text object, pool defaults are:
527 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
528 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
529 // Analog to that:
530 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
531 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
533 pTxtObj->SetMergedItemSet(aSet);
534 pTxtObj->AdjustTextFrameWidthAndHeight();
538 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
540 // FitToSize (fit to frame)
541 SfxItemSetFixed<SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH> aSet(mpViewShell->GetPool());
542 aSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL));
543 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
544 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
545 pTxtObj->SetMergedItemSet(aSet);
546 pTxtObj->AdjustTextFrameWidthAndHeight();
549 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
551 SfxItemSetFixed<SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH> aSet(mpViewShell->GetPool());
552 aSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL));
553 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
554 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
555 pTxtObj->SetMergedItemSet(aSet);
556 pTxtObj->AdjustTextFrameWidthAndHeight();
559 bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
561 bool bReturn = false;
562 if (aDragTimer.IsActive())
564 aDragTimer.Stop();
565 bIsInDragMode = false;
568 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
570 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
572 if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow->GetOutDev())) || rMEvt.GetClicks() == 2 )
573 return true; // handle event from SdrView
575 bool bEmptyTextObj = false;
577 if (mxTextObj.get().is())
579 bool bReset = true;
581 if (mpView)
583 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
585 if (rMarkList.GetMarkCount() == 1
586 && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get().get()) )
588 if (!GetTextObj()->GetOutlinerParaObject() )
589 bEmptyTextObj = true;
590 else
591 bFirstObjCreated = true;
592 bReset = false;
596 if (bReset)
598 mxTextObj = nullptr;
602 if (rMEvt.IsLeft() && !mxTextObj.get().is() && IsIgnoreUnexpectedMouseButtonUp())
603 return false;
605 if( mpView && mpView->IsDragObj())
607 // object was moved
608 FrameView* pFrameView = mpViewShell->GetFrameView();
609 bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
611 if (bDragWithCopy)
613 bDragWithCopy = !mpView->IsPresObjSelected(false);
616 mpView->SetDragWithCopy(bDragWithCopy);
617 mpView->EndDragObj( mpView->IsDragWithCopy() );
618 mpView->ForceMarkedToAnotherPage();
619 mpView->SetCurrentObj(SdrObjKind::Text);
621 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
623 if (bJustEndedEdit)
625 bJustEndedEdit = false;
626 FuPoor::cancel();
628 if ((rMEvt.GetClicks() != 2) &&
629 !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
630 std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
631 std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
633 /*************************************************************
634 * From text mode, you don't want to rotate immediately.
635 **************************************************************/
636 SdrPageView* pPV;
637 SdrObject* pObj = mpView->PickObj(aMDPos, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK);
638 if (pObj && pPV->IsObjMarkable(pObj))
640 mpView->UnmarkAllObj();
641 mpView->MarkObj(pObj,pPV);
642 return bReturn;
646 else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
648 // object was created
649 rtl::Reference<SdrTextObj> pTextObj = DynCastSdrTextObj( mpView->GetCreateObj() );
650 mxTextObj = pTextObj.get();
652 if( pTextObj )
654 //AW outliner needs to be set to vertical when there is no
655 // outliner object up to now; also it needs to be set back to not
656 // vertical when there was a vertical one used last time.
657 OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
658 SdrOutliner& rOutl(pTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj()));
659 bool bVertical((pOPO && pOPO->IsEffectivelyVertical())
660 || nSlotId == SID_ATTR_CHAR_VERTICAL
661 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
662 rOutl.SetVertical(bVertical);
664 // Before ImpSetAttributesForNewTextObject the vertical writing mode
665 // needs to be set at the object. This is done here at the OutlinerParaObject
666 // directly to not mirror the layout text items involved. These items will be set
667 // from ImpSetAttributesForNewTextObject and below.
668 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
670 if(!pPara)
672 GetTextObj()->ForceOutlinerParaObject();
673 pPara = GetTextObj()->GetOutlinerParaObject();
676 if(pPara && bVertical != pPara->IsEffectivelyVertical())
678 // set ParaObject orientation accordingly
679 pPara->SetVertical(bVertical);
682 ImpSetAttributesForNewTextObject(GetTextObj());
685 if (!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
687 // it was not possible to create text object
688 mxTextObj = nullptr;
689 pTextObj = nullptr;
691 else if (nSlotId == SID_TEXT_FITTOSIZE)
693 ImpSetAttributesFitToSize(GetTextObj());
695 SetInEditMode(rMEvt, false);
697 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
699 ImpSetAttributesFitToSizeVertical(GetTextObj());
701 SetInEditMode(rMEvt, false);
703 else
705 // thereby the handles and the gray frame are correct
706 mpView->AdjustMarkHdl();
707 mpView->PickHandle(aPnt);
708 SetInEditMode(rMEvt, false);
711 else if ( mpView && mpView->IsAction())
713 mpView->EndAction();
716 ForcePointer(&rMEvt);
717 mpWindow->ReleaseMouse();
719 if (mpView)
721 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
722 if ( rMarkList.GetMarkCount() == 0 )
724 sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
725 if ( std::abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
726 std::abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
727 !rMEvt.IsShift() && !rMEvt.IsMod2() )
729 SdrPageView* pPV2 = mpView->GetSdrPageView();
730 SdrViewEvent aVEvt;
731 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
732 mpView->MarkObj(aVEvt.mpRootObj, pPV2);
737 if ( !mxTextObj.get().is() && mpView )
739 if ( ( (!bEmptyTextObj && bPermanent) ||
740 (!bFirstObjCreated && !bPermanent) ) &&
741 !mpDocSh->IsReadOnly() &&
742 nSlotId != SID_TEXTEDIT )
744 // text body (left-justified AutoGrow)
745 mpView->SetCurrentObj(SdrObjKind::Text);
746 mpView->SetEditMode(SdrViewEditMode::Create);
747 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
748 mpView->BegCreateObj(aMDPos, nullptr, nDrgLog);
750 bool bSnapEnabled = mpView->IsSnapEnabled();
752 if (bSnapEnabled)
753 mpView->SetSnapEnabled(false);
755 aPnt.AdjustX(nDrgLog + nDrgLog );
756 aPnt.AdjustY(nDrgLog + nDrgLog );
757 mpView->MovAction(aPnt);
759 mxTextObj = DynCastSdrTextObj( mpView->GetCreateObj() );
761 if(mxTextObj.get().is())
763 GetTextObj()->SetDisableAutoWidthOnDragging(true);
766 if(!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
768 mxTextObj.clear();
771 if(bSnapEnabled)
772 mpView->SetSnapEnabled(bSnapEnabled);
774 if(mxTextObj.get().is())
776 SfxItemSet aSet(mpViewShell->GetPool());
777 aSet.Put(makeSdrTextMinFrameHeightItem(0));
778 aSet.Put(makeSdrTextMinFrameWidthItem(0));
779 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
780 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
782 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
784 // Here, all items which need to be different from pool default need to be set
785 // again on the newly created text object.
786 // Since this is a simple click text object, it is first created, then SetVertical()
787 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
788 // deleted again since not the minimum drag distance was travelled. Then, a new
789 // click text object is created and thus all that stuff needs to be set again here.
791 // Before using the new object the vertical writing mode
792 // needs to be set. This is done here at the OutlinerParaObject
793 // directly to not mirror the layout text items involved. These items will be set
794 // below.
795 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
797 if(!pPara)
799 GetTextObj()->ForceOutlinerParaObject();
800 pPara = GetTextObj()->GetOutlinerParaObject();
803 if(pPara && !pPara->IsEffectivelyVertical())
805 // set ParaObject orientation accordingly
806 pPara->SetVertical(true);
809 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
811 // Analog to the else case below, for vertical simple click texts
812 // one of the default set items from ImpSetAttributesForNewTextObject
813 // needs to be adapted to non-block mode.
814 const SfxItemSet& rSet = mpView->GetDefaultAttr();
815 SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
817 if(SvxFrameDirection::Horizontal_RL_TB == eDirection || SvxFrameDirection::Vertical_RL_TB == eDirection)
819 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
821 else
823 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
826 else
828 // This is for Format/Page settings. Since this also leads
829 // to the object defaults to be changed, i think this code can be
830 // removed. CL. wanted to take a look before adding this.
832 // Look in the object defaults if left-to-right is wanted. If
833 // yes, set text anchoring to right to let the box grow to left.
834 const SfxItemSet& rSet = mpView->GetDefaultAttr();
835 SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
837 if(SvxFrameDirection::Horizontal_RL_TB == eDirection)
839 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
841 else
843 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
847 GetTextObj()->SetMergedItemSet(aSet);
848 GetTextObj()->SetDisableAutoWidthOnDragging(true);
849 SetInEditMode(rMEvt, false);
852 bFirstObjCreated = true;
854 else
856 // switch to selection
857 if (mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
859 mxTextObj = nullptr;
862 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
863 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
866 if (bJustEndedEdit)
868 bJustEndedEdit = false;
869 FuPoor::cancel();
871 bMBDown = false;
872 FuConstruct::MouseButtonUp(rMEvt);
873 return bReturn;
877 * handle keyboard events
878 * @returns sal_True if the event was handled, sal_False otherwise
880 bool FuText::KeyInput(const KeyEvent& rKEvt)
882 bool bReturn = false;
884 vcl::KeyCode nCode = rKEvt.GetKeyCode();
885 bool bShift = nCode.IsShift();
887 if(mxTextObj.get().is())
889 // maybe object is deleted, test if it's equal to the selected object
890 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
891 SdrObject* pSelectedObj = nullptr;
893 if(1 == rMarkList.GetMarkCount())
895 SdrMark* pMark = rMarkList.GetMark(0);
896 pSelectedObj = pMark->GetMarkedSdrObj();
899 if(mxTextObj.get().get() != pSelectedObj)
901 mxTextObj = nullptr;
905 if (auto pTextObj = mxTextObj.get())
906 if ( pTextObj->GetObjInventor() == SdrInventor::Default && pTextObj->GetObjIdentifier() == SdrObjKind::TitleText && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
908 // title text object: always soft breaks
909 bShift = true;
912 sal_uInt16 nKey = nCode.GetCode();
913 vcl::KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
914 KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
916 bool bOK = true;
918 if (mpDocSh->IsReadOnly())
920 bOK = !EditEngine::DoesKeyChangeText(aKEvt);
922 if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
924 bOK = false; // default handling in base class
927 if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
929 bReturn = true;
931 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
934 else if (aKeyCode == KEY_ESCAPE)
936 bReturn = cancel();
939 if( bPermanent )
941 mpView->SetCurrentObj(SdrObjKind::Text);
942 mpView->SetEditMode(SdrViewEditMode::Create);
945 if (!bReturn)
947 bReturn = FuDraw::KeyInput(aKEvt);
950 return bReturn;
953 void FuText::Activate()
955 mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
957 // #i89661# it's no longer necessary to make it so big here, it's fine tuned
958 // for text objects in SdrMarkView::CheckSingleSdrObjectHit
959 mpView->SetHitTolerancePixel( 2 * HITPIX );
961 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
963 if (pOLV)
964 pOLV->ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
966 FuConstruct::Activate();
968 if( pOLV )
969 mpView->SetEditMode(SdrViewEditMode::Edit);
972 void FuText::Deactivate()
974 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
976 if (pOLV)
977 pOLV->HideCursor(/*bDeactivate=*/true);
979 mpView->SetHitTolerancePixel( HITPIX );
981 FuConstruct::Deactivate();
985 * Sets the object into the edit mode.
987 void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
989 SdrPageView* pPV = mpView->GetSdrPageView();
990 if( mxTextObj.get().is() && (mxTextObj.get()->getSdrPageFromSdrObject() == pPV->GetPage()) )
992 mpView->SetCurrentObj(SdrObjKind::Text);
994 if( bPermanent )
995 mpView->SetEditMode(SdrViewEditMode::Create);
996 else
997 mpView->SetEditMode(SdrViewEditMode::Edit);
999 bool bEmptyOutliner = false;
1001 if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1003 ::Outliner* pOutl = mpView->GetTextEditOutliner();
1004 sal_Int32 nParagraphCnt = pOutl->GetParagraphCount();
1005 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1007 if (nParagraphCnt==1 && p1stPara)
1009 // with only one paragraph
1010 if (pOutl->GetText(p1stPara).isEmpty())
1012 bEmptyOutliner = true;
1017 if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1019 rtl::Reference<SdrTextObj> pTextObj = mxTextObj.get();
1020 SdrInventor nInv = pTextObj->GetObjInventor();
1021 SdrObjKind nSdrObjKind = pTextObj->GetObjIdentifier();
1023 if (nInv == SdrInventor::Default && GetTextObj()->HasTextEdit() &&
1024 (nSdrObjKind == SdrObjKind::Text ||
1025 nSdrObjKind == SdrObjKind::TitleText ||
1026 nSdrObjKind == SdrObjKind::OutlineText || !pTextObj->IsEmptyPresObj() ) )
1028 // create new outliner (owned by SdrObjEditView)
1029 std::unique_ptr<SdrOutliner> pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
1031 if (bEmptyOutliner)
1032 mpView->SdrEndTextEdit(true);
1034 pTextObj = GetTextObj();
1035 if( pTextObj )
1037 OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1038 if( pOPO && pOPO->IsEffectivelyVertical() )
1040 pOutl->SetVertical(pOPO->GetVertical());
1041 pOutl->SetRotation(pOPO->GetRotation());
1043 else if (nSlotId == SID_ATTR_CHAR_VERTICAL || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL)
1044 pOutl->SetVertical( true );
1046 if( pTextObj->getTextCount() > 1 )
1048 Point aPix(rMEvt.GetPosPixel());
1049 Point aPnt(mpWindow->PixelToLogic(aPix));
1050 pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1053 if (mpView->SdrBeginTextEdit(pTextObj.get(), pPV, mpWindow, true, pOutl.release()) && mxTextObj.get()->GetObjInventor() == SdrInventor::Default)
1055 //tdf#102293 flush overlay before going on to pass clicks down to
1056 //the outline view which will want to paint selections
1057 for (sal_uInt32 b = 0; b < pPV->PageWindowCount(); ++b)
1059 const SdrPageWindow& rPageWindow = *pPV->GetPageWindow(b);
1060 if (!rPageWindow.GetPaintWindow().OutputToWindow())
1061 continue;
1062 const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager();
1063 if (!xManager.is())
1064 continue;
1065 xManager->flush();
1068 bFirstObjCreated = true;
1069 DeleteDefaultText();
1071 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1073 nSdrObjKind = mxTextObj.get()->GetObjIdentifier();
1075 SdrViewEvent aVEvt;
1076 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1078 if (eHit == SdrHitKind::TextEdit)
1080 // hit text
1081 if (nSdrObjKind == SdrObjKind::Text ||
1082 nSdrObjKind == SdrObjKind::TitleText ||
1083 nSdrObjKind == SdrObjKind::OutlineText ||
1084 nSdrObjKind == SdrObjKind::Table ||
1085 nSlotId == SID_TEXTEDIT ||
1086 !bQuickDrag)
1088 pOLV->MouseButtonDown(rMEvt);
1089 pOLV->MouseMove(rMEvt);
1090 pOLV->MouseButtonUp(rMEvt);
1093 if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1095 pOLV->MouseButtonDown(rMEvt);
1098 else
1100 // Move cursor to end of text
1101 if (pOLV != nullptr)
1102 pOLV->SetSelection(ESelection::AtEnd());
1105 else
1107 mpView->RestoreDefaultText( mxTextObj.get().get() );
1113 else
1115 mxTextObj = nullptr;
1120 * Text entry is started, if necessary delete the default text.
1122 void FuText::DeleteDefaultText()
1124 if ( !(mxTextObj.get().is() && mxTextObj.get()->IsEmptyPresObj()) )
1125 return;
1127 SdPage* pPage = static_cast<SdPage*>( mxTextObj.get()->getSdrPageFromSdrObject() );
1129 if (!pPage)
1130 return;
1132 PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get().get());
1134 if ( !(ePresObjKind == PresObjKind::Title ||
1135 ePresObjKind == PresObjKind::Outline ||
1136 ePresObjKind == PresObjKind::Notes ||
1137 ePresObjKind == PresObjKind::Text ) ||
1138 pPage->IsMasterPage() )
1139 return;
1141 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1142 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1143 bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1144 if( bIsUndoEnabled )
1145 pOutliner->EnableUndo(false);
1147 pOutliner->SetText( OUString(), pOutliner->GetParagraph( 0 ) );
1149 if( bIsUndoEnabled )
1150 pOutliner->EnableUndo(true);
1152 if (pSheet &&
1153 (ePresObjKind == PresObjKind::Notes || ePresObjKind == PresObjKind::Text))
1154 pOutliner->SetStyleSheet(0, pSheet);
1156 mxTextObj.get()->SetEmptyPresObj(true);
1159 bool FuText::RequestHelp(const HelpEvent& rHEvt)
1161 bool bReturn = false;
1163 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1165 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1166 mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
1168 OUString aHelpText;
1169 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1170 const SvxFieldData* pField = pFieldItem->GetField();
1172 if (auto pURLField = dynamic_cast< const SvxURLField *>( pField ))
1174 // URL-Field
1175 aHelpText = INetURLObject::decode( pURLField->GetURL(), INetURLObject::DecodeMechanism::WithCharset );
1177 if (!aHelpText.isEmpty())
1179 ::tools::Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj.get()->GetLogicRect());
1180 ::tools::Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1181 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1183 if (Help::IsBalloonHelpEnabled())
1185 Help::ShowBalloon( static_cast<vcl::Window*>(mpWindow), rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1186 bReturn = true;
1188 else if (Help::IsQuickHelpEnabled())
1190 Help::ShowQuickHelp( static_cast<vcl::Window*>(mpWindow), aScreenRect, aHelpText);
1191 bReturn = true;
1196 if (!bReturn)
1198 bReturn = FuConstruct::RequestHelp(rHEvt);
1201 return bReturn;
1204 void FuText::ReceiveRequest(SfxRequest& rReq)
1206 nSlotId = rReq.GetSlot();
1208 // then we call the base class (besides others, nSlotId is NOT set there)
1209 FuPoor::ReceiveRequest(rReq);
1211 if (!(nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId))
1212 return;
1214 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1216 mxTextObj = nullptr;
1217 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1219 if (nSlotId == SID_TEXTEDIT)
1221 // are we currently editing?
1222 mxTextObj = mpView->GetTextEditObject();
1224 if (!mxTextObj.get().is())
1226 // Try to select an object
1227 SdrPageView* pPV = mpView->GetSdrPageView();
1228 SdrViewEvent aVEvt;
1229 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1230 mpView->MarkObj(aVEvt.mpRootObj, pPV);
1232 if (auto pSdrTextObj = DynCastSdrTextObj(aVEvt.mpObj))
1234 mxTextObj = pSdrTextObj;
1238 else if (rMarkList.GetMarkCount() != 0)
1241 if (rMarkList.GetMarkCount() == 1)
1243 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1245 if( auto pTextObj = DynCastSdrTextObj( pObj ))
1247 mxTextObj = pTextObj;
1252 bool bQuickDrag = true;
1254 const SfxItemSet* pArgs = rReq.GetArgs();
1256 if (pArgs
1258 // test for type before using
1259 && SID_TEXTEDIT == nSlotId
1260 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
1262 && pArgs->Get(SID_TEXTEDIT).GetValue() == 2)
1264 // selection with double click -> do not allow QuickDrag
1265 bQuickDrag = false;
1268 SetInEditMode(aMEvt, bQuickDrag);
1271 void FuText::DoubleClick(const MouseEvent& )
1273 // Nothing to do
1276 /** Removed the insertion of default text and putting a new text
1277 object directly into edit mode.
1279 rtl::Reference<SdrObject> FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
1281 rtl::Reference<SdrObject> pObj( SdrObjFactory::MakeNewObject(
1282 mpView->getSdrModelFromSdrView(),
1283 mpView->GetCurrentObjInventor(),
1284 mpView->GetCurrentObjIdentifier(),
1285 nullptr) );
1287 if(pObj)
1289 if( auto pText = DynCastSdrTextObj( pObj.get() ) )
1291 pText->SetLogicRect(rRectangle);
1293 bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1294 pText->SetVerticalWriting(bVertical);
1296 ImpSetAttributesForNewTextObject(pText);
1298 if (nSlotId == SID_TEXT_FITTOSIZE)
1300 ImpSetAttributesFitToSize(pText);
1302 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1304 ImpSetAttributesFitToSizeVertical(pText);
1307 // Put text object into edit mode.
1308 SdrPageView* pPV = mpView->GetSdrPageView();
1309 mpView->SdrBeginTextEdit(pText, pPV);
1311 else
1313 OSL_FAIL("Object is NO text object");
1317 return pObj;
1320 /** is called when the current function should be aborted. <p>
1321 This is used when a function gets a KEY_ESCAPE but can also
1322 be called directly.
1324 @returns true if an active function was aborted
1326 bool FuText::cancel()
1328 if ( mpView->IsTextEdit() )
1330 if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
1331 mxTextObj = nullptr;
1333 mpView->SetCurrentObj(SdrObjKind::Text);
1334 mpView->SetEditMode(SdrViewEditMode::Edit);
1335 return true;
1337 else
1339 return false;
1343 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1345 if( !pFontList || !pView )
1346 return;
1348 if( pOLV )
1350 pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1352 else
1355 pView->BegUndo(SdResId(bGrow ? STR_GROW_FONT_SIZE : STR_SHRINK_FONT_SIZE));
1356 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1357 for( size_t nMark = 0; nMark < rMarkList.GetMarkCount(); ++nMark )
1359 SdrTextObj* pTextObj = DynCastSdrTextObj( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1360 if( pTextObj )
1362 rtl::Reference<sdr::SelectionController> xSelectionController(pView->getSelectionController());
1363 if (xSelectionController.is() && xSelectionController->ChangeFontSize(bGrow, pFontList))
1365 continue;
1367 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1369 pTextObj->setActiveText( nText );
1371 // Put text object into edit mode.
1372 SdrPageView* pPV = pView->GetSdrPageView();
1373 pView->SdrBeginTextEdit(pTextObj, pPV);
1375 pOLV = pView->GetTextEditOutlinerView();
1376 if( pOLV )
1378 pOLV->SetSelection(ESelection::All());
1380 ChangeFontSize( bGrow, pOLV, pFontList, pView );
1383 pView->SdrEndTextEdit();
1386 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1387 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1389 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1390 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1391 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1395 pView->EndUndo();
1399 void FuText::InvalidateBindings()
1401 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
1405 } // end of namespace sd
1407 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */