bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / func / futext.cxx
blobaedeae6bda4d394d5c37fe4d71511e961f55207b
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 <editeng/editerr.hxx>
23 #include <svx/dlgutil.hxx>
24 #include <svx/svxerr.hxx>
25 #include <tools/urlobj.hxx>
26 #include <vcl/help.hxx>
27 #include <editeng/editstat.hxx>
28 #include <svl/aeitem.hxx>
29 #include <svl/intitem.hxx>
30 #include <svx/svdotext.hxx>
31 #include <svx/svdogrp.hxx>
32 #include <editeng/flditem.hxx>
33 #include <svl/style.hxx>
34 #include <svx/svdpagv.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/bindings.hxx>
38 #include <sfx2/request.hxx>
39 #include <editeng/editeng.hxx>
40 #include <svx/svdoutl.hxx>
41 #include <svx/svxids.hrc>
42 #include <sfx2/docfile.hxx>
43 #include <comphelper/processfactory.hxx>
44 #include <editeng/outlobj.hxx>
45 #include <svtools/langtab.hxx>
47 #include <editeng/frmdiritem.hxx>
49 #include <svx/svdetc.hxx>
50 #include <editeng/editview.hxx>
52 #include "sdresid.hxx"
53 #include "app.hrc"
54 #include "res_bmp.hrc"
55 #include "ViewShell.hxx"
56 #include "ViewShellBase.hxx"
57 #include "View.hxx"
58 #include "Outliner.hxx"
59 #include "Window.hxx"
60 #include "drawdoc.hxx"
61 #include "sdpage.hxx"
62 #include "sdmod.hxx"
63 #include "FrameView.hxx"
64 #include "ToolBarManager.hxx"
65 #include "DrawDocShell.hxx"
66 #include "glob.hrc"
67 #include "pres.hxx"
68 #include "optsitem.hxx"
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::lang;
73 using namespace ::com::sun::star::linguistic2;
75 namespace sd {
77 static sal_uInt16 SidArray[] = {
78 SID_STYLE_FAMILY2, // 5542
79 SID_STYLE_FAMILY5, // 5545
80 SID_REDO, // 5700
81 SID_UNDO, // 5701
82 SID_CUT, // 5710
83 SID_COPY, // 5711
84 SID_ATTR_TABSTOP, // 10002
85 SID_ATTR_CHAR_FONT, // 10007
86 SID_ATTR_CHAR_POSTURE, // 10008
87 SID_ATTR_CHAR_WEIGHT, // 10009
88 SID_ATTR_CHAR_SHADOWED, //10010
89 SID_ATTR_CHAR_STRIKEOUT, //10013
90 SID_ATTR_CHAR_UNDERLINE, // 10014
91 SID_ATTR_CHAR_FONTHEIGHT, // 10015
92 SID_ATTR_CHAR_COLOR, // 10017
93 SID_ATTR_CHAR_KERNING, //10018
94 SID_ATTR_PARA_ADJUST_LEFT, // 10028
95 SID_ATTR_PARA_ADJUST_RIGHT, // 10029
96 SID_ATTR_PARA_ADJUST_CENTER, // 10030
97 SID_ATTR_PARA_ADJUST_BLOCK, // 10031
98 SID_ATTR_PARA_LINESPACE_10, // 10034
99 SID_ATTR_PARA_LINESPACE_15, // 10035
100 SID_ATTR_PARA_LINESPACE_20, // 10036
101 SID_ATTR_PARA_ULSPACE, // 10042
102 SID_ATTR_PARA_LRSPACE, // 10043
103 SID_ATTR_TRANSFORM_POS_X, // 10088
104 SID_ATTR_TRANSFORM_POS_Y, // 10089
105 SID_ATTR_TRANSFORM_WIDTH, // 10090
106 SID_ATTR_TRANSFORM_HEIGHT,// 10091
107 SID_ATTR_TRANSFORM_ROT_X, // 10093
108 SID_ATTR_TRANSFORM_ROT_Y, // 10094
109 SID_ATTR_TRANSFORM_ANGLE, // 10095 //Added
110 SID_OUTLINE_UP, // 10150
111 SID_OUTLINE_DOWN, // 10151
112 SID_OUTLINE_LEFT, // 10152
113 SID_OUTLINE_RIGHT, // 10153
114 SID_ATTR_TRANSFORM_PROTECT_POS,// 10236
115 SID_ATTR_TRANSFORM_PROTECT_SIZE,// 10237 //Added
116 SID_FORMTEXT_STYLE, // 10257
117 SID_SET_SUPER_SCRIPT, // 10294
118 SID_SET_SUB_SCRIPT, // 10295
119 SID_ATTR_TRANSFORM_AUTOWIDTH,// 10310
120 SID_ATTR_TRANSFORM_AUTOHEIGHT,// 10311 //Added
121 SID_HYPERLINK_GETLINK, // 10361
122 SID_CHARMAP, // 10503
123 SID_TEXTDIRECTION_LEFT_TO_RIGHT, // 10907
124 SID_TEXTDIRECTION_TOP_TO_BOTTOM, // 10908
125 SID_ATTR_PARA_LEFT_TO_RIGHT, // 10950
126 SID_ATTR_PARA_RIGHT_TO_LEFT, // 10951
127 SID_PARASPACE_INCREASE, // 11145
128 SID_PARASPACE_DECREASE, // 11146
129 FN_NUM_BULLET_ON, // 20138
130 0 };
132 TYPEINIT1( FuText, FuConstruct );
134 static bool bTestText = false;
137 * base class for text functions
139 FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
140 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
141 , bFirstObjCreated(false)
142 , bJustEndedEdit(false)
143 , rRequest (rReq)
147 rtl::Reference<FuPoor> FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
149 rtl::Reference<FuPoor> xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
150 return xFunc;
153 /** Destruktor */
154 void FuText::disposing()
156 if(mpView)
158 if(mpView->SdrEndTextEdit(false) == SDRENDTEXTEDIT_DELETED)
159 mxTextObj.reset( 0 );
161 // reset the RequestHandler of the used Outliner to the handler of the document
162 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
164 if (pOutliner)
165 pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
169 /*************************************************************************
171 |* Execute functionality of this class:
173 |* #71422: Start the functionality of this class in this method
174 |* and not in the ctor.
175 |* If you construct an object of this class and you put the
176 |* address of this object to pFuActual you've got a problem,
177 |* because some methods inside DoExecute use the pFuActual-Pointer.
178 |* If the code inside DoExecute is executed inside the ctor,
179 |* the value of pFuActual is not right. And the value will not
180 |* be right until the ctor finished !!!
182 \************************************************************************/
183 void FuText::DoExecute( SfxRequest& )
185 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
186 ToolBarManager::TBG_FUNCTION,
187 RID_DRAW_TEXT_TOOLBOX);
189 mpView->SetCurrentObj(OBJ_TEXT);
190 mpView->SetEditMode(SDREDITMODE_EDIT);
192 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
194 if (nSlotId == SID_TEXTEDIT)
196 // Try to select an object
197 SdrPageView* pPV = mpView->GetSdrPageView();
198 SdrViewEvent aVEvt;
199 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
200 mpView->MarkObj(aVEvt.pRootObj, pPV);
202 mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
204 else if (mpView->AreObjectsMarked())
206 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
208 if (rMarkList.GetMarkCount() == 1)
210 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
211 mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
215 // check for table
216 if (mpView->AreObjectsMarked())
218 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
220 if (rMarkList.GetMarkCount() == 1)
222 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
223 if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
225 mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX );
230 bool bQuickDrag = true;
232 const SfxItemSet* pArgs = rRequest.GetArgs();
234 if (pArgs
236 // test for type before using
237 && SID_TEXTEDIT == nSlotId
238 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
240 && (sal_uInt16)static_cast<const SfxUInt16Item&>(pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
242 // Selection by doubleclick -> don't allow QuickDrag
243 bQuickDrag = false;
246 SetInEditMode(aMEvt, bQuickDrag);
249 bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
251 bMBDown = true;
252 bJustEndedEdit = false;
254 bool bReturn = FuDraw::MouseButtonDown(rMEvt);
256 mpView->SetMarkHdlWhenTextEdit(true);
257 SdrViewEvent aVEvt;
258 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
260 if (eHit == SDRHIT_TEXTEDIT)
262 // hit text -> SdrView handles event
263 if (mpView->MouseButtonDown(rMEvt, mpWindow))
264 return true;
267 if (rMEvt.GetClicks() == 1)
269 if (mpView->IsTextEdit() && eHit != SDRHIT_MARKEDOBJECT && eHit != SDRHIT_HANDLE)
271 // finish text input
272 if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
274 /* Bugfix from MBA: during a double click onto the unused? area
275 in text mode, we get with the second click eHit =
276 SDRHIT_TEXTEDITOBJ since it goes to the TextObject which was
277 created with the first click. But this is removed by
278 SdrEndTextEdit since it is empty. But it is still in the mark
279 list. The call MarkObj further below accesses then the dead
280 object. As a simple fix, we determine eHit after
281 SdrEndTextEdit again, this returns then SDRHIT_NONE. */
282 mxTextObj.reset( NULL );
283 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
286 mpView->SetCurrentObj(OBJ_TEXT);
287 mpView->SetEditMode(SDREDITMODE_EDIT);
290 if (rMEvt.IsLeft() || rMEvt.IsRight())
292 mpWindow->CaptureMouse();
293 SdrPageView* pPV = mpView->GetSdrPageView();
295 if (eHit == SDRHIT_TEXTEDIT)
297 SetInEditMode(rMEvt, false);
299 else
301 if (eHit != SDRHIT_HANDLE)
303 // deselect selection
304 if (!rMEvt.IsShift() && eHit == SDRHIT_TEXTEDITOBJ)
306 mpView->UnmarkAll();
307 mpView->SetDragMode(SDRDRAG_MOVE);
311 if ( aVEvt.eEvent == SDREVENT_EXECUTEURL ||
312 eHit == SDRHIT_HANDLE ||
313 eHit == SDRHIT_MARKEDOBJECT ||
314 eHit == SDRHIT_TEXTEDITOBJ ||
315 ( eHit == SDRHIT_UNMARKEDOBJECT && bFirstObjCreated &&
316 !bPermanent ) )
318 // Handle, hit marked or umarked object
319 if (eHit == SDRHIT_TEXTEDITOBJ)
321 /* hit text of unmarked object:
322 select object and set to EditMode */
323 mpView->MarkObj(aVEvt.pRootObj, pPV);
325 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
327 mxTextObj.reset( static_cast<SdrTextObj*>(aVEvt.pObj) );
330 SetInEditMode(rMEvt, true);
332 else if (aVEvt.eEvent == SDREVENT_EXECUTEURL && !rMEvt.IsMod2())
334 // execute URL
335 mpWindow->ReleaseMouse();
336 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
337 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
338 SfxBoolItem aBrowseItem( SID_BROWSE, true );
339 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
340 mpWindow->ReleaseMouse();
342 if (rMEvt.IsMod1())
344 // open in new frame
345 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
346 &aStrItem, &aBrowseItem, &aReferer, 0L);
348 else
350 // open in current frame
351 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
352 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
353 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
356 else
358 // drag object or handle
360 // #i78748#
361 // do the EndTextEdit first, it will delete the handles and force a
362 // recreation. This will make aVEvt.pHdl to point to a deleted handle,
363 // thus it is necessary to reset it and to get it again.
365 // #i112855#
366 // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObjet
367 // this caused SdrEndTextEdit() to be called also when not in text editing and
368 // this does not make sense and caused troubles. (see issue 112855)
370 if( mpView->IsTextEdit() )
372 mpView->SdrEndTextEdit();
373 bJustEndedEdit = true;
375 if(aVEvt.pHdl)
377 // force new handle identification, the pointer will be dead here
378 // since SdrEndTextEdit has resetted (deleted) the handles.
379 aVEvt.pHdl = 0;
380 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
384 if (!aVEvt.pHdl)
386 if( eHit == SDRHIT_UNMARKEDOBJECT )
388 if ( !rMEvt.IsShift() )
389 mpView->UnmarkAll();
391 mpView->MarkObj(aVEvt.pRootObj, pPV);
394 // Drag object
395 bFirstMouseMove = true;
396 aDragTimer.Start();
399 if ( ! rMEvt.IsRight())
401 // we need to pick again since SdrEndTextEdit can rebuild the handles list
402 eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
403 if( (eHit == SDRHIT_HANDLE) || (eHit == SDRHIT_MARKEDOBJECT) )
405 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
406 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
409 bReturn = true;
412 else if ( nSlotId != SID_TEXTEDIT &&
413 (bPermanent || !bFirstObjCreated) )
415 // create object
416 mpView->SetCurrentObj(OBJ_TEXT);
417 mpView->SetEditMode(SDREDITMODE_CREATE);
418 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
419 mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
421 else
423 // select
424 if( !rMEvt.IsShift() )
425 mpView->UnmarkAll();
427 mpView->BegMarkObj( aMDPos );
432 else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
434 MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
435 SetInEditMode( aMEvt, false );
438 if (!bIsInDragMode)
440 ForcePointer(&rMEvt);
441 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
444 return bReturn;
447 bool FuText::MouseMove(const MouseEvent& rMEvt)
449 bool bReturn = FuDraw::MouseMove(rMEvt);
451 if (aDragTimer.IsActive() )
453 if( bFirstMouseMove )
454 bFirstMouseMove = false;
455 else
456 aDragTimer.Stop();
459 if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
461 Point aPix(rMEvt.GetPosPixel());
462 Point aPnt(mpWindow->PixelToLogic(aPix));
464 ForceScroll(aPix);
465 mpView->MovAction(aPnt);
468 ForcePointer(&rMEvt);
470 return bReturn;
473 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
475 if(mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
477 if( nSlotId == SID_ATTR_CHAR )
479 /* Create Impress text object (rescales to line height)
480 We get the correct height during the subsequent creation of the
481 object, otherwise we draw to much */
482 SfxItemSet aSet(mpViewShell->GetPool());
483 aSet.Put(makeSdrTextMinFrameHeightItem(0));
484 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
485 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
486 pTxtObj->SetMergedItemSet(aSet);
487 pTxtObj->AdjustTextFrameWidthAndHeight();
488 aSet.Put(makeSdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
489 pTxtObj->SetMergedItemSet(aSet);
491 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
493 SfxItemSet aSet(mpViewShell->GetPool());
494 aSet.Put(makeSdrTextMinFrameWidthItem(0));
495 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
496 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
498 // Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
499 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
500 pTxtObj->SetMergedItemSet(aSet);
501 pTxtObj->AdjustTextFrameWidthAndHeight();
502 aSet.Put(makeSdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
503 pTxtObj->SetMergedItemSet(aSet);
506 else
508 if( nSlotId == SID_ATTR_CHAR_VERTICAL )
510 // draw text object, needs to be initialized when vertical text is used
511 SfxItemSet aSet(mpViewShell->GetPool());
513 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
514 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
516 // Set defaults for vertical click-n'drag text object, pool defaults are:
517 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
518 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
519 // Analog to that:
520 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
521 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
523 pTxtObj->SetMergedItemSet(aSet);
528 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
530 // FitToSize (fit to frame)
531 SfxItemSet aSet(mpViewShell->GetPool(), SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
532 SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
533 aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
534 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
535 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
536 pTxtObj->SetMergedItemSet(aSet);
537 pTxtObj->AdjustTextFrameWidthAndHeight();
540 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
542 SfxItemSet aSet(mpViewShell->GetPool(),
543 SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
544 SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
545 aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
546 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
547 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
548 pTxtObj->SetMergedItemSet(aSet);
549 pTxtObj->AdjustTextFrameWidthAndHeight();
552 void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
554 // Normal Textobject
555 if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
557 if( nSlotId == SID_ATTR_CHAR )
559 // Impress text object (rescales to line height)
560 SfxItemSet aSet(mpViewShell->GetPool());
561 aSet.Put(makeSdrTextMinFrameHeightItem(0));
562 aSet.Put(makeSdrTextMaxFrameHeightItem(0));
563 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
564 aSet.Put(makeSdrTextAutoGrowWidthItem(false));
565 pTxtObj->SetMergedItemSet(aSet);
567 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
569 SfxItemSet aSet(mpViewShell->GetPool());
570 aSet.Put(makeSdrTextMinFrameWidthItem(0));
571 aSet.Put(makeSdrTextMaxFrameWidthItem(0));
572 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
573 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
574 pTxtObj->SetMergedItemSet(aSet);
577 pTxtObj->AdjustTextFrameWidthAndHeight();
581 bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
583 bool bReturn = false;
584 SdrObject* pObj;
585 SdrPageView* pPV;
586 if (aDragTimer.IsActive())
588 aDragTimer.Stop();
589 bIsInDragMode = false;
592 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
594 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
596 if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
597 return true; // handle event from SdrView
599 bool bEmptyTextObj = false;
601 if (mxTextObj.is())
603 bool bReset = true;
605 if (mpView)
607 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
609 if (rMarkList.GetMarkCount() == 1
610 && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
612 if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
613 bEmptyTextObj = true;
614 else
615 bFirstObjCreated = true;
616 bReset = false;
620 if (bReset)
622 mxTextObj.reset( 0 );
626 if( mpView && mpView->IsDragObj())
628 // object was moved
629 FrameView* pFrameView = mpViewShell->GetFrameView();
630 bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
632 if (bDragWithCopy)
634 bDragWithCopy = !mpView->IsPresObjSelected(false, true);
637 mpView->SetDragWithCopy(bDragWithCopy);
638 mpView->EndDragObj( mpView->IsDragWithCopy() );
639 mpView->ForceMarkedToAnotherPage();
640 mpView->SetCurrentObj(OBJ_TEXT);
642 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
644 if (bJustEndedEdit)
646 bJustEndedEdit = false;
647 FuPoor::cancel();
649 if ((rMEvt.GetClicks() != 2) &&
650 !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
651 std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
652 std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
654 /*************************************************************
655 * From text mode, you don't want to rotate immediately.
656 **************************************************************/
657 if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK))
659 if (pPV->IsObjSelectable(pObj))
661 mpView->UnmarkAllObj();
662 mpView->MarkObj(pObj,pPV,false,false);
663 return bReturn;
668 else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
670 // object was created
671 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
673 if( mxTextObj.is() )
675 //AW outliner needs to be set to vertical when there is no
676 // outliner object up to now; also it needs to be set back to not
677 // vertical when there was a vertical one used last time.
678 OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
679 SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj());
680 bool bVertical((pOPO && pOPO->IsVertical())
681 || nSlotId == SID_ATTR_CHAR_VERTICAL
682 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
683 rOutl.SetVertical(bVertical);
685 // Before ImpSetAttributesForNewTextObject the vertical writing mode
686 // needs to be set at the object. This is done here at the OutlinerParaObject
687 // directly to not mirror the layout text items involved. These items will be set
688 // from ImpSetAttributesForNewTextObject and below.
689 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
691 if(!pPara)
693 GetTextObj()->ForceOutlinerParaObject();
694 pPara = GetTextObj()->GetOutlinerParaObject();
697 if(pPara && (bool)bVertical != pPara->IsVertical())
699 // set ParaObject orientation accordingly
700 pPara->SetVertical(bVertical);
703 ImpSetAttributesForNewTextObject(GetTextObj());
706 if (!mpView->EndCreateObj(SDRCREATE_FORCEEND))
708 // it was not possible to create text object
709 mxTextObj.reset(0);
711 else if (nSlotId == SID_TEXT_FITTOSIZE)
713 ImpSetAttributesFitToSize(GetTextObj());
715 SetInEditMode(rMEvt, false);
717 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
719 ImpSetAttributesFitToSizeVertical(GetTextObj());
721 SetInEditMode(rMEvt, false);
723 else
725 ImpSetAttributesFitCommon(GetTextObj());
727 // thereby the handles and the gray frame are correct
728 mpView->AdjustMarkHdl();
729 mpView->PickHandle(aPnt);
730 SetInEditMode(rMEvt, false);
733 else if ( mpView && mpView->IsAction())
735 mpView->EndAction();
738 ForcePointer(&rMEvt);
739 mpWindow->ReleaseMouse();
740 sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
742 if ( mpView && !mpView->AreObjectsMarked() &&
743 std::abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
744 std::abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
745 !rMEvt.IsShift() && !rMEvt.IsMod2() )
747 SdrPageView* pPV2 = mpView->GetSdrPageView();
748 SdrViewEvent aVEvt;
749 mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
750 mpView->MarkObj(aVEvt.pRootObj, pPV2);
753 if ( !mxTextObj.is() && mpView )
755 if ( ( (!bEmptyTextObj && bPermanent) ||
756 (!bFirstObjCreated && !bPermanent) ) &&
757 !mpDocSh->IsReadOnly() &&
758 nSlotId != SID_TEXTEDIT )
760 // text body (left-justified AutoGrow)
761 mpView->SetCurrentObj(OBJ_TEXT);
762 mpView->SetEditMode(SDREDITMODE_CREATE);
763 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
764 mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
766 bool bSnapEnabled = mpView->IsSnapEnabled();
768 if (bSnapEnabled)
769 mpView->SetSnapEnabled(false);
771 aPnt.X() += nDrgLog + nDrgLog;
772 aPnt.Y() += nDrgLog + nDrgLog;
773 mpView->MovAction(aPnt);
775 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
777 if(mxTextObj.is())
779 GetTextObj()->SetDisableAutoWidthOnDragging(true);
782 if(!mpView->EndCreateObj(SDRCREATE_FORCEEND))
784 mxTextObj.reset(0);
787 if(bSnapEnabled)
788 mpView->SetSnapEnabled(bSnapEnabled);
790 if(mxTextObj.is())
792 SfxItemSet aSet(mpViewShell->GetPool());
793 aSet.Put(makeSdrTextMinFrameHeightItem(0));
794 aSet.Put(makeSdrTextMinFrameWidthItem(0));
795 aSet.Put(makeSdrTextAutoGrowHeightItem(true));
796 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
798 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
800 // Here, all items which need to be different from pool default need to be set
801 // again on the newly created text object.
802 // Since this is a simple click text object, it is first created, then SetVertical()
803 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
804 // deleted again since not the minimum drag distance was travelled. Then, a new
805 // click text object is created and thus all that stuff needs to be set again here.
807 // Before using the new object the vertical writing mode
808 // needs to be set. This is done here at the OutlinerParaObject
809 // directly to not mirror the layout text items involved. These items will be set
810 // below.
811 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
813 if(!pPara)
815 GetTextObj()->ForceOutlinerParaObject();
816 pPara = GetTextObj()->GetOutlinerParaObject();
819 if(pPara && !pPara->IsVertical())
821 // set ParaObject orientation accordingly
822 pPara->SetVertical(true);
825 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
827 // Analog to the else case below, for vertical simple click texts
828 // one of the defaulted setted items from ImpSetAttributesForNewTextObject
829 // needs to be adapted to non-block mode.
830 const SfxItemSet& rSet = mpView->GetDefaultAttr();
831 SvxFrameDirection eDirection = (SvxFrameDirection)static_cast<const SvxFrameDirectionItem&>(rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
833 if(FRMDIR_HORI_RIGHT_TOP == eDirection || FRMDIR_VERT_TOP_RIGHT == eDirection)
835 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
837 else
839 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
842 else
844 // This is for Format/Page settings. Since this also leads
845 // to the object defaults to be changed, i think this code can be
846 // removed. CL. wanted to take a look before adding this.
848 // Look in the object defaults if left-to-right is wanted. If
849 // yes, set text anchoring to right to let the box grow to left.
850 const SfxItemSet& rSet = mpView->GetDefaultAttr();
851 SvxFrameDirection eDirection = (SvxFrameDirection)static_cast<const SvxFrameDirectionItem&>(rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
853 if(FRMDIR_HORI_RIGHT_TOP == eDirection)
855 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
857 else
859 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
863 GetTextObj()->SetMergedItemSet(aSet);
864 GetTextObj()->SetDisableAutoWidthOnDragging(true);
865 SetInEditMode(rMEvt, false);
868 bFirstObjCreated = true;
870 else
872 // switch to selection
873 if (mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
875 mxTextObj.reset(0);
878 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
879 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
882 if (bJustEndedEdit)
884 bJustEndedEdit = false;
885 FuPoor::cancel();
887 bMBDown = false;
888 FuConstruct::MouseButtonUp(rMEvt);
889 return bReturn;
893 * handle keyboard events
894 * @returns sal_True if the event was handled, sal_False otherwise
896 bool FuText::KeyInput(const KeyEvent& rKEvt)
898 bool bReturn = false;
899 mpView->SetMarkHdlWhenTextEdit(true);
901 vcl::KeyCode nCode = rKEvt.GetKeyCode();
902 bool bShift = nCode.IsShift();
904 if(mxTextObj.is())
906 // maybe object is deleted, test if it's equal to the selected object
907 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
908 SdrObject* pSelectedObj = 0L;
910 if(1 == rMarkList.GetMarkCount())
912 SdrMark* pMark = rMarkList.GetMark(0);
913 pSelectedObj = pMark->GetMarkedSdrObj();
916 if(mxTextObj.get() != pSelectedObj)
918 mxTextObj.reset(0);
922 if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
924 // title text object: always soft breaks
925 bShift = true;
928 sal_uInt16 nKey = nCode.GetCode();
929 vcl::KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
930 KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
932 bool bOK = true;
934 if (mpDocSh->IsReadOnly())
936 bOK = !EditEngine::DoesKeyChangeText(aKEvt);
938 if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
940 bOK = false; // default handling in base class
943 if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
945 bReturn = true;
947 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
950 else if (aKeyCode == KEY_ESCAPE)
952 bReturn = cancel();
955 if( bPermanent )
957 mpView->SetCurrentObj(OBJ_TEXT);
958 mpView->SetEditMode(SDREDITMODE_CREATE);
961 if (!bReturn)
963 bReturn = FuDraw::KeyInput(aKEvt);
966 return bReturn;
969 void FuText::Activate()
971 mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
973 // #i89661# it's no longer necessary to make it so big here, it's fine tuned
974 // for text objects in SdrMarkView::CheckSingleSdrObjectHit
975 mpView->SetHitTolerancePixel( 2 * HITPIX );
977 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
979 if (pOLV)
980 pOLV->ShowCursor();
982 FuConstruct::Activate();
984 if( pOLV )
985 mpView->SetEditMode(SDREDITMODE_EDIT);
988 void FuText::Deactivate()
990 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
992 if (pOLV)
993 pOLV->HideCursor();
995 mpView->SetHitTolerancePixel( HITPIX );
997 FuConstruct::Deactivate();
1001 * Sets the object into the edit mode.
1003 void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
1005 SdrPageView* pPV = mpView->GetSdrPageView();
1006 if( mxTextObj.is() && (mxTextObj->GetPage() == pPV->GetPage()) )
1008 mpView->SetCurrentObj(OBJ_TEXT);
1010 if( bPermanent )
1011 mpView->SetEditMode(SDREDITMODE_CREATE);
1012 else
1013 mpView->SetEditMode(SDREDITMODE_EDIT);
1015 bool bEmptyOutliner = false;
1017 if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1019 ::Outliner* pOutl = mpView->GetTextEditOutliner();
1020 sal_Int32 nParaAnz = pOutl->GetParagraphCount();
1021 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1023 if (nParaAnz==1 && p1stPara)
1025 // with only one paragraph
1026 if (pOutl->GetText(p1stPara).isEmpty())
1028 bEmptyOutliner = true;
1033 if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1035 sal_uInt32 nInv = mxTextObj->GetObjInventor();
1036 sal_uInt16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1038 if (nInv == SdrInventor && GetTextObj()->HasTextEdit() &&
1039 (nSdrObjKind == OBJ_TEXT ||
1040 nSdrObjKind == OBJ_TITLETEXT ||
1041 nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1043 // create new outliner (owned by SdrObjEditView)
1044 SdrOutliner* pOutl = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, *mpDoc);
1046 if (bEmptyOutliner)
1047 mpView->SdrEndTextEdit(true);
1049 SdrTextObj* pTextObj = GetTextObj();
1050 if( pTextObj )
1052 OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1053 if( ( pOPO && pOPO->IsVertical() ) || (nSlotId == SID_ATTR_CHAR_VERTICAL) || (nSlotId == SID_TEXT_FITTOSIZE_VERTICAL) )
1054 pOutl->SetVertical( true );
1056 if( pTextObj->getTextCount() > 1 )
1058 Point aPix(rMEvt.GetPosPixel());
1059 Point aPnt(mpWindow->PixelToLogic(aPix));
1060 pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1063 if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, true, pOutl) && mxTextObj->GetObjInventor() == SdrInventor)
1065 bFirstObjCreated = true;
1066 DeleteDefaultText();
1068 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1070 nSdrObjKind = mxTextObj->GetObjIdentifier();
1072 SdrViewEvent aVEvt;
1073 SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1075 if (eHit == SDRHIT_TEXTEDIT)
1077 // hit text
1078 if (nSdrObjKind == OBJ_TEXT ||
1079 nSdrObjKind == OBJ_TITLETEXT ||
1080 nSdrObjKind == OBJ_OUTLINETEXT ||
1081 nSdrObjKind == OBJ_TABLE ||
1082 nSlotId == SID_TEXTEDIT ||
1083 !bQuickDrag)
1085 pOLV->MouseButtonDown(rMEvt);
1086 pOLV->MouseMove(rMEvt);
1087 pOLV->MouseButtonUp(rMEvt);
1090 if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1092 pOLV->MouseButtonDown(rMEvt);
1095 else
1097 // Move cursor to end of text
1098 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1099 if (pOLV != NULL)
1100 pOLV->SetSelection(aNewSelection);
1103 else
1105 mpView->RestoreDefaultText(dynamic_cast< SdrTextObj* >( mxTextObj.get() ));
1111 else
1113 mxTextObj.reset(0);
1118 * Text entry is started, if necessary delete the default text.
1120 bool FuText::DeleteDefaultText()
1122 bool bDeleted = false;
1124 if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() )
1126 SdPage* pPage = static_cast<SdPage*>( mxTextObj->GetPage() );
1128 if (pPage)
1130 PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1132 if ( (ePresObjKind == PRESOBJ_TITLE ||
1133 ePresObjKind == PRESOBJ_OUTLINE ||
1134 ePresObjKind == PRESOBJ_NOTES ||
1135 ePresObjKind == PRESOBJ_TEXT) &&
1136 !pPage->IsMasterPage() )
1138 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1139 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1140 bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1141 if( bIsUndoEnabled )
1142 pOutliner->EnableUndo(false);
1144 pOutliner->SetText( OUString(), pOutliner->GetParagraph( 0 ) );
1146 if( bIsUndoEnabled )
1147 pOutliner->EnableUndo(true);
1149 if (pSheet &&
1150 (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1151 pOutliner->SetStyleSheet(0, pSheet);
1153 mxTextObj->SetEmptyPresObj(true);
1154 bDeleted = true;
1159 return bDeleted;
1162 bool FuText::Command(const CommandEvent& rCEvt)
1164 return FuPoor::Command(rCEvt);
1167 bool FuText::RequestHelp(const HelpEvent& rHEvt)
1169 bool bReturn = false;
1171 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1173 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1174 mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1176 OUString aHelpText;
1177 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1178 const SvxFieldData* pField = pFieldItem->GetField();
1180 if (pField && pField->ISA(SvxURLField))
1182 // URL-Field
1183 aHelpText = INetURLObject::decode( static_cast<const SvxURLField*>(pField)->GetURL(), INetURLObject::DECODE_WITH_CHARSET );
1185 if (!aHelpText.isEmpty())
1187 Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1188 Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1189 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1191 if (Help::IsBalloonHelpEnabled())
1193 bReturn = Help::ShowBalloon( (vcl::Window*)mpWindow, rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1195 else if (Help::IsQuickHelpEnabled())
1197 bReturn = Help::ShowQuickHelp( (vcl::Window*)mpWindow, aScreenRect, aHelpText);
1202 if (!bReturn)
1204 bReturn = FuConstruct::RequestHelp(rHEvt);
1207 return bReturn;
1210 void FuText::ReceiveRequest(SfxRequest& rReq)
1212 nSlotId = rReq.GetSlot();
1214 // then we call the base class (besides others, nSlotId is NOT set there)
1215 FuPoor::ReceiveRequest(rReq);
1217 if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId)
1219 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1221 mxTextObj.reset(0);
1223 if (nSlotId == SID_TEXTEDIT)
1225 // are we currently editing?
1226 if(!bTestText)
1227 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetTextEditObject() ) );
1229 if (!mxTextObj.is())
1231 // Try to select an object
1232 SdrPageView* pPV = mpView->GetSdrPageView();
1233 SdrViewEvent aVEvt;
1234 mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
1235 mpView->MarkObj(aVEvt.pRootObj, pPV);
1237 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
1239 mxTextObj.reset( static_cast< SdrTextObj* >( aVEvt.pObj ) );
1243 else if (mpView->AreObjectsMarked())
1245 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1247 if (rMarkList.GetMarkCount() == 1)
1249 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1251 if (pObj->ISA(SdrTextObj))
1253 mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1258 bool bQuickDrag = true;
1260 const SfxItemSet* pArgs = rReq.GetArgs();
1262 if (pArgs
1264 // test for type before using
1265 && SID_TEXTEDIT == nSlotId
1266 && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
1268 && (sal_uInt16) static_cast<const SfxUInt16Item&>( pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1270 // selection wit double click -> do not allow QuickDrag
1271 bQuickDrag = false;
1274 SetInEditMode(aMEvt, bQuickDrag);
1278 void FuText::DoubleClick(const MouseEvent& )
1280 // Nothing to do
1283 /** Removed the insertion of default text and putting a new text
1284 object directly into edit mode.
1286 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
1289 SdrObject* pObj = SdrObjFactory::MakeNewObject(
1290 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
1291 0L, mpDoc);
1293 if(pObj)
1295 if(pObj->ISA(SdrTextObj))
1297 SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
1298 pText->SetLogicRect(rRectangle);
1300 bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1301 pText->SetVerticalWriting(bVertical);
1303 ImpSetAttributesForNewTextObject(pText);
1305 if (nSlotId == SID_TEXT_FITTOSIZE)
1307 ImpSetAttributesFitToSize(pText);
1309 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1311 ImpSetAttributesFitToSizeVertical(pText);
1313 else
1315 ImpSetAttributesFitCommon(pText);
1318 // Put text object into edit mode.
1319 SdrPageView* pPV = mpView->GetSdrPageView();
1320 mpView->SdrBeginTextEdit(pText, pPV);
1322 else
1324 OSL_FAIL("Object is NO text object");
1328 return pObj;
1331 /** is called when the current function should be aborted. <p>
1332 This is used when a function gets a KEY_ESCAPE but can also
1333 be called directly.
1335 @returns true if a active function was aborted
1337 bool FuText::cancel()
1339 if ( mpView->IsTextEdit() )
1341 if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
1342 mxTextObj.reset(0);
1344 mpView->SetCurrentObj(OBJ_TEXT);
1345 mpView->SetEditMode(SDREDITMODE_EDIT);
1346 return true;
1348 else
1350 return false;
1354 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1356 if( !pFontList || !pView )
1357 return;
1359 if( pOLV )
1361 pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1363 else
1366 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1367 for( size_t nMark = 0; nMark < rMarkList.GetMarkCount(); ++nMark )
1369 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1370 if( pTextObj )
1372 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1374 pTextObj->setActiveText( nText );
1376 // Put text object into edit mode.
1377 SdrPageView* pPV = pView->GetSdrPageView();
1378 pView->SdrBeginTextEdit(pTextObj, pPV);
1380 pOLV = pView->GetTextEditOutlinerView();
1381 if( pOLV )
1383 EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1384 if( pEditEngine )
1386 ESelection aSel;
1387 aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1388 aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1389 pOLV->SetSelection(aSel);
1392 ChangeFontSize( bGrow, pOLV, pFontList, pView );
1395 pView->SdrEndTextEdit();
1398 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1399 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1401 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1402 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1403 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1410 } // end of namespace sd
1412 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */