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 <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>
56 #include <ViewShell.hxx>
57 #include <ViewShellBase.hxx>
60 #include <drawdoc.hxx>
62 #include <FrameView.hxx>
63 #include <ToolBarManager.hxx>
64 #include <DrawDocShell.hxx>
65 #include <strings.hrc>
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
;
75 static const sal_uInt16 SidArray
[] = {
76 SID_STYLE_FAMILY2
, // 5542
77 SID_STYLE_FAMILY5
, // 5545
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
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)
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
) );
151 void FuText::disposing()
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();
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();
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
) );
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();
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
243 SetInEditMode(aMEvt
, bQuickDrag
);
246 bool FuText::MouseButtonDown(const MouseEvent
& rMEvt
)
249 bJustEndedEdit
= false;
251 bool bReturn
= FuDraw::MouseButtonDown(rMEvt
);
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
))
263 if (rMEvt
.GetClicks() == 1)
265 if (mpView
->IsTextEdit() && eHit
!= SdrHitKind::MarkedObject
&& eHit
!= SdrHitKind::Handle
)
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);
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
)
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
&&
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 */
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())
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();
355 pFrame
->GetDispatcher()->ExecuteList(SID_OPENDOC
,
356 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
,
357 { &aStrItem
, &aBrowseItem
, &aReferer
});
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
});
370 // drag object or handle
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.
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;
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
);
398 if( eHit
== SdrHitKind::UnmarkedObject
)
400 if ( !rMEvt
.IsShift() )
403 mpView
->MarkObj(aVEvt
.pRootObj
, pPV
);
407 bFirstMouseMove
= true;
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
);
424 else if ( nSlotId
!= SID_TEXTEDIT
&&
425 (bPermanent
|| !bFirstObjCreated
) )
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
);
436 if( !rMEvt
.IsShift() )
439 mpView
->BegMarkObj( aMDPos
);
444 else if ( rMEvt
.GetClicks() == 2 && !mpView
->IsTextEdit() )
446 MouseEvent
aMEvt( mpWindow
->GetPointerPosPixel() );
447 SetInEditMode( aMEvt
, false );
452 ForcePointer(&rMEvt
);
453 mpViewShell
->GetViewFrame()->GetBindings().Invalidate(SidArray
);
459 bool FuText::MouseMove(const MouseEvent
& rMEvt
)
461 bool bReturn
= FuDraw::MouseMove(rMEvt
);
463 if (aDragTimer
.IsActive() )
465 if( bFirstMouseMove
)
466 bFirstMouseMove
= false;
471 if (!bReturn
&& mpView
->IsAction() && !mpDocSh
->IsReadOnly())
473 Point
aPix(rMEvt
.GetPosPixel());
474 Point
aPnt(mpWindow
->PixelToLogic(aPix
));
477 mpView
->MovAction(aPnt
);
480 ForcePointer(&rMEvt
);
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
);
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
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
)
565 if (mpDoc
->GetDocumentType() != DocumentType::Impress
)
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())
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;
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;
623 bFirstObjCreated
= true;
630 mxTextObj
.reset(nullptr);
634 if( mpView
&& mpView
->IsDragObj())
637 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
638 bool bDragWithCopy
= (rMEvt
.IsMod1() && pFrameView
->IsDragWithCopy());
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() );
654 bJustEndedEdit
= false;
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 **************************************************************/
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
);
675 else if( mpView
&& mpView
->IsCreateObj() && rMEvt
.IsLeft())
677 // object was created
678 mxTextObj
.reset( dynamic_cast< SdrTextObj
* >( mpView
->GetCreateObj() ) );
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();
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);
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())
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();
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();
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() ) );
786 GetTextObj()->SetDisableAutoWidthOnDragging(true);
789 if(!mpView
->EndCreateObj(SdrCreateCmd::ForceEnd
))
791 mxTextObj
.reset(nullptr);
795 mpView
->SetSnapEnabled(bSnapEnabled
);
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
818 OutlinerParaObject
* pPara
= GetTextObj()->GetOutlinerParaObject();
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
));
846 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
));
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
));
866 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT
));
870 GetTextObj()->SetMergedItemSet(aSet
);
871 GetTextObj()->SetDisableAutoWidthOnDragging(true);
872 SetInEditMode(rMEvt
, false);
875 bFirstObjCreated
= true;
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
);
891 bJustEndedEdit
= false;
895 FuConstruct::MouseButtonUp(rMEvt
);
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();
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
934 sal_uInt16 nKey
= nCode
.GetCode();
935 vcl::KeyCode
aKeyCode (nKey
, bShift
, nCode
.IsMod1(), nCode
.IsMod2(), nCode
.IsMod3() );
936 KeyEvent
aKEvt(rKEvt
.GetCharCode(), aKeyCode
);
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
) )
953 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArray
);
956 else if (aKeyCode
== KEY_ESCAPE
)
963 mpView
->SetCurrentObj(OBJ_TEXT
);
964 mpView
->SetEditMode(SdrViewEditMode::Create
);
969 bReturn
= FuDraw::KeyInput(aKEvt
);
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();
986 pOLV
->ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
988 FuConstruct::Activate();
991 mpView
->SetEditMode(SdrViewEditMode::Edit
);
994 void FuText::Deactivate()
996 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
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
);
1017 mpView
->SetEditMode(SdrViewEditMode::Create
);
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
);
1053 mpView
->SdrEndTextEdit(true);
1055 SdrTextObj
* pTextObj
= GetTextObj();
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())
1080 const rtl::Reference
< sdr::overlay::OverlayManager
>& xManager
= rPageWindow
.GetOverlayManager();
1086 bFirstObjCreated
= true;
1087 DeleteDefaultText();
1089 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
1091 nSdrObjKind
= mxTextObj
->GetObjIdentifier();
1094 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SdrMouseEventKind::BUTTONDOWN
, aVEvt
);
1096 if (eHit
== SdrHitKind::TextEdit
)
1099 if (nSdrObjKind
== OBJ_TEXT
||
1100 nSdrObjKind
== OBJ_TITLETEXT
||
1101 nSdrObjKind
== OBJ_OUTLINETEXT
||
1102 nSdrObjKind
== OBJ_TABLE
||
1103 nSlotId
== SID_TEXTEDIT
||
1106 pOLV
->MouseButtonDown(rMEvt
);
1107 pOLV
->MouseMove(rMEvt
);
1108 pOLV
->MouseButtonUp(rMEvt
);
1111 if (mpViewShell
->GetFrameView()->IsQuickEdit() && bQuickDrag
&& GetTextObj()->GetOutlinerParaObject())
1113 pOLV
->MouseButtonDown(rMEvt
);
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
);
1126 mpView
->RestoreDefaultText( mxTextObj
.get() );
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()) )
1146 SdPage
* pPage
= static_cast<SdPage
*>( mxTextObj
->getSdrPageFromSdrObject() );
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()) )
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);
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())
1188 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldUnderMousePointer();
1189 const SvxFieldData
* pField
= pFieldItem
->GetField();
1191 if (auto pURLField
= dynamic_cast< const SvxURLField
*>( pField
))
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
);
1207 else if (Help::IsQuickHelpEnabled())
1209 Help::ShowQuickHelp( static_cast<vcl::Window
*>(mpWindow
), aScreenRect
, aHelpText
);
1217 bReturn
= FuConstruct::RequestHelp(rHEvt
);
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
))
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();
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();
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
1287 SetInEditMode(aMEvt
, bQuickDrag
);
1290 void FuText::DoubleClick(const MouseEvent
& )
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(),
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
);
1327 ImpSetAttributesFitCommon(pText
);
1330 // Put text object into edit mode.
1331 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1332 mpView
->SdrBeginTextEdit(pText
, pPV
);
1336 OSL_FAIL("Object is NO text object");
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
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
);
1366 void FuText::ChangeFontSize( bool bGrow
, OutlinerView
* pOLV
, const FontList
* pFontList
, ::sd::View
* pView
)
1368 if( !pFontList
|| !pView
)
1373 pOLV
->GetEditView().ChangeFontSize( bGrow
, pFontList
);
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() );
1385 rtl::Reference
<sdr::SelectionController
> xSelectionController(pView
->getSelectionController());
1386 if (xSelectionController
.is() && xSelectionController
->ChangeFontSize(bGrow
, pFontList
))
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();
1401 EditEngine
* pEditEngine
= pOLV
->GetEditView().GetEditEngine();
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
) );
1429 void FuText::InvalidateBindings()
1431 mpViewShell
->GetViewFrame()->GetBindings().Invalidate(SidArray
);
1435 } // end of namespace sd
1437 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */