Update ooo320-m1
[ooovba.git] / sc / source / ui / drawfunc / futext.cxx
bloba0fc59935bb9a76584a8076b353dbfc037de2cda
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: futext.cxx,v $
10 * $Revision: 1.28.128.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <svx/svddef.hxx>
35 #include <svx/svdoutl.hxx>
36 #include <svx/outlobj.hxx>
37 #include <svx/sdtaaitm.hxx>
38 #include <svx/sdtacitm.hxx>
39 #include <svx/svdotext.hxx>
40 #include <svx/unolingu.hxx>
41 #include <svx/svdocapt.hxx>
42 #include <sfx2/bindings.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <svx/svxids.hrc>
46 #include <svx/eeitem.hxx>
47 #include <svtools/itemset.hxx>
49 #include "futext.hxx"
50 #include "drwlayer.hxx"
51 #include "sc.hrc"
52 #include "tabvwsh.hxx"
53 #include "drawview.hxx"
55 // #98185# Create default drawing objects via keyboard
56 #include "scresid.hxx"
58 // Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
59 //! fusel,fuconstr,futext - zusammenfassen!
60 #define SC_MAXDRAGMOVE 3
62 //------------------------------------------------------------------
64 void lcl_InvalidateAttribs( SfxBindings& rBindings )
66 rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
67 rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
68 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
69 rBindings.Invalidate( SID_ULINE_VAL_NONE );
70 rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
71 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
72 rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
73 rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
74 rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
75 rBindings.Invalidate( SID_ATTR_CHAR_FONT );
76 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
77 rBindings.Invalidate( SID_ALIGNLEFT );
78 rBindings.Invalidate( SID_ALIGNCENTERHOR );
79 rBindings.Invalidate( SID_ALIGNRIGHT );
80 rBindings.Invalidate( SID_ALIGNBLOCK );
81 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
82 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
83 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
84 rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
85 rBindings.Invalidate( SID_SET_SUB_SCRIPT );
86 rBindings.Invalidate( SID_HYPERLINK_GETLINK );
87 rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
88 rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
89 rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
90 rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
91 // pseudo slots for Format menu
92 rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
93 rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
94 rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
95 rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
98 void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj )
100 // use hyphenator only if hyphenation attribute is set
101 if ( pObj && ((const SfxBoolItem&)pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) {
102 com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() );
103 rOutliner.SetHyphenator( xHyphenator );
107 /*************************************************************************
109 |* Basisklasse fuer Textfunktionen
111 \************************************************************************/
113 FuText::FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
114 SdrModel* pDoc, SfxRequest& rReq) :
115 FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq),
116 pTextObj(NULL)
120 /*************************************************************************
122 |* Destruktor
124 \************************************************************************/
126 FuText::~FuText()
128 // StopEditMode(); // in Deactivate !
131 /*************************************************************************
133 |* MouseButtonDown-event
135 \************************************************************************/
137 BOOL __EXPORT FuText::MouseButtonDown(const MouseEvent& rMEvt)
139 // #95491# remember button state for creation of own MouseEvents
140 SetMouseButtonCode(rMEvt.GetButtons());
142 if ( pView->MouseButtonDown(rMEvt, pWindow) )
143 return (TRUE); // Event von der SdrView ausgewertet
145 if ( pView->IsTextEdit() )
147 if( !IsSizingOrMovingNote(rMEvt) )
148 StopEditMode(); // Danebengeklickt, Ende mit Edit
149 pView->SetCreateMode();
152 aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
154 if ( rMEvt.IsLeft() )
156 SdrHdl* pHdl = pView->PickHandle(aMDPos);
158 ULONG nHdlNum = pView->GetHdlNum(pHdl);
160 if (pHdl != NULL)
162 if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl))
164 BOOL bPointMarked=pView->IsPointMarked(*pHdl);
166 if ( rMEvt.IsShift() )
168 if (!bPointMarked)
170 pView->MarkPoint(*pHdl);
172 else
174 pView->UnmarkPoint(*pHdl);
177 else
179 if (!bPointMarked)
181 pView->UnmarkAllPoints();
182 pView->MarkPoint(*pHdl);
185 pHdl=pView->GetHdl(nHdlNum);
189 SdrObject* pObj;
190 SdrPageView* pPV;
192 if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
194 if (pHdl == NULL &&
195 // pView->TakeTextEditObject(aMDPos, pObj, pPV) )
196 pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT) )
198 SdrOutliner* pO = MakeOutliner();
199 lcl_UpdateHyphenator( *pO, pObj );
201 // vertical flag:
202 // deduced from slot ids only if text object has no content
204 USHORT nSlotID = aSfxRequest.GetSlot();
205 BOOL bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
206 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
207 if ( pOPO )
208 bVertical = pOPO->IsVertical(); // content wins
209 pO->SetVertical( bVertical );
211 //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
212 if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
214 // EditEngine-UndoManager anmelden
215 pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
217 OutlinerView* pOLV = pView->GetTextEditOutlinerView();
218 if ( pOLV->MouseButtonDown(rMEvt) )
219 return (TRUE); // Event an den Outliner
222 else
224 // disable tail & circular move for caption objects.
225 bool bDrag = false;
226 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
227 if( rMarkList.GetMarkCount() == 1 )
229 SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
230 if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
232 if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)
233 bDrag = true;
235 else
236 bDrag = true; // different object
238 else
239 bDrag = true; // several objects
241 if ( bDrag )
243 aDragTimer.Start();
244 pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
248 else
250 BOOL bMacro = FALSE;
252 // if (bMacro && pView->TakeMacroObject(aMDPos,pObj,pPV))
253 if (bMacro && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
256 pView->BegMacroObj(aMDPos,pObj,pPV,pWindow);
258 else
260 if (pView->IsEditMode())
262 BOOL bPointMode=pView->HasMarkablePoints();
264 if (!rMEvt.IsShift())
266 if (bPointMode)
268 pView->UnmarkAllPoints();
270 else
272 pView->UnmarkAll();
275 pView->SetDragMode(SDRDRAG_MOVE);
276 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
277 rBindings.Invalidate( SID_OBJECT_ROTATE );
278 rBindings.Invalidate( SID_OBJECT_MIRROR );
279 pHdl=pView->GetHdl(nHdlNum);
282 if ( pView->MarkObj(aMDPos, -2, FALSE, rMEvt.IsMod1()) )
284 aDragTimer.Start();
286 pHdl=pView->PickHandle(aMDPos);
288 if (pHdl!=NULL)
290 pView->MarkPoint(*pHdl);
291 pHdl=pView->GetHdl(nHdlNum);
294 pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
296 else
298 if (bPointMode)
300 pView->BegMarkPoints(aMDPos);
302 else
304 pView->BegMarkObj(aMDPos);
308 else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
310 // Notizen editieren -> keine neuen Textobjekte erzeugen,
311 // stattdessen Textmodus verlassen
313 pViewShell->GetViewData()->GetDispatcher().
314 Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
316 else
318 /**********************************************************
319 * Objekt erzeugen
320 **********************************************************/
321 pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
328 if (!bIsInDragMode)
330 pWindow->CaptureMouse();
331 // ForcePointer(&rMEvt);
332 lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
335 pViewShell->SetActivePointer(pView->GetPreferedPointer(
336 pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
338 // return (bReturn);
339 return TRUE;
342 /*************************************************************************
344 |* MouseMove-event
346 \************************************************************************/
348 BOOL __EXPORT FuText::MouseMove(const MouseEvent& rMEvt)
350 BOOL bReturn = FALSE;
352 // pViewShell->SetActivePointer(aNewPointer);
354 pViewShell->SetActivePointer(pView->GetPreferedPointer(
355 pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
357 if (aDragTimer.IsActive() )
359 Point aOldPixel = pWindow->LogicToPixel( aMDPos );
360 Point aNewPixel = rMEvt.GetPosPixel();
361 if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
362 Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
363 aDragTimer.Stop();
366 if ( pView->MouseMove(rMEvt, pWindow) )
367 return (TRUE); // Event von der SdrView ausgewertet
369 if ( pView->IsAction() )
371 /* aNewPointer = Pointer(POINTER_TEXT);
372 pViewShell->SetActivePointer(aNewPointer);
374 Point aPix(rMEvt.GetPosPixel());
375 Point aPnt(pWindow->PixelToLogic(aPix));
377 ForceScroll(aPix);
378 pView->MovAction(aPnt);
381 // ForcePointer(&rMEvt);
383 return (bReturn);
386 /*************************************************************************
388 |* MouseButtonUp-event
390 \************************************************************************/
392 BOOL __EXPORT FuText::MouseButtonUp(const MouseEvent& rMEvt)
394 // #95491# remember button state for creation of own MouseEvents
395 SetMouseButtonCode(rMEvt.GetButtons());
397 BOOL bReturn = FALSE;
399 if (aDragTimer.IsActive() )
401 aDragTimer.Stop();
404 lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
406 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
408 if ( pView->MouseButtonUp(rMEvt, pWindow) )
409 return (TRUE); // Event von der SdrView ausgewertet
411 if ( pView->IsDragObj() )
413 pView->EndDragObj( rMEvt.IsShift() );
414 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
415 if (rMarkList.GetMarkCount() == 1)
417 SdrMark* pMark = rMarkList.GetMark(0);
418 SdrObject* pObj = pMark->GetMarkedSdrObj();
419 FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
420 FuText* pText = static_cast<FuText*>(pPoor);
421 pText->StopDragMode(pObj );
423 pView->ForceMarkedToAnotherPage();
425 else if ( pView->IsCreateObj() )
427 if (rMEvt.IsLeft())
429 pView->EndCreateObj(SDRCREATE_FORCEEND);
430 if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE)
432 // Lauftext-Objekt erzeugen?
434 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
435 if (rMarkList.GetMark(0))
437 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
439 // die fuer das Scrollen benoetigten Attribute setzen
440 SfxItemSet aItemSet( pDrDoc->GetItemPool(),
441 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
443 aItemSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
444 aItemSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
445 aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
446 aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
447 aItemSet.Put( SdrTextAniCountItem( 1 ) );
448 aItemSet.Put( SdrTextAniAmountItem(
449 (INT16)pWindow->PixelToLogic(Size(2,1)).Width()) );
450 pObj->SetMergedItemSetAndBroadcast(aItemSet);
454 // #93382# init object different when vertical writing
455 sal_uInt16 nSlotID(aSfxRequest.GetSlot());
456 BOOL bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID);
457 if(bVertical)
459 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
460 if(rMarkList.GetMark(0))
462 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
463 if(pObj && pObj->ISA(SdrTextObj))
465 SdrTextObj* pText = (SdrTextObj*)pObj;
466 SfxItemSet aSet(pDrDoc->GetItemPool());
468 pText->SetVerticalWriting(TRUE);
470 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
471 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
472 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
473 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
475 pText->SetMergedItemSet(aSet);
480 SetInEditMode();
482 // Modus verlassen bei einzelnem Klick
483 // (-> fuconstr)
485 if ( !pView->AreObjectsMarked() )
487 pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1());
489 SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
490 if ( pView->AreObjectsMarked() )
491 rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
492 else
493 rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
497 else if ( pView->IsAction() )
499 pView->EndAction();
501 else if( !pView->IsAction() )
503 pWindow->ReleaseMouse();
505 if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
507 pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1());
509 SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
510 if ( pView->AreObjectsMarked() )
511 rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
512 else
513 rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
517 return (bReturn);
520 /*************************************************************************
522 |* Maus-Pointer umschalten
524 \************************************************************************/
526 void FuText::ForcePointer(const MouseEvent* /* pMEvt */)
528 pViewShell->SetActivePointer( aNewPointer );
531 if ( !pView->IsAction() )
533 Point aPnt(pWindow->PixelToLogic( pWindow->ScreenToOutputPixel(
534 Pointer::GetPosPixel() ) ) );
535 SdrHdl* pHdl=pView->HitHandle(aPnt, *pWindow);
537 if (pHdl!=NULL)
539 pViewShell->SetActivePointer(pHdl->GetPointer() );
541 else
543 SdrObject* pObj;
544 SdrPageView* pPV;
546 if ( pView->IsMarkedHit(aPnt) )
548 if ( pView->TakeTextEditObject(aPnt, pObj, pPV) )
550 pViewShell->SetActivePointer(Pointer(POINTER_TEXT));
552 else
554 pViewShell->SetActivePointer(Pointer(POINTER_MOVE));
557 else
559 // if ( pView->TakeMacroObject(aPnt, pObj, pPV) )
560 if ( pView->PickObj(aPnt, pObj, pPV, SDRSEARCH_PICKMACRO) )
562 pViewShell->SetActivePointer( pObj->GetMacroPointer() );
564 else
566 pViewShell->SetActivePointer( aNewPointer );
576 /*************************************************************************
578 |* Tastaturereignisse bearbeiten
580 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
581 |* FALSE.
583 \************************************************************************/
585 BOOL __EXPORT FuText::KeyInput(const KeyEvent& rKEvt)
587 BOOL bReturn = FALSE;
589 if ( pView->KeyInput(rKEvt, pWindow) )
591 bReturn = TRUE;
592 lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
594 else
596 bReturn = FuDraw::KeyInput(rKEvt);
599 return (bReturn);
604 /*************************************************************************
606 |* Function aktivieren
608 \************************************************************************/
610 void FuText::Activate()
612 pView->SetDragMode(SDRDRAG_MOVE);
613 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
614 rBindings.Invalidate( SID_OBJECT_ROTATE );
615 rBindings.Invalidate( SID_OBJECT_MIRROR );
617 // Sofort in den Edit Mode setzen
618 // SetInEditMode();
620 // if (!pTextObj)
622 /**********************************************************************
623 * Kein Textobjekt im EditMode, daher CreateMode setzen
624 **********************************************************************/
625 USHORT nObj = OBJ_TEXT;
627 /* UINT16 nIdent;
628 UINT32 nInvent;
629 pView->TakeCurrentObj(nIdent, nInvent);
631 pView->SetCurrentObj(nObj);
633 pView->SetCreateMode();
636 aNewPointer = Pointer(POINTER_TEXT);
637 // aNewPointer = Pointer(POINTER_CROSS); //! ???
639 aOldPointer = pWindow->GetPointer();
640 pViewShell->SetActivePointer( aNewPointer );
642 FuConstruct::Activate();
646 /*************************************************************************
648 |* Function deaktivieren
650 \************************************************************************/
652 void FuText::Deactivate()
654 FuConstruct::Deactivate();
655 pViewShell->SetActivePointer( aOldPointer );
656 StopEditMode();
660 /*************************************************************************
662 |* Selektion hat sich geaendert
664 \************************************************************************/
666 void FuText::SelectionHasChanged()
668 pView->SetDragMode(SDRDRAG_MOVE);
669 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
670 rBindings.Invalidate( SID_OBJECT_ROTATE );
671 rBindings.Invalidate( SID_OBJECT_MIRROR );
673 pTextObj = NULL;
675 if ( pView->AreObjectsMarked() )
677 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
679 if (rMarkList.GetMarkCount() == 1)
681 SdrMark* pMark = rMarkList.GetMark(0);
682 SdrObject* pObj = pMark->GetMarkedSdrObj();
684 UINT16 nSdrObjKind = pObj->GetObjIdentifier();
686 if (nSdrObjKind == OBJ_TEXT ||
687 nSdrObjKind == OBJ_TITLETEXT ||
688 nSdrObjKind == OBJ_OUTLINETEXT /* ||
689 pObj->ISA(SdrTextObj) */ )
691 pTextObj = (SdrTextObj*) pObj;
696 if (!pTextObj)
698 /**********************************************************************
699 * Kein Textobjekt im EditMode, daher CreateMode setzen
700 **********************************************************************/
701 USHORT nObj = OBJ_TEXT;
702 UINT16 nIdent;
703 UINT32 nInvent;
704 pView->TakeCurrentObj(nIdent, nInvent);
706 // if (! pView->IsEditMode() )
707 // {
708 // if (nIdent == OBJ_TEXT)
709 // {
710 // nObj = OBJ_TEXT;
711 // }
712 // else if (nIdent == OBJ_OUTLINETEXT)
713 // {
714 // nObj = OBJ_OUTLINETEXT;
715 // }
716 // else if (nIdent == OBJ_TITLETEXT)
717 // {
718 // nObj = OBJ_TITLETEXT;
719 // }
720 // }
722 pView->SetCurrentObj(nObj);
724 pView->SetCreateMode();
728 /*************************************************************************
730 |* Objekt in Edit-Mode setzen
732 \************************************************************************/
734 void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
735 BOOL bCursorToEnd, const KeyEvent* pInitialKey)
737 /* It is possible to pass a special (unselected) object in pObj, e.g. the
738 caption object of a cell note. If pObj is 0, then the selected object
739 is used. The layer will be relocked in FuText::StopEditMode(). */
740 if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) )
741 pView->UnlockInternalLayer();
743 if ( !pObj && pView->AreObjectsMarked() )
745 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
746 if (rMarkList.GetMarkCount() == 1)
748 SdrMark* pMark = rMarkList.GetMark(0);
749 pObj = pMark->GetMarkedSdrObj();
753 pTextObj = NULL;
755 if ( pObj )
757 UINT16 nSdrObjKind = pObj->GetObjIdentifier();
759 if (nSdrObjKind == OBJ_TEXT ||
760 nSdrObjKind == OBJ_TITLETEXT ||
761 nSdrObjKind == OBJ_OUTLINETEXT ||
762 pObj->ISA(SdrTextObj))
764 SdrPageView* pPV = pView->GetSdrPageView();
765 Rectangle aRect = pObj->GetLogicRect();
766 Point aPnt = aRect.Center();
768 if ( pObj->HasTextEdit() )
770 SdrOutliner* pO = MakeOutliner();
771 lcl_UpdateHyphenator( *pO, pObj );
773 // vertical flag:
774 // deduced from slot ids only if text object has no content
776 USHORT nSlotID = aSfxRequest.GetSlot();
777 BOOL bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
778 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
779 if ( pOPO )
780 bVertical = pOPO->IsVertical(); // content wins
781 pO->SetVertical( bVertical );
783 //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
784 if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
786 // EditEngine-UndoManager anmelden
787 pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
789 pTextObj = (SdrTextObj*) pObj;
790 pView->SetEditMode();
792 // set text cursor to click position or to end,
793 // pass initial key event to outliner view
794 if ( pMousePixel || bCursorToEnd || pInitialKey )
796 OutlinerView* pOLV = pView->GetTextEditOutlinerView();
797 if (pOLV)
799 if ( pMousePixel )
801 MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
802 pOLV->MouseButtonDown(aEditEvt);
803 pOLV->MouseButtonUp(aEditEvt);
805 else if ( bCursorToEnd )
807 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
808 pOLV->SetSelection(aNewSelection);
811 if ( pInitialKey )
812 pOLV->PostKeyEvent( *pInitialKey );
821 // #98185# Create default drawing objects via keyboard
822 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
824 // case SID_DRAW_TEXT:
825 // case SID_DRAW_TEXT_VERTICAL:
826 // case SID_DRAW_TEXT_MARQUEE:
827 // case SID_DRAW_NOTEEDIT:
829 SdrObject* pObj = SdrObjFactory::MakeNewObject(
830 pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
831 0L, pDrDoc);
833 if(pObj)
835 if(pObj->ISA(SdrTextObj))
837 SdrTextObj* pText = (SdrTextObj*)pObj;
838 pText->SetLogicRect(rRectangle);
840 // #105815# don't set default text, start edit mode instead
841 // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
842 // pText->SetText(aText);
844 sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID);
845 sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID);
847 pText->SetVerticalWriting(bVertical);
849 if(bVertical)
851 SfxItemSet aSet(pDrDoc->GetItemPool());
853 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
854 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
855 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
856 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
858 pText->SetMergedItemSet(aSet);
861 if(bMarquee)
863 SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
865 aSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
866 aSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
867 aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
868 aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
869 aSet.Put( SdrTextAniCountItem( 1 ) );
870 aSet.Put( SdrTextAniAmountItem( (INT16)pWindow->PixelToLogic(Size(2,1)).Width()) );
872 pObj->SetMergedItemSetAndBroadcast(aSet);
875 SetInEditMode( pObj ); // #105815# start edit mode
877 else
879 DBG_ERROR("Object is NO text object");
883 return pObj;