1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <editeng/eeitem.hxx>
22 #include <editeng/editerr.hxx>
23 #include <svx/dlgutil.hxx>
24 #include <svx/sdrpagewindow.hxx>
25 #include <svx/sdrpaintwindow.hxx>
26 #include <svx/svxerr.hxx>
27 #include <tools/urlobj.hxx>
28 #include <vcl/help.hxx>
29 #include <editeng/editstat.hxx>
30 #include <editeng/fhgtitem.hxx>
31 #include <svl/aeitem.hxx>
32 #include <svl/intitem.hxx>
33 #include <svx/svdotext.hxx>
34 #include <svx/svdogrp.hxx>
35 #include <editeng/flditem.hxx>
36 #include <svl/style.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/request.hxx>
42 #include <editeng/editeng.hxx>
43 #include <svx/svdoutl.hxx>
44 #include <svx/svdotable.hxx>
45 #include <svx/svxids.hrc>
46 #include <sfx2/docfile.hxx>
47 #include <editeng/outlobj.hxx>
48 #include <svtools/langtab.hxx>
50 #include <editeng/frmdiritem.hxx>
52 #include <svx/svdetc.hxx>
53 #include <editeng/editview.hxx>
55 #include <sdresid.hxx>
58 #include <ViewShell.hxx>
59 #include <ViewShellBase.hxx>
61 #include <Outliner.hxx>
63 #include <drawdoc.hxx>
66 #include <FrameView.hxx>
67 #include <ToolBarManager.hxx>
68 #include <DrawDocShell.hxx>
69 #include <strings.hrc>
71 #include <optsitem.hxx>
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::uno
;
75 using namespace ::com::sun::star::lang
;
76 using namespace ::com::sun::star::linguistic2
;
80 static const sal_uInt16 SidArray
[] = {
81 SID_STYLE_FAMILY2
, // 5542
82 SID_STYLE_FAMILY5
, // 5545
87 SID_ATTR_TABSTOP
, // 10002
88 SID_ATTR_CHAR_FONT
, // 10007
89 SID_ATTR_CHAR_POSTURE
, // 10008
90 SID_ATTR_CHAR_WEIGHT
, // 10009
91 SID_ATTR_CHAR_SHADOWED
, // 10010
92 SID_ATTR_CHAR_STRIKEOUT
, // 10013
93 SID_ATTR_CHAR_UNDERLINE
, // 10014
94 SID_ATTR_CHAR_FONTHEIGHT
, // 10015
95 SID_ATTR_CHAR_COLOR
, // 10017
96 SID_ATTR_CHAR_KERNING
, // 10018
97 SID_ATTR_CHAR_CASEMAP
, // 10019
98 SID_ATTR_PARA_ADJUST_LEFT
, // 10028
99 SID_ATTR_PARA_ADJUST_RIGHT
, // 10029
100 SID_ATTR_PARA_ADJUST_CENTER
, // 10030
101 SID_ATTR_PARA_ADJUST_BLOCK
, // 10031
102 SID_ATTR_PARA_LINESPACE_10
, // 10034
103 SID_ATTR_PARA_LINESPACE_15
, // 10035
104 SID_ATTR_PARA_LINESPACE_20
, // 10036
105 SID_ATTR_PARA_ULSPACE
, // 10042
106 SID_ATTR_PARA_LRSPACE
, // 10043
107 SID_ATTR_TRANSFORM_POS_X
, // 10088
108 SID_ATTR_TRANSFORM_POS_Y
, // 10089
109 SID_ATTR_TRANSFORM_WIDTH
, // 10090
110 SID_ATTR_TRANSFORM_HEIGHT
, // 10091
111 SID_ATTR_TRANSFORM_ROT_X
, // 10093
112 SID_ATTR_TRANSFORM_ROT_Y
, // 10094
113 SID_ATTR_TRANSFORM_ANGLE
, // 10095 //Added
114 SID_OUTLINE_UP
, // 10150
115 SID_OUTLINE_DOWN
, // 10151
116 SID_OUTLINE_LEFT
, // 10152
117 SID_OUTLINE_RIGHT
, // 10153
118 SID_ATTR_TRANSFORM_PROTECT_POS
, // 10236
119 SID_ATTR_TRANSFORM_PROTECT_SIZE
, // 10237 //Added
120 SID_FORMTEXT_STYLE
, // 10257
121 SID_SET_SUPER_SCRIPT
, // 10294
122 SID_SET_SUB_SCRIPT
, // 10295
123 SID_ATTR_TRANSFORM_AUTOWIDTH
, // 10310
124 SID_ATTR_TRANSFORM_AUTOHEIGHT
, // 10311 //Added
125 SID_HYPERLINK_GETLINK
, // 10361
126 SID_CHARMAP
, // 10503
127 SID_TEXTDIRECTION_LEFT_TO_RIGHT
, // 10907
128 SID_TEXTDIRECTION_TOP_TO_BOTTOM
, // 10908
129 SID_ATTR_PARA_LEFT_TO_RIGHT
, // 10950
130 SID_ATTR_PARA_RIGHT_TO_LEFT
, // 10951
131 SID_PARASPACE_INCREASE
, // 11145
132 SID_PARASPACE_DECREASE
, // 11146
133 FN_NUM_BULLET_ON
, // 20138
137 static bool bTestText
= false;
140 * base class for text functions
142 FuText::FuText( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
143 : FuConstruct(pViewSh
, pWin
, pView
, pDoc
, rReq
)
144 , bFirstObjCreated(false)
145 , bJustEndedEdit(false)
150 rtl::Reference
<FuPoor
> FuText::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
152 rtl::Reference
<FuPoor
> xFunc( new FuText( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
156 void FuText::disposing()
160 if(mpView
->SdrEndTextEdit() == SdrEndTextEditKind::Deleted
)
161 mxTextObj
.reset( nullptr );
163 // reset the RequestHandler of the used Outliner to the handler of the document
164 ::Outliner
* pOutliner
= mpView
->GetTextEditOutliner();
167 pOutliner
->SetStyleSheetPool(static_cast<SfxStyleSheetPool
*>(mpDoc
->GetStyleSheetPool()));
171 /*************************************************************************
173 |* Execute functionality of this class:
175 |* #71422: Start the functionality of this class in this method
176 |* and not in the ctor.
177 |* If you construct an object of this class and you put the
178 |* address of this object to pFuActual you've got a problem,
179 |* because some methods inside DoExecute use the pFuActual-Pointer.
180 |* If the code inside DoExecute is executed inside the ctor,
181 |* the value of pFuActual is not right. And the value will not
182 |* be right until the ctor finished !!!
184 \************************************************************************/
185 void FuText::DoExecute( SfxRequest
& )
187 mpViewShell
->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
188 ToolBarManager::ToolBarGroup::Function
,
189 ToolbarId::Draw_Text_Toolbox_Sd
);
191 mpView
->SetCurrentObj(OBJ_TEXT
);
192 mpView
->SetEditMode(SdrViewEditMode::Edit
);
194 MouseEvent
aMEvt(mpWindow
->GetPointerPosPixel());
196 if (nSlotId
== SID_TEXTEDIT
)
198 // Try to select an object
199 SdrPageView
* pPV
= mpView
->GetSdrPageView();
201 mpView
->PickAnything(aMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
202 mpView
->MarkObj(aVEvt
.pRootObj
, pPV
);
204 mxTextObj
.reset( dynamic_cast< SdrTextObj
* >( aVEvt
.pObj
) );
206 else if (mpView
->AreObjectsMarked())
208 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
210 if (rMarkList
.GetMarkCount() == 1)
212 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
213 mxTextObj
.reset( dynamic_cast< SdrTextObj
* >( pObj
) );
218 if (mpView
->AreObjectsMarked())
220 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
222 if (rMarkList
.GetMarkCount() == 1)
224 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
225 if( pObj
&& (pObj
->GetObjInventor() == SdrInventor::Default
) && (pObj
->GetObjIdentifier() == OBJ_TABLE
) )
227 mpViewShell
->GetViewShellBase().GetToolBarManager()->AddToolBarShell(ToolBarManager::ToolBarGroup::Function
, ToolbarId::Draw_Table_Toolbox
);
232 bool bQuickDrag
= true;
234 const SfxItemSet
* pArgs
= rRequest
.GetArgs();
238 // test for type before using
239 && SID_TEXTEDIT
== nSlotId
240 && SfxItemState::SET
== pArgs
->GetItemState(SID_TEXTEDIT
)
242 && static_cast<const SfxUInt16Item
&>(pArgs
->Get(SID_TEXTEDIT
)).GetValue() == 2)
244 // Selection by doubleclick -> don't allow QuickDrag
248 SetInEditMode(aMEvt
, bQuickDrag
);
251 bool FuText::MouseButtonDown(const MouseEvent
& rMEvt
)
254 bJustEndedEdit
= false;
256 bool bReturn
= FuDraw::MouseButtonDown(rMEvt
);
259 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
261 if (eHit
== SdrHitKind::TextEdit
)
263 // hit text -> SdrView handles event
264 if (mpView
->MouseButtonDown(rMEvt
, mpWindow
))
268 if (rMEvt
.GetClicks() == 1)
270 if (mpView
->IsTextEdit() && eHit
!= SdrHitKind::MarkedObject
&& eHit
!= SdrHitKind::Handle
)
273 if(mpView
->SdrEndTextEdit() == SdrEndTextEditKind::Deleted
)
275 /* Bugfix from MBA: during a double click onto the unused? area
276 in text mode, we get with the second click eHit =
277 SdrHitKind::TextEditObj since it goes to the TextObject which was
278 created with the first click. But this is removed by
279 SdrEndTextEdit since it is empty. But it is still in the mark
280 list. The call MarkObj further below accesses then the dead
281 object. As a simple fix, we determine eHit after
282 SdrEndTextEdit again, this returns then SdrHitKind::NONE. */
283 mxTextObj
.reset( nullptr );
284 eHit
= mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
287 mpView
->SetCurrentObj(OBJ_TEXT
);
288 mpView
->SetEditMode(SdrViewEditMode::Edit
);
291 if (rMEvt
.IsLeft() || rMEvt
.IsRight())
293 mpWindow
->CaptureMouse();
294 SdrPageView
* pPV
= mpView
->GetSdrPageView();
296 if (eHit
== SdrHitKind::TextEdit
)
298 SetInEditMode(rMEvt
, false);
302 // Don't remark table when clicking in it, mark change triggers a lot of updating
303 bool bMarkChanges
= true;
304 rtl::Reference
< sdr::SelectionController
> xSelectionController(mpView
->getSelectionController());
305 if (eHit
== SdrHitKind::TextEditObj
&& xSelectionController
.is())
307 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
308 if (rMarkList
.GetMarkCount() == 1 && rMarkList
.GetMark(0)->GetMarkedSdrObj() == aVEvt
.pRootObj
)
309 bMarkChanges
= false;
312 if (eHit
!= SdrHitKind::Handle
)
314 // deselect selection
315 if (!rMEvt
.IsShift() && eHit
== SdrHitKind::TextEditObj
)
320 mpView
->SetDragMode(SdrDragMode::Move
);
325 if ( aVEvt
.eEvent
== SdrEventKind::ExecuteUrl
||
326 eHit
== SdrHitKind::Handle
||
327 eHit
== SdrHitKind::MarkedObject
||
328 eHit
== SdrHitKind::TextEditObj
||
329 ( eHit
== SdrHitKind::UnmarkedObject
&& bFirstObjCreated
&&
332 // Handle, hit marked or unmarked object
333 if (eHit
== SdrHitKind::TextEditObj
)
335 /* hit text of unmarked object:
336 select object and set to EditMode */
338 mpView
->MarkObj(aVEvt
.pRootObj
, pPV
);
340 if (aVEvt
.pObj
&& dynamic_cast< const SdrTextObj
*>( aVEvt
.pObj
) != nullptr)
342 mxTextObj
.reset( static_cast<SdrTextObj
*>(aVEvt
.pObj
) );
345 SetInEditMode(rMEvt
, true);
347 else if (aVEvt
.eEvent
== SdrEventKind::ExecuteUrl
&& !rMEvt
.IsMod2())
350 mpWindow
->ReleaseMouse();
351 SfxStringItem
aStrItem(SID_FILE_NAME
, aVEvt
.pURLField
->GetURL());
352 SfxStringItem
aReferer(SID_REFERER
, mpDocSh
->GetMedium()->GetName());
353 SfxBoolItem
aBrowseItem( SID_BROWSE
, true );
354 SfxViewFrame
* pFrame
= mpViewShell
->GetViewFrame();
355 mpWindow
->ReleaseMouse();
360 pFrame
->GetDispatcher()->ExecuteList(SID_OPENDOC
,
361 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
,
362 { &aStrItem
, &aBrowseItem
, &aReferer
});
366 // open in current frame
367 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
368 pFrame
->GetDispatcher()->ExecuteList(SID_OPENDOC
,
369 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
,
370 { &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
});
375 // drag object or handle
378 // do the EndTextEdit first, it will delete the handles and force a
379 // recreation. This will make aVEvt.pHdl to point to a deleted handle,
380 // thus it is necessary to reset it and to get it again.
383 // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObject
384 // this caused SdrEndTextEdit() to be called also when not in text editing and
385 // this does not make sense and caused troubles. (see issue 112855)
387 if( mpView
->IsTextEdit() )
389 mpView
->SdrEndTextEdit();
390 bJustEndedEdit
= true;
394 // force new handle identification, the pointer will be dead here
395 // since SdrEndTextEdit has reset (deleted) the handles.
396 aVEvt
.pHdl
= nullptr;
397 mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
403 if( eHit
== SdrHitKind::UnmarkedObject
)
405 if ( !rMEvt
.IsShift() )
408 mpView
->MarkObj(aVEvt
.pRootObj
, pPV
);
412 bFirstMouseMove
= true;
416 if ( ! rMEvt
.IsRight())
418 // we need to pick again since SdrEndTextEdit can rebuild the handles list
419 eHit
= mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
420 if( (eHit
== SdrHitKind::Handle
) || (eHit
== SdrHitKind::MarkedObject
) )
422 sal_uInt16 nDrgLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
423 mpView
->BegDragObj(aMDPos
, nullptr, aVEvt
.pHdl
, nDrgLog
);
429 else if ( nSlotId
!= SID_TEXTEDIT
&&
430 (bPermanent
|| !bFirstObjCreated
) )
433 mpView
->SetCurrentObj(OBJ_TEXT
);
434 mpView
->SetEditMode(SdrViewEditMode::Create
);
435 sal_uInt16 nDrgLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
436 mpView
->BegCreateObj(aMDPos
, nullptr, nDrgLog
);
441 if( !rMEvt
.IsShift() )
444 mpView
->BegMarkObj( aMDPos
);
449 else if ( rMEvt
.GetClicks() == 2 && !mpView
->IsTextEdit() )
451 MouseEvent
aMEvt( mpWindow
->GetPointerPosPixel() );
452 SetInEditMode( aMEvt
, false );
457 ForcePointer(&rMEvt
);
458 mpViewShell
->GetViewFrame()->GetBindings().Invalidate(SidArray
);
464 bool FuText::MouseMove(const MouseEvent
& rMEvt
)
466 bool bReturn
= FuDraw::MouseMove(rMEvt
);
468 if (aDragTimer
.IsActive() )
470 if( bFirstMouseMove
)
471 bFirstMouseMove
= false;
476 if (!bReturn
&& mpView
->IsAction() && !mpDocSh
->IsReadOnly())
478 Point
aPix(rMEvt
.GetPosPixel());
479 Point
aPnt(mpWindow
->PixelToLogic(aPix
));
482 mpView
->MovAction(aPnt
);
485 ForcePointer(&rMEvt
);
490 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj
* pTxtObj
)
492 if(mpDoc
->GetDocumentType() == DocumentType::Impress
)
494 if( nSlotId
== SID_ATTR_CHAR
)
496 /* Create Impress text object (rescales to line height)
497 We get the correct height during the subsequent creation of the
498 object, otherwise we draw to much */
499 SfxItemSet
aSet(mpViewShell
->GetPool());
500 aSet
.Put(makeSdrTextMinFrameHeightItem(0));
501 aSet
.Put(makeSdrTextAutoGrowWidthItem(false));
502 aSet
.Put(makeSdrTextAutoGrowHeightItem(true));
503 pTxtObj
->SetMergedItemSet(aSet
);
504 pTxtObj
->AdjustTextFrameWidthAndHeight();
505 aSet
.Put(makeSdrTextMaxFrameHeightItem(pTxtObj
->GetLogicRect().GetSize().Height()));
506 pTxtObj
->SetMergedItemSet(aSet
);
508 else if( nSlotId
== SID_ATTR_CHAR_VERTICAL
)
510 SfxItemSet
aSet(mpViewShell
->GetPool());
511 aSet
.Put(makeSdrTextMinFrameWidthItem(0));
512 aSet
.Put(makeSdrTextAutoGrowWidthItem(true));
513 aSet
.Put(makeSdrTextAutoGrowHeightItem(false));
515 // Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
516 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
517 pTxtObj
->SetMergedItemSet(aSet
);
518 pTxtObj
->AdjustTextFrameWidthAndHeight();
519 aSet
.Put(makeSdrTextMaxFrameWidthItem(pTxtObj
->GetLogicRect().GetSize().Width()));
520 pTxtObj
->SetMergedItemSet(aSet
);
525 if( nSlotId
== SID_ATTR_CHAR_VERTICAL
)
527 // draw text object, needs to be initialized when vertical text is used
528 SfxItemSet
aSet(mpViewShell
->GetPool());
530 aSet
.Put(makeSdrTextAutoGrowWidthItem(true));
531 aSet
.Put(makeSdrTextAutoGrowHeightItem(false));
533 // Set defaults for vertical click-n'drag text object, pool defaults are:
534 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
535 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
537 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK
));
538 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
540 pTxtObj
->SetMergedItemSet(aSet
);
545 void FuText::ImpSetAttributesFitToSize(SdrTextObj
* pTxtObj
)
547 // FitToSize (fit to frame)
548 SfxItemSet
aSet(mpViewShell
->GetPool(), svl::Items
<SDRATTR_TEXT_AUTOGROWHEIGHT
, SDRATTR_TEXT_AUTOGROWWIDTH
>{});
549 aSet
.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL
));
550 aSet
.Put(makeSdrTextAutoGrowHeightItem(false));
551 aSet
.Put(makeSdrTextAutoGrowWidthItem(false));
552 pTxtObj
->SetMergedItemSet(aSet
);
553 pTxtObj
->AdjustTextFrameWidthAndHeight();
556 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj
* pTxtObj
)
558 SfxItemSet
aSet(mpViewShell
->GetPool(),
559 svl::Items
<SDRATTR_TEXT_AUTOGROWHEIGHT
, SDRATTR_TEXT_AUTOGROWWIDTH
>{});
560 aSet
.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_PROPORTIONAL
));
561 aSet
.Put(makeSdrTextAutoGrowHeightItem(false));
562 aSet
.Put(makeSdrTextAutoGrowWidthItem(false));
563 pTxtObj
->SetMergedItemSet(aSet
);
564 pTxtObj
->AdjustTextFrameWidthAndHeight();
567 void FuText::ImpSetAttributesFitCommon(SdrTextObj
* pTxtObj
)
570 if (mpDoc
->GetDocumentType() == DocumentType::Impress
)
572 if( nSlotId
== SID_ATTR_CHAR
)
574 // Impress text object (rescales to line height)
575 SfxItemSet
aSet(mpViewShell
->GetPool());
576 aSet
.Put(makeSdrTextMinFrameHeightItem(0));
577 aSet
.Put(makeSdrTextMaxFrameHeightItem(0));
578 aSet
.Put(makeSdrTextAutoGrowHeightItem(true));
579 aSet
.Put(makeSdrTextAutoGrowWidthItem(false));
580 pTxtObj
->SetMergedItemSet(aSet
);
582 else if( nSlotId
== SID_ATTR_CHAR_VERTICAL
)
584 SfxItemSet
aSet(mpViewShell
->GetPool());
585 aSet
.Put(makeSdrTextMinFrameWidthItem(0));
586 aSet
.Put(makeSdrTextMaxFrameWidthItem(0));
587 aSet
.Put(makeSdrTextAutoGrowWidthItem(true));
588 aSet
.Put(makeSdrTextAutoGrowHeightItem(false));
589 pTxtObj
->SetMergedItemSet(aSet
);
592 pTxtObj
->AdjustTextFrameWidthAndHeight();
596 bool FuText::MouseButtonUp(const MouseEvent
& rMEvt
)
598 bool bReturn
= false;
599 if (aDragTimer
.IsActive())
602 bIsInDragMode
= false;
605 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArray
);
607 Point
aPnt( mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
609 if( (mpView
&& mpView
->MouseButtonUp(rMEvt
, mpWindow
)) || rMEvt
.GetClicks() == 2 )
610 return true; // handle event from SdrView
612 bool bEmptyTextObj
= false;
620 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
622 if (rMarkList
.GetMarkCount() == 1
623 && ( rMarkList
.GetMark(0)->GetMarkedSdrObj() == mxTextObj
.get()) )
625 if( mxTextObj
.is() && !GetTextObj()->GetOutlinerParaObject() )
626 bEmptyTextObj
= true;
628 bFirstObjCreated
= true;
635 mxTextObj
.reset( nullptr );
639 if( mpView
&& mpView
->IsDragObj())
642 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
643 bool bDragWithCopy
= (rMEvt
.IsMod1() && pFrameView
->IsDragWithCopy());
647 bDragWithCopy
= !mpView
->IsPresObjSelected(false);
650 mpView
->SetDragWithCopy(bDragWithCopy
);
651 mpView
->EndDragObj( mpView
->IsDragWithCopy() );
652 mpView
->ForceMarkedToAnotherPage();
653 mpView
->SetCurrentObj(OBJ_TEXT
);
655 sal_uInt16 nDrgLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
659 bJustEndedEdit
= false;
662 if ((rMEvt
.GetClicks() != 2) &&
663 !rMEvt
.IsShift() && !rMEvt
.IsMod1() && !rMEvt
.IsMod2() && !rMEvt
.IsRight() &&
664 std::abs(aPnt
.X() - aMDPos
.X()) < nDrgLog
&&
665 std::abs(aPnt
.Y() - aMDPos
.Y()) < nDrgLog
)
667 /*************************************************************
668 * From text mode, you don't want to rotate immediately.
669 **************************************************************/
671 SdrObject
* pObj
= mpView
->PickObj(aMDPos
, mpView
->getHitTolLog(), pPV
, SdrSearchOptions::ALSOONMASTER
| SdrSearchOptions::BEFOREMARK
);
674 if (pPV
->IsObjMarkable(pObj
))
676 mpView
->UnmarkAllObj();
677 mpView
->MarkObj(pObj
,pPV
);
683 else if( mpView
&& mpView
->IsCreateObj() && rMEvt
.IsLeft())
685 // object was created
686 mxTextObj
.reset( dynamic_cast< SdrTextObj
* >( mpView
->GetCreateObj() ) );
690 //AW outliner needs to be set to vertical when there is no
691 // outliner object up to now; also it needs to be set back to not
692 // vertical when there was a vertical one used last time.
693 OutlinerParaObject
* pOPO
= GetTextObj()->GetOutlinerParaObject();
694 SdrOutliner
& rOutl(mxTextObj
->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj()));
695 bool bVertical((pOPO
&& pOPO
->IsVertical())
696 || nSlotId
== SID_ATTR_CHAR_VERTICAL
697 || nSlotId
== SID_TEXT_FITTOSIZE_VERTICAL
);
698 rOutl
.SetVertical(bVertical
);
700 // Before ImpSetAttributesForNewTextObject the vertical writing mode
701 // needs to be set at the object. This is done here at the OutlinerParaObject
702 // directly to not mirror the layout text items involved. These items will be set
703 // from ImpSetAttributesForNewTextObject and below.
704 OutlinerParaObject
* pPara
= GetTextObj()->GetOutlinerParaObject();
708 GetTextObj()->ForceOutlinerParaObject();
709 pPara
= GetTextObj()->GetOutlinerParaObject();
712 if(pPara
&& bVertical
!= pPara
->IsVertical())
714 // set ParaObject orientation accordingly
715 pPara
->SetVertical(bVertical
);
718 ImpSetAttributesForNewTextObject(GetTextObj());
721 if (!mpView
->EndCreateObj(SdrCreateCmd::ForceEnd
))
723 // it was not possible to create text object
724 mxTextObj
.reset(nullptr);
726 else if (nSlotId
== SID_TEXT_FITTOSIZE
)
728 ImpSetAttributesFitToSize(GetTextObj());
730 SetInEditMode(rMEvt
, false);
732 else if ( nSlotId
== SID_TEXT_FITTOSIZE_VERTICAL
)
734 ImpSetAttributesFitToSizeVertical(GetTextObj());
736 SetInEditMode(rMEvt
, false);
740 ImpSetAttributesFitCommon(GetTextObj());
742 // thereby the handles and the gray frame are correct
743 mpView
->AdjustMarkHdl();
744 mpView
->PickHandle(aPnt
);
745 SetInEditMode(rMEvt
, false);
748 else if ( mpView
&& mpView
->IsAction())
753 ForcePointer(&rMEvt
);
754 mpWindow
->ReleaseMouse();
755 sal_uInt16 nDrgLog1
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
757 if ( mpView
&& !mpView
->AreObjectsMarked() &&
758 std::abs(aMDPos
.X() - aPnt
.X()) < nDrgLog1
&&
759 std::abs(aMDPos
.Y() - aPnt
.Y()) < nDrgLog1
&&
760 !rMEvt
.IsShift() && !rMEvt
.IsMod2() )
762 SdrPageView
* pPV2
= mpView
->GetSdrPageView();
764 mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
765 mpView
->MarkObj(aVEvt
.pRootObj
, pPV2
);
768 if ( !mxTextObj
.is() && mpView
)
770 if ( ( (!bEmptyTextObj
&& bPermanent
) ||
771 (!bFirstObjCreated
&& !bPermanent
) ) &&
772 !mpDocSh
->IsReadOnly() &&
773 nSlotId
!= SID_TEXTEDIT
)
775 // text body (left-justified AutoGrow)
776 mpView
->SetCurrentObj(OBJ_TEXT
);
777 mpView
->SetEditMode(SdrViewEditMode::Create
);
778 sal_uInt16 nDrgLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
779 mpView
->BegCreateObj(aMDPos
, nullptr, nDrgLog
);
781 bool bSnapEnabled
= mpView
->IsSnapEnabled();
784 mpView
->SetSnapEnabled(false);
786 aPnt
.AdjustX(nDrgLog
+ nDrgLog
);
787 aPnt
.AdjustY(nDrgLog
+ nDrgLog
);
788 mpView
->MovAction(aPnt
);
790 mxTextObj
.reset( dynamic_cast< SdrTextObj
* >( mpView
->GetCreateObj() ) );
794 GetTextObj()->SetDisableAutoWidthOnDragging(true);
797 if(!mpView
->EndCreateObj(SdrCreateCmd::ForceEnd
))
799 mxTextObj
.reset(nullptr);
803 mpView
->SetSnapEnabled(bSnapEnabled
);
807 SfxItemSet
aSet(mpViewShell
->GetPool());
808 aSet
.Put(makeSdrTextMinFrameHeightItem(0));
809 aSet
.Put(makeSdrTextMinFrameWidthItem(0));
810 aSet
.Put(makeSdrTextAutoGrowHeightItem(true));
811 aSet
.Put(makeSdrTextAutoGrowWidthItem(true));
813 if(nSlotId
== SID_ATTR_CHAR_VERTICAL
)
815 // Here, all items which need to be different from pool default need to be set
816 // again on the newly created text object.
817 // Since this is a simple click text object, it is first created, then SetVertical()
818 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
819 // deleted again since not the minimum drag distance was travelled. Then, a new
820 // click text object is created and thus all that stuff needs to be set again here.
822 // Before using the new object the vertical writing mode
823 // needs to be set. This is done here at the OutlinerParaObject
824 // directly to not mirror the layout text items involved. These items will be set
826 OutlinerParaObject
* pPara
= GetTextObj()->GetOutlinerParaObject();
830 GetTextObj()->ForceOutlinerParaObject();
831 pPara
= GetTextObj()->GetOutlinerParaObject();
834 if(pPara
&& !pPara
->IsVertical())
836 // set ParaObject orientation accordingly
837 pPara
->SetVertical(true);
840 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
842 // Analog to the else case below, for vertical simple click texts
843 // one of the default set items from ImpSetAttributesForNewTextObject
844 // needs to be adapted to non-block mode.
845 const SfxItemSet
& rSet
= mpView
->GetDefaultAttr();
846 SvxFrameDirection eDirection
= rSet
.Get(EE_PARA_WRITINGDIR
).GetValue();
848 if(SvxFrameDirection::Horizontal_RL_TB
== eDirection
|| SvxFrameDirection::Vertical_RL_TB
== eDirection
)
850 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM
));
854 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
));
859 // This is for Format/Page settings. Since this also leads
860 // to the object defaults to be changed, i think this code can be
861 // removed. CL. wanted to take a look before adding this.
863 // Look in the object defaults if left-to-right is wanted. If
864 // yes, set text anchoring to right to let the box grow to left.
865 const SfxItemSet
& rSet
= mpView
->GetDefaultAttr();
866 SvxFrameDirection eDirection
= rSet
.Get(EE_PARA_WRITINGDIR
).GetValue();
868 if(SvxFrameDirection::Horizontal_RL_TB
== eDirection
)
870 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
874 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT
));
878 GetTextObj()->SetMergedItemSet(aSet
);
879 GetTextObj()->SetDisableAutoWidthOnDragging(true);
880 SetInEditMode(rMEvt
, false);
883 bFirstObjCreated
= true;
887 // switch to selection
888 if (mpView
->SdrEndTextEdit() == SdrEndTextEditKind::Deleted
)
890 mxTextObj
.reset(nullptr);
893 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT
,
894 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
899 bJustEndedEdit
= false;
903 FuConstruct::MouseButtonUp(rMEvt
);
908 * handle keyboard events
909 * @returns sal_True if the event was handled, sal_False otherwise
911 bool FuText::KeyInput(const KeyEvent
& rKEvt
)
913 bool bReturn
= false;
915 vcl::KeyCode nCode
= rKEvt
.GetKeyCode();
916 bool bShift
= nCode
.IsShift();
920 // maybe object is deleted, test if it's equal to the selected object
921 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
922 SdrObject
* pSelectedObj
= nullptr;
924 if(1 == rMarkList
.GetMarkCount())
926 SdrMark
* pMark
= rMarkList
.GetMark(0);
927 pSelectedObj
= pMark
->GetMarkedSdrObj();
930 if(mxTextObj
.get() != pSelectedObj
)
932 mxTextObj
.reset(nullptr);
936 if ( mxTextObj
.is() && mxTextObj
->GetObjInventor() == SdrInventor::Default
&& mxTextObj
->GetObjIdentifier() == OBJ_TITLETEXT
&& rKEvt
.GetKeyCode().GetCode() == KEY_RETURN
)
938 // title text object: always soft breaks
942 sal_uInt16 nKey
= nCode
.GetCode();
943 vcl::KeyCode
aKeyCode (nKey
, bShift
, nCode
.IsMod1(), nCode
.IsMod2(), nCode
.IsMod3() );
944 KeyEvent
aKEvt(rKEvt
.GetCharCode(), aKeyCode
);
948 if (mpDocSh
->IsReadOnly())
950 bOK
= !EditEngine::DoesKeyChangeText(aKEvt
);
952 if( aKeyCode
.GetCode() == KEY_PAGEUP
|| aKeyCode
.GetCode() == KEY_PAGEDOWN
)
954 bOK
= false; // default handling in base class
957 if (bOK
&& mpView
->KeyInput(aKEvt
, mpWindow
) )
961 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArray
);
964 else if (aKeyCode
== KEY_ESCAPE
)
971 mpView
->SetCurrentObj(OBJ_TEXT
);
972 mpView
->SetEditMode(SdrViewEditMode::Create
);
977 bReturn
= FuDraw::KeyInput(aKEvt
);
983 void FuText::Activate()
985 mpView
->SetQuickTextEditMode(mpViewShell
->GetFrameView()->IsQuickEdit());
987 // #i89661# it's no longer necessary to make it so big here, it's fine tuned
988 // for text objects in SdrMarkView::CheckSingleSdrObjectHit
989 mpView
->SetHitTolerancePixel( 2 * HITPIX
);
991 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
994 pOLV
->ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
996 FuConstruct::Activate();
999 mpView
->SetEditMode(SdrViewEditMode::Edit
);
1002 void FuText::Deactivate()
1004 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
1007 pOLV
->HideCursor(/*bDeactivate=*/true);
1009 mpView
->SetHitTolerancePixel( HITPIX
);
1011 FuConstruct::Deactivate();
1015 * Sets the object into the edit mode.
1017 void FuText::SetInEditMode(const MouseEvent
& rMEvt
, bool bQuickDrag
)
1019 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1020 if( mxTextObj
.is() && (mxTextObj
->GetPage() == pPV
->GetPage()) )
1022 mpView
->SetCurrentObj(OBJ_TEXT
);
1025 mpView
->SetEditMode(SdrViewEditMode::Create
);
1027 mpView
->SetEditMode(SdrViewEditMode::Edit
);
1029 bool bEmptyOutliner
= false;
1031 if (!GetTextObj()->GetOutlinerParaObject() && mpView
->GetTextEditOutliner())
1033 ::Outliner
* pOutl
= mpView
->GetTextEditOutliner();
1034 sal_Int32 nParagraphCnt
= pOutl
->GetParagraphCount();
1035 Paragraph
* p1stPara
= pOutl
->GetParagraph( 0 );
1037 if (nParagraphCnt
==1 && p1stPara
)
1039 // with only one paragraph
1040 if (pOutl
->GetText(p1stPara
).isEmpty())
1042 bEmptyOutliner
= true;
1047 if (GetTextObj() != mpView
->GetTextEditObject() || bEmptyOutliner
)
1049 SdrInventor nInv
= mxTextObj
->GetObjInventor();
1050 sal_uInt16 nSdrObjKind
= mxTextObj
->GetObjIdentifier();
1052 if (nInv
== SdrInventor::Default
&& GetTextObj()->HasTextEdit() &&
1053 (nSdrObjKind
== OBJ_TEXT
||
1054 nSdrObjKind
== OBJ_TITLETEXT
||
1055 nSdrObjKind
== OBJ_OUTLINETEXT
|| !mxTextObj
->IsEmptyPresObj() ) )
1057 // create new outliner (owned by SdrObjEditView)
1058 std::unique_ptr
<SdrOutliner
> pOutl
= SdrMakeOutliner(OutlinerMode::OutlineObject
, *mpDoc
);
1061 mpView
->SdrEndTextEdit(true);
1063 SdrTextObj
* pTextObj
= GetTextObj();
1066 OutlinerParaObject
* pOPO
= pTextObj
->GetOutlinerParaObject();
1067 if( pOPO
&& pOPO
->IsVertical() )
1068 pOutl
->SetVertical( true, pOPO
->IsTopToBottom());
1069 else if (nSlotId
== SID_ATTR_CHAR_VERTICAL
|| nSlotId
== SID_TEXT_FITTOSIZE_VERTICAL
)
1070 pOutl
->SetVertical( true );
1072 if( pTextObj
->getTextCount() > 1 )
1074 Point
aPix(rMEvt
.GetPosPixel());
1075 Point
aPnt(mpWindow
->PixelToLogic(aPix
));
1076 pTextObj
->setActiveText( pTextObj
->CheckTextHit(aPnt
) );
1079 if (mpView
->SdrBeginTextEdit(pTextObj
, pPV
, mpWindow
, true, pOutl
.release()) && mxTextObj
->GetObjInventor() == SdrInventor::Default
)
1081 //tdf#102293 flush overlay before going on to pass clicks down to
1082 //the outline view which will want to paint selections
1083 for (sal_uInt32 b
= 0; b
< pPV
->PageWindowCount(); ++b
)
1085 const SdrPageWindow
& rPageWindow
= *pPV
->GetPageWindow(b
);
1086 if (!rPageWindow
.GetPaintWindow().OutputToWindow())
1088 rtl::Reference
< sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1094 bFirstObjCreated
= true;
1095 DeleteDefaultText();
1097 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
1099 nSdrObjKind
= mxTextObj
->GetObjIdentifier();
1102 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
1104 if (eHit
== SdrHitKind::TextEdit
)
1107 if (nSdrObjKind
== OBJ_TEXT
||
1108 nSdrObjKind
== OBJ_TITLETEXT
||
1109 nSdrObjKind
== OBJ_OUTLINETEXT
||
1110 nSdrObjKind
== OBJ_TABLE
||
1111 nSlotId
== SID_TEXTEDIT
||
1114 pOLV
->MouseButtonDown(rMEvt
);
1115 pOLV
->MouseMove(rMEvt
);
1116 pOLV
->MouseButtonUp(rMEvt
);
1119 if (mpViewShell
->GetFrameView()->IsQuickEdit() && bQuickDrag
&& GetTextObj()->GetOutlinerParaObject())
1121 pOLV
->MouseButtonDown(rMEvt
);
1126 // Move cursor to end of text
1127 ESelection
aNewSelection(EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
, EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
);
1128 if (pOLV
!= nullptr)
1129 pOLV
->SetSelection(aNewSelection
);
1134 mpView
->RestoreDefaultText( mxTextObj
.get() );
1142 mxTextObj
.reset(nullptr);
1147 * Text entry is started, if necessary delete the default text.
1149 void FuText::DeleteDefaultText()
1151 if ( mxTextObj
.is() && mxTextObj
->IsEmptyPresObj() )
1153 SdPage
* pPage
= static_cast<SdPage
*>( mxTextObj
->GetPage() );
1157 PresObjKind ePresObjKind
= pPage
->GetPresObjKind(mxTextObj
.get());
1159 if ( (ePresObjKind
== PRESOBJ_TITLE
||
1160 ePresObjKind
== PRESOBJ_OUTLINE
||
1161 ePresObjKind
== PRESOBJ_NOTES
||
1162 ePresObjKind
== PRESOBJ_TEXT
) &&
1163 !pPage
->IsMasterPage() )
1165 ::Outliner
* pOutliner
= mpView
->GetTextEditOutliner();
1166 SfxStyleSheet
* pSheet
= pOutliner
->GetStyleSheet( 0 );
1167 bool bIsUndoEnabled
= pOutliner
->IsUndoEnabled();
1168 if( bIsUndoEnabled
)
1169 pOutliner
->EnableUndo(false);
1171 pOutliner
->SetText( OUString(), pOutliner
->GetParagraph( 0 ) );
1173 if( bIsUndoEnabled
)
1174 pOutliner
->EnableUndo(true);
1177 (ePresObjKind
== PRESOBJ_NOTES
|| ePresObjKind
== PRESOBJ_TEXT
))
1178 pOutliner
->SetStyleSheet(0, pSheet
);
1180 mxTextObj
->SetEmptyPresObj(true);
1186 bool FuText::RequestHelp(const HelpEvent
& rHEvt
)
1188 bool bReturn
= false;
1190 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
1192 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1193 mxTextObj
.is() && pOLV
&& pOLV
->GetFieldUnderMousePointer())
1196 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldUnderMousePointer();
1197 const SvxFieldData
* pField
= pFieldItem
->GetField();
1199 if (pField
&& dynamic_cast< const SvxURLField
*>( pField
) != nullptr)
1202 aHelpText
= INetURLObject::decode( static_cast<const SvxURLField
*>(pField
)->GetURL(), INetURLObject::DecodeMechanism::WithCharset
);
1204 if (!aHelpText
.isEmpty())
1206 ::tools::Rectangle aLogicPix
= mpWindow
->LogicToPixel(mxTextObj
->GetLogicRect());
1207 ::tools::Rectangle
aScreenRect(mpWindow
->OutputToScreenPixel(aLogicPix
.TopLeft()),
1208 mpWindow
->OutputToScreenPixel(aLogicPix
.BottomRight()));
1210 if (Help::IsBalloonHelpEnabled())
1212 bReturn
= Help::ShowBalloon( static_cast<vcl::Window
*>(mpWindow
), rHEvt
.GetMousePosPixel(), aScreenRect
, aHelpText
);
1214 else if (Help::IsQuickHelpEnabled())
1216 bReturn
= Help::ShowQuickHelp( static_cast<vcl::Window
*>(mpWindow
), aScreenRect
, aHelpText
);
1223 bReturn
= FuConstruct::RequestHelp(rHEvt
);
1229 void FuText::ReceiveRequest(SfxRequest
& rReq
)
1231 nSlotId
= rReq
.GetSlot();
1233 // then we call the base class (besides others, nSlotId is NOT set there)
1234 FuPoor::ReceiveRequest(rReq
);
1236 if (nSlotId
== SID_TEXTEDIT
|| mpViewShell
->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR
== nSlotId
)
1238 MouseEvent
aMEvt(mpWindow
->GetPointerPosPixel());
1240 mxTextObj
.reset(nullptr);
1242 if (nSlotId
== SID_TEXTEDIT
)
1244 // are we currently editing?
1246 mxTextObj
.reset( mpView
->GetTextEditObject() );
1248 if (!mxTextObj
.is())
1250 // Try to select an object
1251 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1253 mpView
->PickAnything(aMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
1254 mpView
->MarkObj(aVEvt
.pRootObj
, pPV
);
1256 if (aVEvt
.pObj
&& dynamic_cast< SdrTextObj
*>( aVEvt
.pObj
) != nullptr)
1258 mxTextObj
.reset( static_cast< SdrTextObj
* >( aVEvt
.pObj
) );
1262 else if (mpView
->AreObjectsMarked())
1264 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
1266 if (rMarkList
.GetMarkCount() == 1)
1268 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
1270 if( dynamic_cast< const SdrTextObj
*>( pObj
) != nullptr)
1272 mxTextObj
.reset( static_cast< SdrTextObj
* >( pObj
) );
1277 bool bQuickDrag
= true;
1279 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1283 // test for type before using
1284 && SID_TEXTEDIT
== nSlotId
1285 && SfxItemState::SET
== pArgs
->GetItemState(SID_TEXTEDIT
)
1287 && static_cast<const SfxUInt16Item
&>( pArgs
->Get(SID_TEXTEDIT
)).GetValue() == 2)
1289 // selection wit double click -> do not allow QuickDrag
1293 SetInEditMode(aMEvt
, bQuickDrag
);
1297 void FuText::DoubleClick(const MouseEvent
& )
1302 /** Removed the insertion of default text and putting a new text
1303 object directly into edit mode.
1305 SdrObject
* FuText::CreateDefaultObject(const sal_uInt16 nID
, const ::tools::Rectangle
& rRectangle
)
1307 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
1308 mpView
->getSdrModelFromSdrView(),
1309 mpView
->GetCurrentObjInventor(),
1310 mpView
->GetCurrentObjIdentifier(),
1315 if( auto pText
= dynamic_cast< SdrTextObj
*>( pObj
) )
1317 pText
->SetLogicRect(rRectangle
);
1319 bool bVertical
= (SID_ATTR_CHAR_VERTICAL
== nID
|| SID_TEXT_FITTOSIZE_VERTICAL
== nID
);
1320 pText
->SetVerticalWriting(bVertical
);
1322 ImpSetAttributesForNewTextObject(pText
);
1324 if (nSlotId
== SID_TEXT_FITTOSIZE
)
1326 ImpSetAttributesFitToSize(pText
);
1328 else if ( nSlotId
== SID_TEXT_FITTOSIZE_VERTICAL
)
1330 ImpSetAttributesFitToSizeVertical(pText
);
1334 ImpSetAttributesFitCommon(pText
);
1337 // Put text object into edit mode.
1338 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1339 mpView
->SdrBeginTextEdit(pText
, pPV
);
1343 OSL_FAIL("Object is NO text object");
1350 /** is called when the current function should be aborted. <p>
1351 This is used when a function gets a KEY_ESCAPE but can also
1354 @returns true if a active function was aborted
1356 bool FuText::cancel()
1358 if ( mpView
->IsTextEdit() )
1360 if(mpView
->SdrEndTextEdit() == SdrEndTextEditKind::Deleted
)
1361 mxTextObj
.reset(nullptr);
1363 mpView
->SetCurrentObj(OBJ_TEXT
);
1364 mpView
->SetEditMode(SdrViewEditMode::Edit
);
1373 void FuText::ChangeFontSize( bool bGrow
, OutlinerView
* pOLV
, const FontList
* pFontList
, ::sd::View
* pView
)
1375 if( !pFontList
|| !pView
)
1380 pOLV
->GetEditView().ChangeFontSize( bGrow
, pFontList
);
1385 pView
->BegUndo(SdResId(bGrow
? STR_GROW_FONT_SIZE
: STR_SHRINK_FONT_SIZE
));
1386 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
1387 for( size_t nMark
= 0; nMark
< rMarkList
.GetMarkCount(); ++nMark
)
1389 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( rMarkList
.GetMark(nMark
)->GetMarkedSdrObj() );
1392 rtl::Reference
<sdr::SelectionController
> xSelectionController(pView
->getSelectionController());
1393 if (xSelectionController
.is() && xSelectionController
->ChangeFontSize(bGrow
, pFontList
))
1397 for( sal_Int32 nText
= 0; nText
< pTextObj
->getTextCount(); nText
++ )
1399 pTextObj
->setActiveText( nText
);
1401 // Put text object into edit mode.
1402 SdrPageView
* pPV
= pView
->GetSdrPageView();
1403 pView
->SdrBeginTextEdit(pTextObj
, pPV
);
1405 pOLV
= pView
->GetTextEditOutlinerView();
1408 EditEngine
* pEditEngine
= pOLV
->GetEditView().GetEditEngine();
1412 aSel
.nEndPara
= pEditEngine
->GetParagraphCount()-1;
1413 aSel
.nEndPos
= pEditEngine
->GetTextLen(aSel
.nEndPara
);
1414 pOLV
->SetSelection(aSel
);
1417 ChangeFontSize( bGrow
, pOLV
, pFontList
, pView
);
1420 pView
->SdrEndTextEdit();
1423 SfxItemSet
aShapeSet( pTextObj
->GetMergedItemSet() );
1424 if( EditView::ChangeFontSize( bGrow
, aShapeSet
, pFontList
) )
1426 pTextObj
->SetObjectItemNoBroadcast( aShapeSet
.Get( EE_CHAR_FONTHEIGHT
) );
1427 pTextObj
->SetObjectItemNoBroadcast( aShapeSet
.Get( EE_CHAR_FONTHEIGHT_CJK
) );
1428 pTextObj
->SetObjectItemNoBroadcast( aShapeSet
.Get( EE_CHAR_FONTHEIGHT_CTL
) );
1436 void FuText::InvalidateBindings()
1438 mpViewShell
->GetViewFrame()->GetBindings().Invalidate(SidArray
);
1442 } // end of namespace sd
1444 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */